Exemplo n.º 1
0
    protected void ibnRandom_Click(object sender, ImageClickEventArgs e)
    {
        Biz_Mul_Est_Target_Pool bizMulEstTargetPool = new Biz_Mul_Est_Target_Pool();

        DataTable DT_dept_ref_id = UltraGridUtility.GetDataSetByCheckedBox(UltraWebGrid1, new string[] { "DEPT_REF_ID" }, "selchk", "cBox").Tables[0];

        StringBuilder dept_ref_id_list = new StringBuilder();


        //전체 직원 정보, 평가, 피평가 포함된 테이블 스키마 복사
        DataTable dtResult = DT_DEPTEMP.Clone();



        for (int i = 0; i < DT_dept_ref_id.Rows.Count; i++)
        {
            string dept_ref_id = DT_dept_ref_id.Rows[i]["DEPT_REF_ID"].ToString();
            if (dept_ref_id_list.Length > 0)
            {
                dept_ref_id_list.Append(", ");
            }
            dept_ref_id_list.Append(dept_ref_id);
        }


        //해당 부서들의 피평가자들 리스트
        DataTable DT_tgt_emp_id = DataTypeUtility.FilterSortDataTable(DT_DEPTEMP, string.Format(" EST_TYPE_TGT = 'TGT' AND DEPT_REF_ID IN ({0}) ", dept_ref_id_list.ToString()));



        //피평가자들의 모든 평가자 리스트
        DataTable DT_est_emp_id = bizMulEstTargetPool.Get_BaseEstEmpList(COMP_ID, EST_ID, ESTTERM_REF_ID, ESTTERM_SUB_ID, DT_tgt_emp_id);



        DT_est_emp_id.Columns.Add("TGT_DEPT_ID");
        DT_est_emp_id.Columns.Add("TGT_EMP_NAME");
        DT_est_emp_id.Columns.Add("TGT_CLASS_CODE");
        DT_est_emp_id.Columns.Add("TGT_CLS_NAME");
        DT_est_emp_id.Columns.Add("TGT_GRP_CODE");
        DT_est_emp_id.Columns.Add("TGT_GRP_NAME");
        DT_est_emp_id.Columns.Add("TGT_RANK_CODE");
        DT_est_emp_id.Columns.Add("TGT_RANK_NAME");
        DT_est_emp_id.Columns.Add("TGT_DUTY_CODE");
        DT_est_emp_id.Columns.Add("TGT_DUT_NAME");
        DT_est_emp_id.Columns.Add("TGT_KIND_CODE");
        DT_est_emp_id.Columns.Add("TGT_KND_NAME");

        StringBuilder est_tgt_list = new StringBuilder();

        for (int i = 0; i < DT_dept_ref_id.Rows.Count; i++)
        {
            string    c_dept_ref_id   = DT_dept_ref_id.Rows[i]["DEPT_REF_ID"].ToString();
            DataTable c_DT_tgt_emp_id = DataTypeUtility.FilterSortDataTable(DT_tgt_emp_id, string.Format("DEPT_REF_ID={0}", c_dept_ref_id));

            //선택된 부서의 피평가자 수만큼 루프
            for (int j = 0; j < c_DT_tgt_emp_id.Rows.Count; j++)
            {
                string tgt_dept_id         = c_DT_tgt_emp_id.Rows[j]["DEPT_REF_ID"].ToString();
                string tgt_emp_id          = c_DT_tgt_emp_id.Rows[j]["EMP_REF_ID"].ToString();
                string tgt_emp_name        = c_DT_tgt_emp_id.Rows[j]["EMP_NAME"].ToString();
                string position_class_code = c_DT_tgt_emp_id.Rows[j]["POSITION_CLASS_CODE"].ToString();
                string pos_cls_name        = c_DT_tgt_emp_id.Rows[j]["POS_CLS_NAME"].ToString();
                string position_grp_code   = c_DT_tgt_emp_id.Rows[j]["POSITION_GRP_CODE"].ToString();
                string pos_grp_name        = c_DT_tgt_emp_id.Rows[j]["POS_GRP_NAME"].ToString();
                string position_rank_code  = c_DT_tgt_emp_id.Rows[j]["POSITION_RANK_CODE"].ToString();
                string pos_rank_name       = c_DT_tgt_emp_id.Rows[j]["POS_RNK_NAME"].ToString();
                string position_duty_code  = c_DT_tgt_emp_id.Rows[j]["POSITION_DUTY_CODE"].ToString();
                string pos_dut_name        = c_DT_tgt_emp_id.Rows[j]["POS_DUT_NAME"].ToString();
                string position_kind_code  = c_DT_tgt_emp_id.Rows[j]["POSITION_KIND_CODE"].ToString();
                string pos_knd_name        = c_DT_tgt_emp_id.Rows[j]["POS_KND_NAME"].ToString();



                //해당 피평가자에 대한 평가자 리스트 추출
                string    filter_Extract_EstEmp = string.Format("TGT_EMP_ID={0} AND EST_EMP_ID <> {0}", tgt_emp_id);
                DataTable dtRandom = DataTypeUtility.FilterSortDataTable(DT_est_emp_id, filter_Extract_EstEmp);



                StringBuilder est_emp_list = new StringBuilder();

                if (dtRandom.Rows.Count > 0)
                {
                    for (int k = 0; k < EST_MAX_COUNT; k++)
                    {
                        int cntRandom = dtRandom.Rows.Count;


                        //행 감소를 체크
                        if (cntRandom == 0)
                        {
                            break;
                        }


                        //랜덤 인덱스
                        Random rnd    = new Random();
                        int    rndNum = rnd.Next();
                        int    rndIdx = rndNum % cntRandom;



                        //평가자 EMP_REF_ID
                        if (est_emp_list.Length > 0)
                        {
                            est_emp_list.Append(", ");
                        }
                        est_emp_list.Append(j.ToString() + "-" + dtRandom.Rows[rndIdx]["EMP_REF_ID"].ToString());



                        DataRow rowRandom = dtRandom.Rows[rndIdx];

                        rowRandom["TGT_DEPT_ID"]    = tgt_dept_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 (est_emp_list.Length > 0)
                    {
                        if (est_tgt_list.Length > 0)
                        {
                            est_tgt_list.Append(";");
                        }
                        est_tgt_list.Append(string.Format("{2}. {0}={1}", tgt_emp_id, est_emp_list.ToString(), i.ToString()));
                    }
                }
            }
        }

        if (dept_ref_id_list.Length == 0)
        {
            dept_ref_id_list.Append("-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.AddEmpEstTargetMapFromPool(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("실패하였습니다.", false);
        }
    }
Exemplo n.º 2
0
    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);
        }
    }