protected void SavePPL_Click(object sender, EventArgs e) { // string EmployeeID = EmployeeIDLabel.Text; string Name = NameLabel.Text; string posname = posnameLabel.Text; // string unitname = unitnameLabel.Text; string company_id = unitnameList.SelectedValue; string MOBILE = TelLabel.Text; string group_in = GroupIDINLabel.Text; OracleQuery cc = new OracleQuery(); OracleQuery2 cc2 = new OracleQuery2(); var s = cl.Items.Cast <ListItem>() .Where(item => item.Selected) .Aggregate("", (current, item) => current + (item.Text + ", ")); string hh = s.TrimEnd(new[] { ',', ' ' }); if (hh == "") { NoResult.Visible = true; errorlabel.Text = "กรุณาเลือกกลุ่มอย่างน้อย 1 กลุ่ม"; return; } DataTable dt_tempChk = ViewState["ALLPPL"] as DataTable; //dt_tempChk.DefaultView.RowFilter = "[EMPLOYEE_ID] = '" + EmployeeID + "'"; //DataTable dtOutput = dt_tempChk.DefaultView.ToTable(); //if (dtOutput.Rows.Count > 0) //{ // SavePPL.Enabled = false; // NoResult.Visible = true; // errorlabel.Text = "มีชื่อในระบบ"; // resultppl.Visible = false; // return; //} DataView dv = dt_tempChk.DefaultView; dv.Sort = "EMPLOYEE_ID desc"; DataTable sortedDT = dv.ToTable(); string EmployeeID = (Convert.ToDouble(sortedDT.Rows[0]["EMPLOYEE_ID"].ToString()) + 1).ToString(); int index = cl.Items.Count; string loginName = Session["ID"].ToString(); cc2.InsertGCPPL(EmployeeID, Name, company_id, MOBILE, posname, loginName); for (int i = 0; i < index; i++) { string id = cl.Items[i].Value; if (cl.Items[i].Selected) { cc2.InsertGCService(id, EmployeeID, company_id); } } grpPanel.Visible = false; AddPPLPanel.Visible = false; BindPPLDetail(); }
protected void UpdatePPL_Click(object sender, EventArgs e) { string EmployeeID = EmployeeIDLabel.Text; string Name = NameLabel.Text; string posname = posnameLabel.Text; // string unitname = unitnameLabel.Text; string company_id = unitnameList.SelectedValue; string MOBILE = TelLabel.Text; string group_in = GroupIDINLabel.Text; OracleQuery cc = new OracleQuery(); OracleQuery2 cc2 = new OracleQuery2(); var s = cl.Items.Cast <ListItem>() .Where(item => item.Selected) .Aggregate("", (current, item) => current + (item.Text + ", ")); string hh = s.TrimEnd(new[] { ',', ' ' }); if (hh == "") { NoResult.Visible = true; errorlabel.Text = "กรุณาเลือกกลุ่มอย่างน้อย 1 กลุ่ม"; return; } string longinName = Session["ID"].ToString(); int index = cl.Items.Count; for (int i = 0; i < index; i++) { string id = cl.Items[i].Value; if (group_in.Contains(id) && !cl.Items[i].Selected) { cc2.DeleteGCPPL(id, "300", EmployeeID, company_id); } else if (!group_in.Contains(id) && cl.Items[i].Selected) { cc2.InsertGCService(id, EmployeeID, company_id); } } cc2.updateGCPPL(EmployeeID, Name, company_id, MOBILE, posname, longinName); grpPanel.Visible = false; AddPPLPanel.Visible = false; BindPPLDetail(); }