<%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> //此頁面限制管理員填寫,助理不可填寫。 string conStr = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString; string EmpNo = ""; DataSet ds = new DataSet(); public int id; public void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string uID = Request["UniqueID"].ToString(); //string uID = "21"; id = int.Parse(uID); hdID.Value = id.ToString(); using (SqlConnection sqlConn = new SqlConnection(conStr)) { sqlConn.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = sqlConn; comm.CommandText = "SELECT DeptCode,Convert(nvarchar(10),Date,120) as Date FROM NFC_REP_N06_DinnerBasic WHERE UniqueID=" + id; SqlDataReader dr = comm.ExecuteReader(); while (dr.Read()) { lblSetDept.Text = dr[0].ToString(); lblDate.Text = dr[1].ToString(); } sqlConn.Close(); } SqlDataSource2.SelectCommand = "SELECT RType+RExType AS RChType,Ramount,RCode,RType,RExType from NFC_REP_N06_DinnerDetail WHERE PUniqueID= " + id; rpEdit.DataBind(); } } protected void btnSave_Click(object sender, EventArgs e) { id = int.Parse(hdID.Value); using (SqlConnection sqlConn = new SqlConnection(conStr)) { sqlConn.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = sqlConn; comm.CommandText = "SELECT CookieClass FROM adm_awprojectconfig WHERE projectid='N06'"; try { string cookclass = (string)comm.ExecuteScalar(); EmpNo = Request.Cookies[cookclass]["AutoFlow_AccountID"].ToString(); } catch { EmpNo = ""; } if (EmpNo == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "errlog", "alert('請先登錄系統!')", true); } else { comm.CommandText = " UPDATE NFC_REP_N06_DinnerBasic SET AdmUpdateTime=getdate(),AdmID='" + EmpNo + "',Remark='' WHERE UniqueID=" + id; comm.ExecuteNonQuery(); bool isNot; foreach (RepeaterItem ri in rpEdit.Items) { TextBox tbSum = ri.FindControl("ed1") as TextBox; TextBox tbCode = ri.FindControl("ed2") as TextBox; TextBox tbType = ri.FindControl("ed3") as TextBox; TextBox tbExt = ri.FindControl("ed4") as TextBox; int sum; isNot = int.TryParse(tbSum.Text, out sum); comm.CommandText = "UPDATE NFC_REP_N06_DinnerDetail SET Ramount= " + sum + " WHERE RCode='" + tbCode.Text.Trim() + "' and RExType ='" + tbExt.Text.Trim() + "' AND PUniqueID=" + id; comm.ExecuteNonQuery(); } Response.Write("alter('更新成功')"); string msg = "window.opener.location.reload();window.close()"; Page.ClientScript.RegisterStartupScript(this.GetType(), "suclog", msg, true); } sqlConn.Close(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <style type="text/css"> .bt { font-style: normal; font-weight: normal; font-size: 11px; font-family: Arial; padding: top 10px right 10px bottom 10px left 10px; margin: top 10px right 10px bottom 10px left 10px; } hr { 100%; background-color: #bfbfbf; } ddd { height: 12px; 44px; } </style> <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script> <script type="text/javascript"> function checkNum(e) { var keynum var keychar var numcheck if (window.event) { keynum = e.keyCode; } else if (e.which) { keynum = e.which; } keychar = String.fromCharCode(keynum); numcheck = /\d/; return numcheck.test(keychar); } </script> </head> <body> <form id="formSubmit" runat="server" class="bt"> <table class="bt"> <tr> <td>設置部門:<asp:Label ID="lblSetDept" runat="server" class="bt"> </asp:Label> </td> </tr> <tr> <td>班別日期: <asp:Label ID="lblDate" runat="server" Width="80px" class="bt"></asp:Label> </td> </tr> </table> <div id="divEdit" runat="server"> <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:SqlConn %>" runat="server"></asp:SqlDataSource> <asp:Repeater ID="rpEdit" DataSourceID="SqlDataSource2" runat="server"> <HeaderTemplate> <table class="bt"> </HeaderTemplate> <ItemTemplate> <tr> <td> <asp:Label ID="lbl0" Text=' <%#Eval("RChType") %>' runat="server" class="tb"></asp:Label>: </td> <td> <asp:TextBox ID="ed1" Text='<%#Eval("Ramount") %>' runat="server" class="bt" Width="44px" onkeypress="return checkNum(event);" onpaste="return false;"></asp:TextBox> <asp:TextBox ID="ed2" Text='<%#Eval("RCode") %>' runat="server" Visible="false"></asp:TextBox> <asp:TextBox ID="ed3" Text='<%#Eval("rtype") %>' runat="server" Visible="false"></asp:TextBox> <asp:TextBox ID="ed4" Text='<%#Eval("RexType") %>' runat="server" Visible="false"></asp:TextBox> </td> </tr> </ItemTemplate> <FooterTemplate></table></FooterTemplate> </asp:Repeater> <asp:Button ID="btnSave" runat="server" Text="保存" OnClick="btnSave_Click" CssClass="bt" /> <input id="btnCancel" class="bt" onclick="window.close();" type="button" value="取消" /> <asp:HiddenField ID="hdID" runat="server" /> </div> </form> </body> </html>