protected void DELETE_Approver(object sender, EventArgs e) { List<OrgGetDataDemo> list = new List<OrgGetDataDemo>(); //Button btn = sender as Button; ImageButton btn = sender as ImageButton; // อ่านข้อมูลผู้อนุญาตปัจจุบัน Add_Approver = ""; DataTable DT = CurrentData_Approver(); //string Delete_At = btn.Attributes["Approver_Row_Index"].ToString(); string Delete_At = btn.CommandArgument.ToString(); DT.Rows.RemoveAt(GL.CINT(btn.Attributes["Approver_Row_Index"].ToString()) - 1); DataRow DR_Temp; for (int i = 0; i <= DT.Rows.Count - 1; i++) { DR_Temp = DT.Rows[i]; DR_Temp["Row_Index"] = i + 1; OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT.Rows[i]["person_id"].ToString(); data.Approver_Name = DT.Rows[i]["staff_name"].ToString(); if (DT.Rows[i]["approve_date"].ToString() != "") { data.approve_date = DT.Rows[i]["approve_date"].ToString(); } else { data.approve_date = ""; } list.Add(data); } Session["DT_Current"] = DT; Session["list_Current"] = list; BindORG(LeaveNote_ID); }
private List<OrgGetDataDemo> GetData_ORG() { List<OrgGetDataDemo> list = new List<OrgGetDataDemo>(); DataTable DT = new DataTable(); try { if (Add_Approver.ToString() == "Add" && Session["DT_Current"] != null) { DT = CurrentData_Approver(); //DT = (DataTable)Session["DT_Current"]; List<OrgGetDataDemo> list_Current = (List<OrgGetDataDemo>)Session["list_Current"]; // เพิ่ม row //DataTable DT_NewRow; DataRow DR; DR = DT.NewRow(); DT.Rows.Add(DR); //DT.Merge(DT_NewRow); if (DT.Rows.Count > 0) { for (int i = 0; i <= DT.Rows.Count - 1; i++) { OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT.Rows[i]["person_id"].ToString(); data.Approver_Name = DT.Rows[i]["staff_name"].ToString(); if (DT.Rows[i]["approve_date"].ToString() != "") { //data.approve_date = Convert.ToDateTime(DT.Rows[i]["approve_date"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")); data.approve_date = DT.Rows[i]["approve_date"].ToString(); } else { data.approve_date = ""; } list.Add(data); //DR["Row_Index"] = i + 1; //DR["person_id"] = list_Current; //DR["staff_name"] = i + 1; //DR["Date"] = i + 1; } } else { // เพิ่ม 1 row รอไว้ DR = DT.NewRow(); DT.Rows.Add(DR); OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = 1; data.Approver_ID = DT.Rows[0]["person_id"].ToString(); data.Approver_Name = DT.Rows[0]["staff_name"].ToString(); data.approve_date = ""; list.Add(data); } //// เพิ่ม 1 row รอไว้ ////DataRow DR; ////DR = DT.NewRow(); ////DT.Rows.Add(DR); //OrgGetDataDemo data = new OrgGetDataDemo(); //data.Row_Index = list_Current.Count + 1; //data.Approver_ID = ""; //data.Approver_Name = ""; //list.Add(data); Session["DT_Current"] = DT; Session["list_Current"] = list; } else if (Add_Approver.ToString() == "" && Session["DT_Current"] == null) { string aSql = ""; SqlParameter[] param = new SqlParameter[1]; if (_LeaveApproverTableName == ApproverTableName.HRM_LEAVE_HIS_APPROVER) { aSql = "select person_id_approve person_id, approver_level level_name, " + Environment.NewLine; aSql += " isnull(p.prefix_name,'') + isnull(p.name,'') + ' ' + isnull(p.surname,'') staff_name " + Environment.NewLine; aSql += " ,approve_date " + Environment.NewLine; aSql += " from hrm_leave_his_approver ha " + Environment.NewLine; aSql += " inner join vw_CMN_PERSON p on p.id=ha.person_id_approve " + Environment.NewLine; aSql += " inner join CTLT_ORGANIZE org on org.org_serial=p.org_serial " + Environment.NewLine; aSql += " where ha.leave_his_id=@_LEAVE_HIS_ID " + Environment.NewLine; aSql += " and p.per_status=1"; aSql += " order by ha.id"; param[0] = OPM_BL.setParameter("@_LEAVE_HIS_ID", SqlDbType.BigInt, GL.CINT( LeaveNote_ID.ToString())); } else { aSql = "select person_id_approve person_id, approver_level level_name, " + Environment.NewLine; aSql += " isnull(p.prefix_name,'') + isnull(p.name,'') + ' ' + isnull(p.surname,'') staff_name " + Environment.NewLine; aSql += " ,approve_date " + Environment.NewLine; aSql += " from hrm_leave_group_approver ha " + Environment.NewLine; aSql += " inner join vw_CMN_PERSON p on p.id=ha.person_id_approve " + Environment.NewLine; aSql += " where ha.leave_group_id=@_LEAVE_GROUP_ID " + Environment.NewLine; aSql += " and p.per_status=1"; aSql += " order by ha.id"; param[0] = OPM_BL.setParameter("@_LEAVE_GROUP_ID", SqlDbType.BigInt, GL.CINT(LeaveNote_ID.ToString())); } DT = OPM_BL.GetDatatable(aSql, param); //DataTable DT = OPM_BL.GetDatatable(aSql, param); //DT มีข้อมูล ใส่ข้อมูลใน list if (DT.Rows.Count > 0) { for (int i = 0; i <= DT.Rows.Count - 1; i++) { OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT.Rows[i]["person_id"].ToString(); data.Approver_Name = DT.Rows[i]["staff_name"].ToString(); //if (DT.Rows[i]["approve_date"] == null) //{ // data.approve_date = DBNull.Value; //} //else { // data.approve_date = (DateTime)DT.Rows[i]["approve_date"]; //} if (Convert.IsDBNull(DT.Rows[i]["approve_date"]) == false) { data.approve_date = DT.Rows[i]["approve_date"].ToString(); //data.approve_date = Convert.ToDateTime(DT.Rows[i]["approve_date"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")); } else { data.approve_date = ""; } list.Add(data); } } else { DT = DT_SetDefault_Approver(); if (DT.Rows.Count > 0) { for (int i = 0; i <= DT.Rows.Count - 1; i++) { OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT.Rows[i]["person_id"].ToString(); data.Approver_Name = DT.Rows[i]["staff_name"].ToString(); if (DT.Rows[i]["approve_date"].ToString() != "") { data.approve_date = DT.Rows[i]["approve_date"].ToString(); } else { data.approve_date = ""; } list.Add(data); } } else { // เพิ่ม 1 row รอไว้ DataRow DR; DR = DT.NewRow(); DT.Rows.Add(DR); OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = 1; data.Approver_ID = DT.Rows[0]["person_id"].ToString(); data.Approver_Name = DT.Rows[0]["staff_name"].ToString(); data.approve_date = ""; list.Add(data); } } Session["DT_Current"] = DT; Session["list_Current"] = list; } else { DT = (DataTable)Session["DT_Current"]; list = (List<OrgGetDataDemo>)Session["list_Current"]; } } catch (Exception ex) { } //Session["DT_Current"] = DT; //Session["list_Current"] = list; return list; //string SQL = " select ORG_SERIAL,ORG_NAME,ORG_ABBR,ORDER_SEQ_PDM from vw_SMM_ORG_LEVEL2 order by ORDER_SEQ_PDM "; //SqlDataAdapter DA = new SqlDataAdapter(SQL, OPM_BL.DefaultConnectionString); //DataTable DT = new DataTable(); //DA.Fill(DT); //List<OrgGetDataDemo> list = new List<OrgGetDataDemo>(); //for (int i = 0; i <= DT.Rows.Count - 1; i++) //{ // OrgGetDataDemo data = new OrgGetDataDemo(); // data.index = i; // data.ORG_SERIAL = DT.Rows[i]["ORG_SERIAL"].ToString(); // data.ORDER_SEQ_PDM = DT.Rows[i]["ORDER_SEQ_PDM"].ToString(); // data.ORG_ABBR = DT.Rows[i]["ORG_ABBR"].ToString(); // data.ORG_NAME = DT.Rows[i]["ORG_NAME"].ToString(); // list.Add(data); //} //return list; }
// เรียงลำดับหน่วยงาน protected void ASPxTree_ORG_ProcessDragNode(object sender, TreeListNodeDragEventArgs e) { // child คือรายการที่กดย้าย // Parent รายการที่ child ย้ายเพื่อต่อท้ายรายการ List<OrgGetDataDemo> list = new List<OrgGetDataDemo>(); OrgGetDataDemo child = e.Node.DataItem as OrgGetDataDemo; OrgGetDataDemo newParent = e.NewParentNode.DataItem as OrgGetDataDemo; // หารายการ Datatable ผู้ประเมินปัจจุบัน Row_Index string Child_Row_Index = ""; string Child_person_id = ""; string newParent_Row_Index = ""; string newParent_person_id = ""; Add_Approver = ""; DataTable DT = CurrentData_Approver(); // หา child ของรายการผู้ประเมิน DT.DefaultView.RowFilter = " Row_Index='" + child.Row_Index + "'"; Child_Row_Index = DT.DefaultView[0]["Row_Index"].ToString(); Child_person_id = DT.DefaultView[0]["person_id"].ToString(); // หา parent ของรายการผู้ประเมิน DT.DefaultView.RowFilter = " Row_Index='" + newParent.Row_Index + "'"; newParent_Row_Index = DT.DefaultView[0]["Row_Index"].ToString(); newParent_person_id = DT.DefaultView[0]["person_id"].ToString(); //Reorder_Approver(Child_person_id, newParent_person_id, newParent_Row_Index); DataTable DT_Temp; //DT.DefaultView.RowFilter="0=1"; DT_Temp = DT.DefaultView.ToTable(); DataRow DR = null; //DR = DT.Rows[child.Row_Index -1]; //DR["Row_Index"] = GL.CDBL(newParent_Row_Index) + (0.5); for (int i = 0; i <= DT.Rows.Count - 1; i++) { DR = DT.Rows[i]; if (GL.CINT(DT.Rows[i]["Row_Index"]) == GL.CINT(child.Row_Index)) { DR["Row_Index"] = GL.CDBL(newParent_Row_Index) + (0.5); } } DT.DefaultView.RowFilter = null; DT.DefaultView.Sort = "Row_Index asc"; DT_Temp = DT.DefaultView.ToTable(); // เรียงลำดับผู้ประเมินใหม่ //DataTable DT_Temp; DT_Temp = DT.DefaultView.ToTable(); //DT_Temp.DefaultView.Sort = ""; //DT_Temp = null; //DT_Temp = DT.DefaultView.ToTable(); //DT_Temp = DT_Temp.DefaultView.ToTable(); DataRow DR_Temp; for (int i = 0; i <= DT_Temp.Rows.Count - 1; i++) { DR_Temp = DT_Temp.Rows[i]; DR_Temp["Row_Index"] = i + 1; OrgGetDataDemo data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT_Temp.Rows[i]["person_id"].ToString(); data.Approver_Name = DT_Temp.Rows[i]["staff_name"].ToString(); if (DT_Temp.Rows[i]["approve_date"].ToString() != "") { data.approve_date = DT_Temp.Rows[i]["approve_date"].ToString(); } else { data.approve_date = ""; } list.Add(data); } Session["DT_Current"] = DT_Temp; Session["list_Current"] = list; //LogFileEng.SaveActionTransLog("HRM_UT0502", "Swap Approver", "จัดลำดับผู้อนุญาต", "CTLT_ORGANIZE", "เลื่อนหน่วยงาน ORG_SERIAL='" + child.ORG_SERIAL + " อยู่ภายใต้ ORG_SERIAL='" + newParent.ORG_SERIAL + "'", "", Request); BindORG(LeaveNote_ID); e.Handled = true; }
private List<OrgGetDataDemo> GetData_Current() { List<OrgGetDataDemo> list = new List<OrgGetDataDemo>(); try { DataTable DT = CurrentData_Approver(); int Row_Current = GL.CINT(DT.Rows.Count); //DT มีข้อมูล ใส่ข้อมูลใน list //DataRow DR; //DR = DT.NewRow(); //DT.Rows.Add(DR); //OrgGetDataDemo data = new OrgGetDataDemo(); //data.Row_Index = DT.Rows.Count + 1; //data.Approver_ID = DT.Rows[0]["person_id"].ToString(); //data.Approver_Name = DT.Rows[0]["staff_name"].ToString(); //list.Add(data); DataRow DR; OrgGetDataDemo data = new OrgGetDataDemo(); if (DT.Rows.Count > 0) { //เพิ่มแถวใหม่ DR = DT.NewRow(); //DR["Row_Index"] = Row_Current + 1; //DR["person_id"] = -1; //DR["staff_name"] = ""; DT.Rows.Add(DR); for (int i = 0; i <= DT.Rows.Count - 1; i++) { data = new OrgGetDataDemo(); data.Row_Index = i + 1; data.Approver_ID = DT.Rows[i]["person_id"].ToString(); data.Approver_Name = DT.Rows[i]["staff_name"].ToString(); list.Add(data); } } else { // เพิ่ม 1 row รอไว้ data = new OrgGetDataDemo(); DR = DT.NewRow(); DT.Rows.Add(DR); data.Row_Index = 1; data.Approver_ID = DT.Rows[0]["person_id"].ToString(); data.Approver_Name = DT.Rows[0]["staff_name"].ToString(); list.Add(data); } } catch (Exception ex) { } return list; }