<%@ Page language="c#" Codebehind="pubScoreArea_View.aspx.cs" AutoEventWireup="false" Inherits="KPIS.Scoring.pubScoreArea_View" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>pubScoreArea_View</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="" name="vs_targetSchema"> <LINK href="../CSS/style1.css" type="text/css" rel="stylesheet"> <script language="javascript" src="../JavaScript/meizz2.js"></script> <LINK href="../CSS/style2.css" type="text/css" rel="stylesheet"> <script language="javascript"> var bgColorNotSelect = "#ffffff"; var bgColorSelected = "#fceade"; var selectedLine = null; function SelectLine(trID){ if (document.getElementById(trID) !=null){ if (selectedLine==trID){ document.getElementById(trID).style.backgroundColor = bgColorNotSelect; } else { if (selectedLine !=null){ document.getElementById(selectedLine).style.background = bgColorNotSelect; } document.getElementById(trID).style.backgroundColor = bgColorSelected; } } selectedLine=trID; } </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <table class="tblouter" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td> <TABLE class="titletbl" id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0"> <TR> <td class="title1_L"></td> <TD class="td_title1"><asp:label id="lbUseInfo" runat="server" CssClass="f_title"></asp:label></TD> <td class="title1_R"></td> </TR> </TABLE> </td> </tr> <tr> <td><iewc:toolbar id="Toolbar1" runat="server" CssClass="toolbar" borderWidth="1px" border="0" DefaultStyle='background:url("../images/toolbar_bg.gif")'> <iewc:ToolbarButton Text="Add" ID="ibtnAdd" ImageUrl="../images/NewP.gif" DefaultStyle="border:0px; padding: 2px 0px 2px 20px;" HoverStyle="cursor:hand; padding: 2px 0px 2px 20px;" SelectedStyle="border: 0px; padding: 2px 0px 2px 18px;"></iewc:ToolbarButton> <iewc:ToolbarButton Text="Refresh" ID="ibtnRefresh" ImageUrl="../images/Refresh.gif" DefaultStyle="border:0px; padding: 2px 0px 2px 20px;" HoverStyle="cursor:hand; padding: 2px 0px 2px 20px;" SelectedStyle="border: 0px; padding: 2px 0px 2px 18px;"></iewc:ToolbarButton> <iewc:ToolbarButton Text="Back" ID="ibtnBack" ImageUrl="../images/back.gif" DefaultStyle="border:0px; padding: 2px 0px 2px 20px;" HoverStyle="cursor:hand; padding: 2px 0px 2px 20px;" SelectedStyle="border: 0px; padding: 2px 0px 2px 18px;"></iewc:ToolbarButton> </iewc:toolbar></td> </tr> <tr> <td><span id="span_Header" runat="server"> <table style="WIDTH: 100%; HEIGHT: 58px" cellSpacing="0" cellPadding="0" border="0"> <tr> <td style="WIDTH: 76px; HEIGHT: 3px"><font color="red">Indicator*:</font></td> <td style="WIDTH: 171px; HEIGHT: 3px"><asp:dropdownlist id="ddlIndicator" Runat="server" Width="296px"></asp:dropdownlist></td> <td style="WIDTH: 69px; HEIGHT: 3px"><font color="red">Weight(%)*:</font></td> <td style="WIDTH: 107px; HEIGHT: 3px"><asp:textbox id="tbWeight" Runat="server" Width="80px">0</asp:textbox></td> <td style="WIDTH: 65px; HEIGHT: 3px">Level:</td> <td style="HEIGHT: 3px"><asp:dropdownlist id="ddlLevel" Runat="server" Width="88px"></asp:dropdownlist></td> </tr> <tr> <td style="WIDTH: 76px"><font color="red">Scoring By*:</font></td> <td><asp:dropdownlist id="ddlScoringBy" Runat="server" Width="147px"></asp:dropdownlist></td> <td style="WIDTH: 69px"><font color="red">show Sort*:</font></td> <td style="WIDTH: 107px"><asp:textbox id="tbshowSort" Runat="server" Width="80px">0</asp:textbox></td> <td>Remark</td> <td><asp:textbox id="tbRemark" Runat="server" Width="312px"></asp:textbox></td> </tr> <tr> <td>Valid date<font class="Fred2">*</font>:</td> <td><asp:textbox id="tbvalid" runat="server" Width="136px" ></asp:textbox></td> <td>Invalid date<font class="Fred2">*</font>:</td> <td colspan="3"><asp:textbox id="tbinvalid" runat="server" Width="136px" ></asp:textbox></td> </tr> <tr> <td align="center" colSpan="8"><asp:button id="btnSave" CssClass="btn70" Runat="server" Text="Save"></asp:button><FONT face="新細明體"> </FONT> <asp:button id="btnCancel" CssClass="btn70" Runat="server" Text="Cancel"></asp:button></td> </tr> </table> </span> </td> </tr> <TR> <td class="pL20"><asp:dropdownlist id="ddlQuery" runat="server" Width="136px"> <asp:ListItem Value="(all*)" Selected="True">(all*)</asp:ListItem> <asp:ListItem Value="irName">Indicator</asp:ListItem> <asp:ListItem Value="Level">Level</asp:ListItem> </asp:dropdownlist><asp:textbox id="tbQuery" runat="server" Width="136px"></asp:textbox><asp:button id="btnQuery" CssClass="search2" Runat="server" Text="Query"></asp:button></td> </TR> <TR> <TD> <table class="tblpage" cellSpacing="0" cellPadding="0" width="100%"> <tr> <td> <div>Record Total: <asp:label id="LRecords" runat="server" CssClass="fred" Width="20px"></asp:label>Page Current: <asp:label id="LPage" runat="server" CssClass="fred" Width="10px"></asp:label>/ <asp:label id="LPages" runat="server" CssClass="fred" Width="10px"></asp:label>Page </div> </td> </tr> </table> <asp:datagrid id="dgScoreArea" runat="server" ItemStyle-Font-Name="Arial" ItemStyle-Font-Size="9pt" HeaderStyle-Font-Name="Arial" HeaderStyle-Font-Size="10pt" width="100%" DataKeyField="saID" AutoGenerateColumns="False" BorderWidth="1px" BorderColor="#6F9CC3" AllowPaging="True" PageSize="25" AllowSorting="True"> <AlternatingItemStyle CssClass="ais_1"></AlternatingItemStyle> <ItemStyle Font-Size="9pt" Font-Names="Arial" CssClass="is_1"></ItemStyle> <HeaderStyle Font-Size="10pt" Font-Names="Arial" CssClass="hs_1"></HeaderStyle> <Columns> <asp:BoundColumn Visible="False" DataField="saID"></asp:BoundColumn> <asp:BoundColumn DataField="irMName" SortExpression="irMName" ReadOnly="True" HeaderText="Indicator"></asp:BoundColumn> <asp:TemplateColumn SortExpression="Weight" HeaderText="Weight(%)"> <ItemTemplate> <asp:Label Runat="server" text='<%# Convert.ToString(Convert.ToDouble(DataBinder.Eval(Container.DataItem, "Weight").ToString())*100)+"%" %>' ID=Label2> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox Runat="server" ID="DGtbWeight" Text='<%# Convert.ToDouble(DataBinder.Eval(Container.DataItem, "Weight").ToString())*100 %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="Level" HeaderText="Level"> <ItemTemplate> <asp:Label Runat=server text='<%# DataBinder.Eval(Container.DataItem, "Level").ToString() %>' ID="Label3"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList Runat="server" ID="DGddlLevel" DataSource='<%# GetData(2) %>' SelectedIndex='<%# GetIndex(2,DataBinder.Eval(Container.DataItem, "Level").ToString()) %>'> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="ScoringBy" HeaderText="Scoring By"> <ItemTemplate> <asp:Label Runat=server text='<%# DataBinder.Eval(Container.DataItem, "mScroingBy").ToString() %>' ID="Label4"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList Runat="server" ID="DGddlScoringBy" DataSource='<%# GetData(3) %>' SelectedIndex='<%# GetIndex(3,DataBinder.Eval(Container.DataItem, "ScoringBy").ToString()) %>'> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="showSort" HeaderText="Show Sort"> <ItemTemplate> <asp:Label Runat="server" text='<%# DataBinder.Eval(Container.DataItem, "showSort").ToString() %>' ID="Label1"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox Runat="server" ID="DGtbshowSort" Text='<%# DataBinder.Eval(Container.DataItem, "showSort").ToString() %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="ValidDate" HeaderText="ValidDate"> <ItemTemplate> <asp:Label id=Label6 Runat="server" text='<%# String.Format("{0:yyyy-MM-dd}",DataBinder.Eval(Container.DataItem, "ValidDate")) %>'> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox id=tbValidDate Runat="server" οnfοcus="setdate(this);" Text='<%# String.Format("{0:yyyy-MM-dd}",DataBinder.Eval(Container.DataItem, "ValidDate")) %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="InvalidDate" HeaderText="InvalidDate"> <ItemTemplate> <asp:Label Runat="server" text='<%# String.Format("{0:yyyy-MM-dd}",DataBinder.Eval(Container.DataItem, "InvalidDate")) %>' ID="Label7"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox Runat="server" ID="tbInvalidDate" οnfοcus="setdate(this);" Text='<%# String.Format("{0:yyyy-MM-dd}",DataBinder.Eval(Container.DataItem, "InvalidDate")) %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:BoundColumn Visible="False" DataField="ValidDate" SortExpression="ValidDate" HeaderText="ValidDate" DataFormatString="{0:yyyy-MM-dd}"></asp:BoundColumn> <asp:BoundColumn Visible="False" DataField="InvalidDate" SortExpression="InvalidDate" HeaderText="InvalidDate" DataFormatString="{0:yyyy-MM-dd}"></asp:BoundColumn> <asp:TemplateColumn SortExpression="Remark" HeaderText="Remark"> <ItemTemplate> <asp:Label Runat="server" text='<%# DataBinder.Eval(Container.DataItem, "Remark").ToString() %>' ID="Label5"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox Runat="server" ID="DGtbRemark" Text='<%# DataBinder.Eval(Container.DataItem, "Remark").ToString() %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemStyle Width="80px"></ItemStyle> <ItemTemplate> <asp:HyperLink id=Select runat="server" Text="Show Detail" NavigateUrl='<%# "pubScoreArea_View.aspx?F_SysCode=" + Request["F_SysCode"] + "&saID=" + DataBinder.Eval(Container.DataItem, "saID") + "&irMID=" + DataBinder.Eval(Container.DataItem, "irMID") + "&pageNO=" + dgScoreArea.CurrentPageIndex %>'>Show Detail</asp:HyperLink> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemStyle Width="60px"></ItemStyle> <ItemTemplate> <asp:LinkButton id="lkSetDetail" Runat="server" Text="Set Detail" CommandName="Detail"></asp:LinkButton> </ItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"> <ItemStyle HorizontalAlign="Center"></ItemStyle> </asp:EditCommandColumn> <asp:TemplateColumn> <ItemStyle Width="40px"></ItemStyle> <ItemTemplate> <asp:LinkButton id="lkDelete" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton> </ItemTemplate> </asp:TemplateColumn> </Columns> <PagerStyle NextPageText="Next" Font-Size="10pt" Font-Names="Arial" PrevPageText="Previous" Position="TopAndBottom"></PagerStyle> </asp:datagrid></TD> </TR> <TR> <TD> <hr class="hr"> <asp:label id="lbDetail" runat="server" CssClass="fred2"></asp:label> <hr class="hr"> </TD> </TR> </table> </form> </body></HTML>using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace KPIS.Scoring
{ /// <summary> /// pubScoreArea_View 的摘要描述。 /// </summary> public class pubScoreArea_View : System.Web.UI.Page { protected System.Web.UI.WebControls.Label lbUseInfo; protected Microsoft.Web.UI.WebControls.Toolbar Toolbar1; protected System.Web.UI.WebControls.DropDownList ddlQuery; protected System.Web.UI.WebControls.TextBox tbQuery; protected System.Web.UI.WebControls.Button btnQuery; protected System.Web.UI.WebControls.Label LRecords; protected System.Web.UI.WebControls.Label LPage; protected System.Web.UI.WebControls.Label LPages; protected System.Web.UI.WebControls.DataGrid dgScoreArea; protected System.Web.UI.HtmlControls.HtmlGenericControl span_Header; protected System.Web.UI.WebControls.DropDownList ddlIndicator; protected System.Web.UI.WebControls.TextBox tbWeight; protected System.Web.UI.WebControls.DropDownList ddlLevel; protected System.Web.UI.WebControls.DropDownList ddlScoringBy; protected System.Web.UI.WebControls.TextBox tbshowSort; protected System.Web.UI.WebControls.Button btnSave; protected System.Web.UI.WebControls.Button btnCancel; protected System.Web.UI.WebControls.TextBox tbRemark; protected System.Web.UI.WebControls.TextBox tbvalid; protected System.Web.UI.WebControls.TextBox tbinvalid; protected System.Web.UI.WebControls.Label lbDetail; #region Web Form 設計工具產生的程式碼 override protected void OnInit(EventArgs e) { // // CODEGEN: 此為 ASP.NET Web Form 設計工具所需的呼叫。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改 /// 這個方法的內容。 /// </summary> private void InitializeComponent() { this.Toolbar1.ButtonClick += new System.EventHandler(this.Toolbar1_ButtonClick); this.btnSave.Click += new System.EventHandler(this.btnSave_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click); this.dgScoreArea.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgScoreArea_ItemCommand); this.dgScoreArea.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgScoreArea_PageIndexChanged); this.dgScoreArea.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgScoreArea_CancelCommand); this.dgScoreArea.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgScoreArea_EditCommand); this.dgScoreArea.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgScoreArea_SortCommand); this.dgScoreArea.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgScoreArea_UpdateCommand); this.dgScoreArea.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgScoreArea_DeleteCommand); this.dgScoreArea.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgScoreArea_ItemDataBound); this.Load += new System.EventHandler(this.Page_Load);}
#endregion CommClass.PubFunction func = new CommClass.PubFunction();public int GetIndex(int Index, string category) {
ArrayList arr = new ArrayList(); int i = 0; DataSet mydataset = new DataSet(); DataTable mydatatable = new DataTable();switch (Index){
case 1: // Indicator mydataset=func.GetDataTable("Select irMID, case when '"+ Session["Language"] +"' = 'Chinese' then irNameCH else irNameEN end as irName from pubIndicatorBase order by showSort"); break; case 2: // Level mydataset=func.GetDataTable("select Item, Remark from pubParameter where Category='productLevel' order by Remark "); arr.Add("ALL"); break; case 3: // ScroingBY mydataset=func.GetDataTable("select Item, Remark from pubParameter where Category='ScoringBy' order by Remark"); break; }mydatatable=mydataset.Tables[0];
Hashtable statusindex = new Hashtable();while (i < mydatatable.Rows.Count) {
statusindex[mydatatable.Rows[i][0].ToString()] = i; i += 1; } if (!((statusindex[category] == null))) { return ((int)(statusindex[category])); } else { return 0; } }public ArrayList GetData(int Index) {
ArrayList arr = new ArrayList(); int i = 0; DataSet mydataset = new DataSet(); DataTable mydatatable = new DataTable();switch (Index){
case 1: // Indicator mydataset=func.GetDataTable("Select irMID, case when '"+ Session["Language"] +"' = 'Chinese' then irNameCH else irNameEN end as irName from pubIndicatorBase order by showSort"); break; case 2: // Level mydataset=func.GetDataTable("select Item, Remark from pubParameter where Category='productLevel' order by Remark "); arr.Add("ALL"); break; case 3: // ScroingBY mydataset=func.GetDataTable("select Item, Remark from pubParameter where Category='ScoringBy' order by Remark"); break; } mydatatable=mydataset.Tables[0]; while (i < mydatatable.Rows.Count) { arr.Add(mydatatable.Rows[i][0].ToString()); i += 1; } return arr; } void dgbind() { DataSet ds; //綁定數據, 并且按照指定條件顯示出來 if ((IsPostBack==true) && (tbQuery.Text!="")) { ds=func.GetDataTable("Select *, case when ScoringBy='A' then 'Area' when ScoringBy='R' then 'Ranking' else 'Other' end as mScroingBy, "+ " case when '"+ Session["Language"] +"' = 'Chinese' then b.irMNameCH else b.irMNameEN end as irMName "+ " from pubScoreAreaM as a left join pubIndicatorMain as b on a.irMID =b.irMID where b.irMID in (select irMID from pubIndicatorbase where irID in (" +func.GetIndicatorID(Convert.ToInt32(Session["uID"]),"All")+")) and ("+getcond()+") "); } else { ds=func.GetDataTable("Select *, case when ScoringBy='A' then 'Area' when ScoringBy='R' then 'Ranking' else 'Other' end as mScroingBy, "+ " case when '"+ Session["Language"] +"' = 'Chinese' then b.irMNameCH else b.irMNameEN end as irMName "+ " from pubScoreAreaM as a left join pubIndicatorMain as b on a.irMID =b.irMID where datediff(day,getdate(),a.invaliddate)>=0 and datediff(day,getdate(),a.validdate)<=0 and b.irMID in (select irMID from pubIndicatorbase where irID in (" +func.GetIndicatorID(Convert.ToInt32(Session["uID"]),"All")+")) and ("+getcond()+") "); } DataView dv; dv=ds.Tables[0].DefaultView; dv.Sort=ViewState["sortitem"]+" "+ViewState["sortdir"]; dgScoreArea.DataSource=dv; if (dgScoreArea.CurrentPageIndex>=func.GetDGPageCount(ds.Tables[0],dgScoreArea)) { dgScoreArea.CurrentPageIndex=0; } dgScoreArea.DataBind(); LRecords.Text = ds.Tables[0].Rows.Count.ToString(); LPages.Text = dgScoreArea.PageCount.ToString(); LPage.Text = (dgScoreArea.CurrentPageIndex + 1).ToString(); if(ds.Tables[0].Rows.Count==0) { if (IsPostBack) { Response.Write("<script language=javascript>alert('There is no relational data!');</script>"); return; } } }//獲得查詢條件
string getcond() { string tbstr; tbstr=""; switch(ddlQuery.SelectedIndex) { case 0 : tbstr = "1=1"; break; case 1: if (tbQuery.Text.Trim() =="") tbstr = "1=1"; else tbstr =" (b.irMNameCH like '%"+ tbQuery.Text.Trim() +"%') or (b.irMNameEN like '%" + tbQuery.Text.Trim() +"%')" ; break; case 2: if (tbQuery.Text.Trim() =="") tbstr = "1=1"; else tbstr ="Level ='"+ tbQuery.Text.Trim() +"' " ; break; } return tbstr; }private void Page_Load(object sender, System.EventArgs e) {
if (Session["uID"] == null) { func.Login_Again();//Session 丟失後重新Login } else { if (Session["uID"].ToString() =="") { this.Response.Redirect("../Login.aspx"); } } if (!IsPostBack) { //獲取幫助信息 lbUseInfo.Text=func.GetUseInfo("pubScoreArea_View",Session["Language"].ToString()); this.tbvalid.Attributes.Add("onfocus","setdate(this);"); this.tbinvalid.Attributes.Add("onfocus","setdate(this);"); string s= Page.Request.Url.ToString(); //設定權限,新增/修改/刪除 if (Session["LoginRole"].ToString() !="A") { int uID =Convert.ToInt32(Session["uID"]); string F_SysCode =Request["F_SysCode"].ToString(); this.Toolbar1.Items.FlatIndexItem(0).Enabled =func.GetMenu(uID,F_SysCode,"Add"); if (func.GetMenu(uID,F_SysCode,"Delete") ==false) { dgScoreArea.Columns[dgScoreArea.Columns.Count-1].Visible =false; } if (func.GetMenu(uID,F_SysCode,"Edit") ==false) { dgScoreArea.Columns[dgScoreArea.Columns.Count-2].Visible =false; dgScoreArea.Columns[dgScoreArea.Columns.Count-3].Visible =false; } }tbWeight.Attributes.Add("onKeypress", "var isNS4 = (navigator.appName=='Netscape')?1:0; if(!isNS4){if(event.keyCode < 46 || event.keyCode > 57) event.returnValue = false;}else{if(event.which < 46 || event.which > 57) returnfalse;}");
tbshowSort.Attributes.Add("onKeypress", "var isNS4 = (navigator.appName=='Netscape')?1:0; if(!isNS4){if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;}else{if(event.which < 48 || event.which > 57) returnfalse;}"); //設定 DataGrid 的當前顯示頁碼 if (!(Request["pageNO"]==null)){ dgScoreArea.CurrentPageIndex=Convert.ToInt32(Request["pageNO"].ToString()); }ViewState["sortitem"]="showSort";
ViewState["sortdir"]="asc"; dgbind(); if (!(Request["irMID"]==null)) { DataSet ds; //顯示對應指標分值區間的明細設定資料 ds=func.GetDataTable("Select *, case when ScoringBy='A' then 'Area' when ScoringBy='R' then 'Ranking' else 'Other' end as mScroingBy, "+ " case when '"+ Session["Language"] +"' = 'Chinese' then b.irMNameCH else b.irMNameEN end as irMName "+ " from pubScoreAreaM as a left join pubIndicatorMain as b on a.irMID =b.irMID where a.irMID=" + Request["irMID"] +" "); if (ds.Tables[0].Rows.Count>0) { lbDetail.Text=ds.Tables[0].Rows[0]["irMName"].ToString() + " : "; } ds=func.GetDataTable("select dbo.GetScoreAreaString( " + Request["saID"] + ") as AreaString "); if (ds.Tables[0].Rows.Count>0) { lbDetail.Text += ds.Tables[0].Rows[0]["AreaString"]; } }span_Header.Visible=false;
} }private void dgScoreArea_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {
LinkButton DelButton= new LinkButton(); if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item)) { e.Item.Attributes.Add("onMouseover", "this.bgColor='#eeeeee'"); e.Item.Attributes.Add("onmouseout", "this.bgColor='white'"); e.Item.Attributes.Add("ID","dg_"+e.Item.Cells[0].Text); e.Item.Attributes.Add("onclick","SelectLine('dg_"+e.Item.Cells[0].Text+"')"); e.Item.Attributes.Add("style","cursor:hand"); } }private void Toolbar1_ButtonClick(object sender, System.EventArgs e) {
Microsoft.Web.UI.WebControls.ToolbarItem item = (Microsoft.Web.UI.WebControls.ToolbarItem)sender; switch(item.ID) { case "ibtnAdd": func.FillDDL(ddlIndicator,"Select irMID, case when '"+ Session["Language"] +"' = 'Chinese' then irMNameCH else irMNameEN end as irMName from pubIndicatorMain where datediff(day,getdate(),invaliddate)>=0 and datediff(day,getdate(),validdate)<=0 and ScoringShow =1 order by irBigType desc, showsort","irMName","irMID"); func.FillDDL(ddlLevel,"select Item,Remark from pubParameter where Category='productLevel' order by Remark","Remark","Item"); func.FillDDL2(ddlLevel,"ALL","ALL","T"); func.FillDDL(ddlScoringBy,"select Item,Remark from pubParameter where Category='ScoringBy' order by Remark", "Remark", "Item"); tbRemark.Text=""; span_Header.Visible=true; break; case "ibtnRefresh": dgbind(); break; } }private void dgScoreArea_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {
int ID; ID = (int)dgScoreArea.DataKeys[e.Item.ItemIndex]; if (func.ExecuteSQL("Delete pubScoreAreaM where saID=" + ID)==false) { Response.Write("<script language=javascript>alert('Delete formula fail!');</script>"); return; } else { Response.Write("<script language=javascript>alert('Delete OK!');</script>"); dgbind(); return; } }private void dgScoreArea_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e) {
func.DGPageChange(dgScoreArea, e); dgbind(); }private void dgScoreArea_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e) {
string sortitem=e.SortExpression; if (ViewState["sortitem"].ToString()==sortitem) { if (ViewState["sortdir"].ToString()=="asc") { ViewState["sortdir"]="desc"; } else { ViewState["sortdir"]="asc"; } } else ViewState["sortitem"]=sortitem; dgbind(); }private void btnQuery_Click(object sender, System.EventArgs e) {
dgbind(); }private void btnCancel_Click(object sender, System.EventArgs e) {
span_Header.Visible=false; }private void btnSave_Click(object sender, System.EventArgs e) {
DataSet ds = new DataSet(); if (func.IsNumeric(tbWeight.Text)==false || func.IsNumeric(tbshowSort.Text)==false){ Response.Write("<script language=javascript>alert('Error data type or enter null value of Weight and showSort!');</script>"); return; } if (Convert.ToDecimal(tbWeight.Text) <=0 || Convert.ToDecimal(tbWeight.Text)>100){ Response.Write("<script language=javascript>alert('Weight must be above 0 and less than 100!');</script>"); return; } //先判斷資料庫中是否已經存在此資料, 若有則不保存, 否則保存 if (ddlLevel.SelectedValue=="ALL"){ ds= func.GetDataTable("Select count(*) as cs from pubScoreAreaM where irMID=" + ddlIndicator.SelectedValue +" and Level is NULL and ScoringBy='" + ddlScoringBy.SelectedValue +"' and ValidDate ='"+this.tbvalid.Text+"' and InvalidDate ='"+this.tbinvalid.Text+"' "); }else{ ds= func.GetDataTable("Select count(*) as cs from pubScoreAreaM where irMID=" + ddlIndicator.SelectedValue +" and Level= '"+ ddlLevel.SelectedValue +"' and ScoringBy='" + ddlScoringBy.SelectedValue +"' and ValidDate ='"+this.tbvalid.Text+"' and InvalidDate ='"+this.tbinvalid.Text+"'"); } if ((int)ds.Tables[0].Rows[0]["cs"]==0){ if (func.ExecuteSQL("Insert into pubScoreAreaM (irMID, Weight, Level, ScoringBy, showSort, Remark, CreateBy,ValidDate) values (" + ddlIndicator.SelectedValue +","+ tbWeight.Text +"/100.0,case when '"+ ddlLevel.SelectedValue +"'='ALL' then NULL else '"+ ddlLevel.SelectedValue +"' end, '"+ ddlScoringBy.SelectedValue +"',"+tbshowSort.Text+",'"+ tbRemark.Text +"', '"+ Session["LoginID"].ToString() +"','"+this.tbvalid.Text+"')")==false){ Response.Write("<script language=javascript>alert('Save data error!');</script>"); }else{ Response.Write("<script language=javascript>alert('Save OK!');</script>"); tbWeight.Text="0"; tbshowSort.Text="0"; dgbind(); return; } }else{ Response.Write("<script language=javascript>alert('Already exist this data!');</script>"); return; } }private void dgScoreArea_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {
//找到要更新資料行的ID int saID=(int)dgScoreArea.DataKeys[e.Item.ItemIndex]; int irMID=func.GetID("saID=" + saID, "pubScoreAreaM", "irMID");//找出更新之後的值
DropDownList level=(DropDownList)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("DGddlLevel")); DropDownList scoringby=(DropDownList)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("DGddlScoringBy")); TextBox weight=(TextBox)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("DGtbWeight")); TextBox showsort=(TextBox)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("DGtbshowSort")); TextBox ValidDate =(TextBox)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("tbValidDate")); TextBox InvalidDate =(TextBox)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("tbInvalidDate")); TextBox remark=(TextBox)(dgScoreArea.Items[e.Item.ItemIndex].FindControl("DGtbRemark")); //資料校驗, Weight 和 ShowSort 不能為空 if ((func.IsNumeric(weight.Text)==false) || (func.IsNumeric(showsort.Text)==false)){ Response.Write("<script language=javascript>alert('Weight and showSort can not allow NULL!');</script>"); return; }else{ DataSet ds = new DataSet(); //先判斷資料庫中是否已經存在此資料, 若有則不保存, 否則保存 if (level.SelectedValue=="ALL"){ ds= func.GetDataTable("Select count(*) as cs from pubScoreAreaM where irMID=" + irMID +" and Level is NULL and ScoringBy='" + scoringby.SelectedValue +"' and ValidDate ='"+ValidDate.Text+"' and InvalidDate ='"+InvalidDate.Text+"' "); }else{ ds= func.GetDataTable("Select count(*) as cs from pubScoreAreaM where irMID=" + irMID +" and Level= '"+ level.SelectedValue +"' and ScoringBy='" + scoringby.SelectedValue +"' and ValidDate ='"+ValidDate.Text+"' and InvalidDate ='"+InvalidDate.Text+"' "); } if (((int)ds.Tables[0].Rows[0]["cs"]==1) || ((int)ds.Tables[0].Rows[0]["cs"]==0) ) { //更新資料 if (func.ExecuteSQL("update pubScoreAreaM set Weight="+ weight.Text +"/100.0,showSort="+ showsort.Text +", Level=case when '"+ level.SelectedValue +"'='ALL' then NULL else '"+ level.SelectedValue +"' end, ScoringBy='" + scoringby.SelectedValue +"',Remark='"+ remark.Text +"', ModifyBy='" + Session["LoginID"].ToString() +"', ModifyTime=getdate() where saID="+ saID)==false){ Response.Write("<script language=javascript>alert('update data error!');</script>"); return; }else { Response.Write("<script language=javascript>alert('update OK!');</script>"); } }else{ Response.Write("<script language=javascript>alert('Already exist this data!');</script>"); return; } } dgScoreArea.EditItemIndex = -1; dgbind(); dgScoreArea.Columns[dgScoreArea.Columns.Count-1].Visible =true; dgScoreArea.Columns[dgScoreArea.Columns.Count-3].Visible =true; dgScoreArea.Columns[dgScoreArea.Columns.Count-4].Visible=true; }private void dgScoreArea_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {
dgScoreArea.EditItemIndex=e.Item.ItemIndex; dgbind(); dgScoreArea.Columns[dgScoreArea.Columns.Count-1].Visible =false; dgScoreArea.Columns[dgScoreArea.Columns.Count-3].Visible =false; dgScoreArea.Columns[dgScoreArea.Columns.Count-4].Visible=false;}
private void dgScoreArea_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {
dgScoreArea.EditItemIndex=-1; dgbind(); dgScoreArea.Columns[dgScoreArea.Columns.Count-1].Visible =true; dgScoreArea.Columns[dgScoreArea.Columns.Count-3].Visible =true; dgScoreArea.Columns[dgScoreArea.Columns.Count-4].Visible=true; }private void dgScoreArea_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {
if (e.CommandName=="Detail"){ int ID; ID = (int)this.dgScoreArea.DataKeys[e.Item.ItemIndex]; Response.Write("<script language=javascript>var openWnd; openWnd=window.open('pubScoreArea_Set.aspx?saID=" + ID + "&state=Edit','ScoreSet','height=500,width=700,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes',null);" + " openWnd.moveTo((parseInt(screen.width)-700)/2,(parseInt(screen.height)-500)/2);</script>"); } } }}