protected void SavePPL_Click(object sender, EventArgs e) { string poscode = poscodeLabel.Text; string Name = NameLabel.Text; string posname = posnameLabel.Text; string unitname = unitnameLabel.Text; string company_id = companyLabel.Text; string MOBILE = TelLabel.Text; string group_in = GroupIDINLabel.Text; string unitcode = unitcodeLabel.Text; string code = codeLabel.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 = "[code] = '" + code + "'"; DataTable dtOutput = dt_tempChk.DefaultView.ToTable(); if (dtOutput.Rows.Count > 0) { SavePPL.Enabled = false; NoResult.Visible = true; errorlabel.Text = "มีชื่อในระบบ"; resultppl.Visible = false; return; } int index = cl.Items.Count; string loginName = Session["ID"].ToString(); for (int i = 0; i < index; i++) { string id = cl.Items[i].Value; if (cl.Items[i].Selected) { cc2.InsertPTTBService(id, code); } } string result = cc2.InsertPTTBPPL(poscode, MOBILE, loginName, unitcode, code); if (result != "0") { cc2.UpdatePTTBPPL(code, MOBILE, loginName); } grpPanel.Visible = false; AddPPLPanel.Visible = false; BindPPLDetail(); }
protected void UpdatePPL_Click(object sender, EventArgs e) { string poscode = poscodeLabel.Text; string Name = NameLabel.Text; string posname = posnameLabel.Text; string unitname = unitnameLabel.Text; string company_id = companyLabel.Text; string MOBILE = TelLabel.Text; string group_in = GroupIDINLabel.Text; string unicode = unitcodeLabel.Text; string code = codeLabel.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; } int index = cl.Items.Count; string loginName = Session["ID"].ToString(); for (int i = 0; i < index; i++) { string id = cl.Items[i].Value; if (group_in.Contains(id) && !cl.Items[i].Selected) { cc2.DeletePTTBPPL(id, "100", code); } else if (!group_in.Contains(id) && cl.Items[i].Selected) { cc2.InsertPTTBService(id, code); } } string result = cc2.InsertPTTBPPL(poscode, MOBILE, loginName, unicode, code); if (result != "0") { cc2.UpdatePTTBPPL(code, MOBILE, loginName); } grpPanel.Visible = false; AddPPLPanel.Visible = false; BindPPLDetail(); }