protected void ibnDelRandom_Click(object sender, ImageClickEventArgs e) { int cnt = UltraWebGrid1.Rows.Count; string dept_ref_id_list = string.Empty; for (int i = 0; i < cnt; i++) { UltraGridRow row = UltraWebGrid1.Rows[i]; TemplatedColumn selchk = (TemplatedColumn)row.Band.Columns.FromKey("selchk"); CheckBox cBox = (CheckBox)((CellItem)selchk.CellItems[row.BandIndex]).FindControl("cBox"); if (cBox.Checked) { dept_ref_id_list += "," + DataTypeUtility.GetValue(row.Cells.FromKey("DEPT_REF_ID").Value); } } if (dept_ref_id_list.Length > 0) { dept_ref_id_list = dept_ref_id_list.Remove(0, 1); } else { dept_ref_id_list = "-1"; } DataTable dtEmp = DataTypeUtility.FilterSortDataTable(DT_DEPTEMP, string.Format(" DEPT_REF_ID IN ({0}) ", dept_ref_id_list)); MicroBSC.Integration.EST.Biz.Biz_Est_Emp_Est_Target_Map bizEstEmpEstTargetMap = new MicroBSC.Integration.EST.Biz.Biz_Est_Emp_Est_Target_Map(); string okMsg = bizEstEmpEstTargetMap.AddEmpEstTargetMap(dtEmp , null , COMP_ID , EST_ID , ESTTERM_REF_ID , ESTTERM_SUB_ID , ConESTTERM_STEP_ID , ConDIRECTION_TYPE , "N" , DateTime.Now , this.gUserInfo.Emp_Ref_ID); if (okMsg.Length == 0) { ltrScript.Text = JSHelper.GetAlertScript("정상 처리 되었습니다.", false); DoBinding_Dept(); } else { ltrScript.Text = JSHelper.GetAlertScript(okMsg); } }
protected void ibnRandom_Click(object sender, ImageClickEventArgs e) { int cnt = UltraWebGrid1.Rows.Count; string dept_ref_id_list = string.Empty; string dept_ref_id = string.Empty; DataTable dtResult = DT_DEPTEMP.Clone(); for (int i = 0; i < cnt; i++) { UltraGridRow row = UltraWebGrid1.Rows[i]; TemplatedColumn selchk = (TemplatedColumn)row.Band.Columns.FromKey("selchk"); CheckBox cBox = (CheckBox)((CellItem)selchk.CellItems[row.BandIndex]).FindControl("cBox"); if (cBox.Checked) { dept_ref_id = DataTypeUtility.GetValue(row.Cells.FromKey("DEPT_REF_ID").Value); dept_ref_id_list += "," + dept_ref_id; string est_tgt_list = string.Empty; DataRow[] rowsTGT = DT_DEPTEMP.Select(string.Format(" EST_TYPE_TGT = 'TGT' AND DEPT_REF_ID = {0} ", dept_ref_id)); string filterDept = " EST_TYPE_EST = 'EST' "; string sort = string.Empty; if (EST_RANGE.Equals("D")) { filterDept += string.Format(" AND DEPT_REF_ID = {0} ", dept_ref_id); } if (EST_METHOD.Equals("R")) { foreach (DataRow rowTgt in rowsTGT) { DataTable dtRandom = DT_DEPTEMP.Copy(); string estList = string.Empty; string tgt_emp_id = DataTypeUtility.GetValue(rowTgt["EMP_REF_ID"]); string tgt_emp_name = DataTypeUtility.GetValue(rowTgt["EMP_NAME"]); string position_class_code = DataTypeUtility.GetValue(rowTgt["POSITION_CLASS_CODE"]); string pos_cls_name = DataTypeUtility.GetValue(rowTgt["POS_CLS_NAME"]); string position_grp_code = DataTypeUtility.GetValue(rowTgt["POSITION_GRP_CODE"]); string pos_grp_name = DataTypeUtility.GetValue(rowTgt["POS_GRP_NAME"]); string position_rank_code = DataTypeUtility.GetValue(rowTgt["POSITION_RANK_CODE"]); string pos_rank_name = DataTypeUtility.GetValue(rowTgt["POS_RNK_NAME"]); string position_duty_code = DataTypeUtility.GetValue(rowTgt["POSITION_DUTY_CODE"]); string pos_dut_name = DataTypeUtility.GetValue(rowTgt["POS_DUT_NAME"]); string position_kind_code = DataTypeUtility.GetValue(rowTgt["POSITION_KIND_CODE"]); string pos_knd_name = DataTypeUtility.GetValue(rowTgt["POS_KND_NAME"]); string filter = filterDept + string.Format(" AND EMP_REF_ID <> {0} ", tgt_emp_id); dtRandom = DataTypeUtility.FilterSortDataTable(dtRandom, filter); int cntRandom = dtRandom.Rows.Count; if (cntRandom > 0) { for (int k = 0; k < EST_MAX_COUNT; k++) { cntRandom = dtRandom.Rows.Count; if (cntRandom <= 0) { break; } Random rnd = new Random(); int rndCnt = rnd.Next(0, cntRandom - 1); rndCnt = rnd.Next(0, rndCnt); //int rndCnt = rnd.Next(1, 1); estList += "," + DataTypeUtility.GetValue(dtRandom.Rows[rndCnt]["EMP_REF_ID"]); DataRow rowRandom = dtRandom.Rows[rndCnt]; rowRandom["TGT_DEPT_ID"] = dept_ref_id; rowRandom["TGT_EMP_ID"] = tgt_emp_id; rowRandom["TGT_EMP_NAME"] = tgt_emp_name; rowRandom["TGT_CLASS_CODE"] = position_class_code; rowRandom["TGT_CLS_NAME"] = pos_cls_name; rowRandom["TGT_GRP_CODE"] = position_grp_code; rowRandom["TGT_GRP_NAME"] = pos_grp_name; rowRandom["TGT_RANK_CODE"] = position_rank_code; rowRandom["TGT_RANK_NAME"] = pos_rank_name; rowRandom["TGT_DUTY_CODE"] = position_duty_code; rowRandom["TGT_DUT_NAME"] = pos_dut_name; rowRandom["TGT_KIND_CODE"] = position_kind_code; rowRandom["TGT_KND_NAME"] = pos_knd_name; dtResult.ImportRow(rowRandom); rowRandom.Delete(); dtRandom.AcceptChanges(); } } if (estList.Length > 0) { estList = estList.Remove(0, 1); } est_tgt_list += ";" + string.Format("{0}={1}", tgt_emp_id, estList); } } else { //dtRandom = DataTypeUtility.FilterSortDataTable(dtRandom, filter, sort); } if (est_tgt_list.Length > 0) { est_tgt_list = est_tgt_list.Remove(0, 1); } row.Cells.FromKey("RND_EST_LIST").Value += est_tgt_list; } } if (dept_ref_id_list.Length > 0) { dept_ref_id_list = dept_ref_id_list.Remove(0, 1); } else { dept_ref_id_list = "-1"; } DataTable dtEmp = DataTypeUtility.FilterSortDataTable(DT_DEPTEMP, string.Format(" DEPT_REF_ID IN ({0}) ", dept_ref_id_list)); MicroBSC.Integration.EST.Biz.Biz_Est_Emp_Est_Target_Map bizEstEmpEstTargetMap = new MicroBSC.Integration.EST.Biz.Biz_Est_Emp_Est_Target_Map(); string okMsg = bizEstEmpEstTargetMap.AddEmpEstTargetMap(dtEmp , dtResult , COMP_ID , EST_ID , ESTTERM_REF_ID , ESTTERM_SUB_ID , ConESTTERM_STEP_ID , ConDIRECTION_TYPE , "N" , DateTime.Now , this.gUserInfo.Emp_Ref_ID); if (okMsg.Length == 0) { ltrScript.Text = JSHelper.GetAlertScript("정상 처리 되었습니다.", false); DoBinding_Dept(); } else { ltrScript.Text = JSHelper.GetAlertScript(okMsg); } }