/// <summary>
        /// 提交考核数据
        /// </summary>
        /// <param name="GuidID"></param>
        /// <param name="workload"></param>
        /// <param name="score"></param>
        /// <returns></returns>
        public bool SubmitKaoHeData(String GuidID, int workload, int score)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA          da1       = new Tb_TaskDA();
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("GuidID", GuidID));
                Dictionary <String, object> dic1 = new Dictionary <string, object>();

                dic1["Status"]       = "3";
                dic1["CheckDate"]    = DateTime.Now;
                dic1["Score"]        = score;
                dic1["LastWorkLoad"] = workload;

                da1.EditData(condition, dic1);
                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 用户接单
        /// </summary>
        /// <param name="guidid"></param>
        /// <returns></returns>
        public bool ReceiveTask(String guidid)
        {
            bool succ = false;

            JConnect.GetConnect().BeginTrans();
            try
            {
                //1--更改工单中的数据
                Dictionary <String, object> dic1 = new Dictionary <string, object>();
                dic1["ExecuteMan"] = FrameLib.UserID;
                dic1["Status"]     = "1";
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("GuidID", guidid));
                Tb_TaskDA da1 = new Tb_TaskDA();
                da1.EditData(condition, dic1);


                //如操作成功,则插入派工单的日志
                //2--创建工单日志
                (new Tb_Task_LogBU()).NewLog(guidid, FrameLib.UserID + "承接工单", "", "0", null);

                JConnect.GetConnect().CommitTrans();
                succ = true;
            }
            catch (Exception err)
            {
                WebFrame.Util.JTool.WriteErrorLog(err.ToString());
                JConnect.GetConnect().RollBackTrans();
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 退单
        /// </summary>
        /// <param name="GuidID"></param>
        /// <returns></returns>
        public bool TuiTaskTask(String GuidID)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA                   da1       = new Tb_TaskDA();
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <String, object> dic1      = new Dictionary <string, object>();
                condition.Add(new SearchField("GuidID", GuidID));

                //1--退单
                dic1["Status"]         = "0";
                dic1["ExecuteManID"]   = "";
                dic1["ExecuteManName"] = "";
                dic1["begDate"]        = DBNull.Value;
                dic1["endDate"]        = DBNull.Value;
                da1.EditData(condition, dic1);

                //2--创建日志
                (new Tb_Task_LogBU()).NewLog(GuidID, "退单", "");

                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 提交一个计划
        /// 根据taskid,得到项目的id,设置计划的审核者和状态
        /// </summary>
        /// <param name="GuidID">项目的GuidID</param>
        /// <param name="userid">提交的用户ID</param>
        /// <returns></returns>
        public bool SubmitTask(String GuidID)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA                   da1       = new Tb_TaskDA();
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <String, object> dic1      = new Dictionary <string, object>();
                condition.Add(new SearchField("GuidID", GuidID));

                //1--提交工单审核
                dic1["Status"]    = "2";
                dic1["CheckDate"] = DateTime.Now;
                da1.EditData(condition, dic1);

                //2--创建日志
                (new Tb_Task_LogBU()).NewLog(GuidID, "提交审核", "");

                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 取消一个工单
        /// </summary>
        /// <param name="GuidID"></param>
        /// <returns></returns>
        public bool CancelTask(String GuidID)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA                   da1       = new Tb_TaskDA();
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <String, object> dic1      = new Dictionary <string, object>();
                condition.Add(new SearchField("GuidID", GuidID));

                //1--取消工单
                dic1["Status"] = "9";
                da1.EditData(condition, dic1);

                //2--创建日志
                (new Tb_Task_LogBU()).NewLog(GuidID, "取消工单", "");

                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 删除派工单,同时删除其中包含的附件
        /// 上传派工单的日志和日志包含的附件
        /// </summary>
        /// <param name="guidid"></param>
        /// <returns></returns>
        public bool DeleteData(String guidid)
        {
            bool succ = false;

            JConnect.GetConnect().BeginTrans();
            try
            {
                //1--删除派工单
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("Guidid", guidid));
                Tb_TaskDA da1 = new Tb_TaskDA();
                DataRow   dr1 = da1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    //删除相关附件
                    String filename1 = dr1["RelaFile"].ToString();
                    if (String.IsNullOrEmpty(filename1) == false)
                    {
                        filename1 = System.Web.HttpContext.Current.Server.MapPath(filename1);
                        if (File.Exists(filename1))
                        {
                            File.Delete(filename1);
                        }
                    }

                    //删除数据
                    da1.DeleteData(condition);
                }

                //2--删除派工单的日志
                condition.Clear();
                condition.Add(new SearchField("parentGuid", guidid));
                Tb_Task_LogDA da2 = new Tb_Task_LogDA();
                DataTable     dt1 = da2.GetListData(condition, -1, -1, "", "*");
                foreach (DataRow dr0 in dt1.Rows)
                {
                    String filename1 = dr0["RelateFile"].ToString();
                    if (String.IsNullOrEmpty(filename1) == false)
                    {
                        filename1 = System.Web.HttpContext.Current.Server.MapPath(filename1);
                        if (File.Exists(filename1))
                        {
                            File.Delete(filename1);
                        }
                    }
                }
                da2.DeleteData(condition);

                JConnect.GetConnect().CommitTrans();
                succ = true;
            }
            catch (Exception err)
            {
                JConnect.GetConnect().RollBackTrans();
                WebFrame.Util.JTool.WriteErrorLog(err.ToString());
            }
            return(succ);
        }
        /// <summary>
        /// 得到满足条件的第一条数据
        /// </summary>
        /// <param name="guidid"></param>
        /// <returns></returns>
        public DataRow GetFirstDataRow(String guidid, String fields)
        {
            Tb_TaskDA          da1       = new Tb_TaskDA();
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("GuidID", guidid));
            DataRow dr1 = da1.GetFirstDataRow(condition, fields);

            return(dr1);
        }
 /// <summary>
 /// 功能:执行普通的SQL语句
 /// </summary>
 public void ExcuteSql(String sql)
 {
     try
     {
         Tb_TaskDA da1 = new Tb_TaskDA();
         da1.ExcuteSql(sql);
     }
     catch (Exception err)
     {
         this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
     }
 }
 /// <summary>
 /// 根据条件删除数据
 /// </summary>
 /// <param name="condition">删除数据条件</param>
 public void DeleteData(List <SearchField> condition)
 {
     try
     {
         Tb_TaskDA da1 = new Tb_TaskDA();
         da1.DeleteData(condition);
         this.executeResultCount = da1.ExecuteResultCount;
     }
     catch (Exception err)
     {
         this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
     }
 }
 /// <summary>
 /// 根据条件,修改一个数据
 /// </summary>
 /// <param name="condition">修改数据的条件</param>
 /// <param name="data1">新的数据</param>
 public void EditData(List <SearchField> condition, Dictionary <String, object> data1)
 {
     try
     {
         Tb_TaskDA da1 = new Tb_TaskDA();
         da1.EditData(condition, data1);
         this.executeResultCount = da1.ExecuteResultCount;
     }
     catch (Exception err)
     {
         this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
     }
 }
 /// <summary>
 /// 新增一条数据
 /// </summary>
 /// <param name="data1">Dictionary数据</param>
 public void NewData(Dictionary <String, object> data1)
 {
     try
     {
         Tb_TaskDA da1 = new Tb_TaskDA();
         da1.NewData(data1);
         this.executeResultCount = da1.ExecuteResultCount;
     }
     catch (Exception err)
     {
         this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
         throw err;
     }
 }
        /// <summary>
        /// 判断是否有符合条件的数据
        /// </summary>
        ///<param name="condition">查询条件</param>
        /// <returns></returns>
        public bool HasData(List <SearchField> condition)
        {
            bool result = false;

            try
            {
                Tb_TaskDA da1 = new Tb_TaskDA();
                result = da1.HasData(condition);
            }
            catch (Exception err)
            {
                this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
            }
            return(result);
        }
        /// <summary>
        /// 得到满足条件的第一行数据(返回值为Dictionary)
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <param name="Fields">数据字段</param>
        /// <returns>Dictionary字典</returns>
        public Dictionary <string, object> GetFirstDictionary(List <SearchField> condition, params String[] Fields)
        {
            Dictionary <string, object> data1 = null;

            try
            {
                Tb_TaskDA da1 = new Tb_TaskDA();
                data1 = da1.GetFirstDictionary(condition, Fields);
                this.executeResultCount = da1.ExecuteResultCount;
            }
            catch (Exception err)
            {
                this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
            }
            return(data1);
        }
        /// <summary>
        /// Complete or not Complete Task
        /// </summary>
        /// <param name="TaskID"></param>
        /// <param name="Flag"></param>
        /// <returns></returns>
        public bool CompleteTask(String GuidID, int Flag, String Remark)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA                   da1       = new Tb_TaskDA();
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <String, object> dic1      = new Dictionary <string, object>();
                condition.Add(new SearchField("GuidID", GuidID));

                String title = "工单完成";
                //1--退单
                if (Flag == 1)
                {
                    dic1["Status"]     = "3";
                    dic1["finishDate"] = DateTime.Now; //完成审核时间
                }
                else if (Flag == 2)                    //退回重改
                {
                    dic1["Status"] = "1";
                    title          = "工单退回重改,退回说明:" + Remark;
                }
                else
                {
                    dic1["Status"]     = "4";
                    dic1["finishDate"] = DateTime.Now;  //完成审核时间
                    title = "工单失败";
                }
                da1.EditData(condition, dic1);

                //2--创建日志
                (new Tb_Task_LogBU()).NewLog(GuidID, "审核工单", title);

                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        /// <summary>
        /// 根据条件得到列表数据
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <param name="PageSize">页大小</param>
        /// <param name="CurPage">当前页</param>
        /// <param name="Fields">数据字段</param>
        /// <param name="orderBy">排序表达式</param>
        /// <param name="TotalRow">数据总行数</param>
        /// <param name="Fields">要显示的字段</param>
        /// <returns>列表数据</returns>
        public DataTable GetListData(List <SearchField> condition,
                                     int PageSize, int CurPage, String orderBy,
                                     out int TotalRow, params String[] Fields)
        {
            TotalRow = 0;
            DataTable dt1 = null;

            try
            {
                Tb_TaskDA da1 = new Tb_TaskDA();
                dt1 = da1.GetListData(condition, PageSize, CurPage, orderBy, out TotalRow, Fields);
                this.executeResultCount = da1.ExecuteResultCount;
                return(dt1);
            }
            catch (Exception err)
            {
                this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
            }
            return(dt1);
        }
        /// <summary>
        /// 完成接单的操作
        /// </summary>
        /// <param name="TaskID"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public bool JieDanTask(String GuidIDS, String domanid, String domanName,
                               String endDate)
        {
            bool succ = false;

            try
            {
                Tb_TaskDA                   da1       = new Tb_TaskDA();
                String[]                    arrs      = GuidIDS.Split(',');
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <String, object> dic1      = new Dictionary <string, object>();
                foreach (String m in arrs)
                {
                    condition.Clear();
                    condition.Add(new SearchField("GuidID", m));

                    //1--接单
                    dic1.Clear();
                    dic1["Status"]         = "1";
                    dic1["ExecuteManID"]   = domanid;
                    dic1["ExecuteManName"] = domanName;
                    dic1["begDate"]        = DateTime.Now;
                    dic1["endDate"]        = DateTime.Parse(endDate);
                    da1.EditData(condition, dic1);

                    //2--创建日志
                    (new Tb_Task_LogBU()).NewLog(m, "接单", "计划完成时间:" + endDate);
                }

                succ = true;
            }
            catch (Exception err)
            {
                succ = false;
            }
            return(succ);
        }
        //插入数据
        private void InsertData1(
            String prNum,
            String content1,
            String content2,
            String zeren1,
            String finish1,
            Tb_TaskDA da0)
        {
            //1--更加prjNum得到项目id
            String             prjguid   = String.Empty;
            Tb_ProjectDA       da1       = new Tb_ProjectDA();
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("prjNum", prNum));
            Dictionary <String, object> dic1 = da1.GetFirstDictionary(condition, "GuidID");

            if (dic1 != null && dic1.Count > 0 && String.IsNullOrEmpty(dic1["GuidID"].ToString()) == false)
            {
                prjguid = dic1["GuidID"].ToString();
            }

            //2--得到项目经理的id
            String prjManager       = String.Empty;
            Tb_Project_PersonDA da3 = new Tb_Project_PersonDA();

            dic1.Clear();
            condition.Clear();
            condition.Add(new SearchField("ProjectGuidID", prjguid));
            condition.Add(new SearchField("PrjRole", "0"));
            dic1 = da3.GetFirstDictionary(condition, "PersonID");
            if (dic1 != null && dic1.Count > 0)
            {
                prjManager = dic1["PersonID"].ToString();
            }

            //3--根据责任人的姓名得到责任id
            String  zr1 = String.Empty;
            JUserDA da2 = new JUserDA();

            dic1.Clear();
            condition.Clear();
            condition.Add(new SearchField("UserName", zeren1));
            dic1 = da2.GetFirstDictionary(condition, "UserID");
            if (dic1 != null && dic1.Count > 0)
            {
                zr1 = dic1["UserID"].ToString();
            }

            //插入数据
            String year1  = DateTime.Now.ToString("yyyy");
            String month1 = DateTime.Now.ToString("MM");

            if (String.IsNullOrEmpty(prjguid) == false &&
                String.IsNullOrEmpty(content1) == false &&
                String.IsNullOrEmpty(content2) == false &&
                String.IsNullOrEmpty(prjManager) == false &&
                String.IsNullOrEmpty(zr1) == false)
            {
                dic1.Clear();
                dic1["ProjectGuidID"] = prjguid;
                DateTime t1 = DateTime.Parse(year1 + "-" + month1 + "-01");
                dic1["begDate"] = t1;

                DateTime t2 = DateTime.Parse(year1 + "-" + finish1.Substring(0, 2) + "-" + finish1.Substring(2));
                dic1["endDate"] = t2;

                dic1["Workload"]  = ((t2 - t1).Days + 1) * 8;
                dic1["TaskTitle"] = "工作计划";
                dic1["content"]   = content1 + "--" + content2;
                dic1["Manager"]   = prjManager;
                dic1["Status"]    = "1";
                dic1["GuidID"]    = WebFrame.Util.JString.GetUnique32ID();
                dic1["AddTime"]   = DateTime.Now;
                dic1["AddUser"]   = zr1;

                da0.NewData(dic1);
            }
        }
        /// <summary>
        /// 从xlsFile中导入数据
        /// </summary>
        /// <param name="xlsFile"></param>
        /// <returns></returns>
        public bool ExportDataFromXls(String parentGuid, String xlsFile, String BigKind)
        {
            bool succ = false;

            try
            {
                JConnect.GetConnect().BeginTrans();
                if (String.IsNullOrEmpty(xlsFile) == false && File.Exists(xlsFile))
                {
                    WebFrame.Util.UExcel u1  = new WebFrame.Util.UExcel();
                    DataTable            dt1 = u1.XlsToDataSet(xlsFile).Tables[0];

                    Dictionary <String, object> dic1 = new Dictionary <string, object>();


                    Tb_TaskDA     da0 = new Tb_TaskDA();
                    Tb_Task_LogBU bu2 = new Tb_Task_LogBU();

                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        dic1.Clear();
                        dic1["ManagerID"]   = WebFrame.FrameLib.UserID;
                        dic1["ManagerName"] = WebFrame.FrameLib.UserName;
                        dic1["AddTime"]     = DateTime.Now;
                        dic1["Status"]      = "0";
                        dic1["parentGuid"]  = parentGuid;
                        dic1["BigKind"]     = BigKind;

                        if (BigKind == "0")     //工单
                        {
                            dic1["TaskKind"]    = dr1[0].ToString();
                            dic1["TaskTitle"]   = dr1[1].ToString();
                            dic1["content"]     = dr1[2].ToString();
                            dic1["ImportGrade"] = dr1[3].ToString();
                            dic1["TimeGrade"]   = dr1[4].ToString();
                            dic1["PlanDate"]    = DateTime.Parse(dr1[5].ToString());
                            dic1["Workload"]    = dr1[6].ToString();
                            dic1["GuidID"]      = WebFrame.Util.JString.GetUnique32ID(); //得到32位的GuidID的数据

                            if (String.IsNullOrEmpty(dr1[0].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[1].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[2].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[3].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[4].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[5].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[6].ToString()) == false)
                            {
                                da0.NewData(dic1);
                                //插入工单
                                bu2.NewLog(dic1["GuidID"].ToString(), "创建工单", "");
                            }
                        }
                        else                 //BUG工单
                        {
                            dic1["TaskTitle"] = dr1[0].ToString();
                            dic1["SubTitle"]  = dr1[1].ToString();

                            dic1["content"] = dr1[2].ToString();
                            dic1["BugKind"] = dr1[3].ToString();

                            dic1["ImportGrade"] = dr1[4].ToString();
                            dic1["TimeGrade"]   = dr1[5].ToString();

                            dic1["AddTime"]  = DateTime.Parse(dr1[6].ToString());
                            dic1["PlanDate"] = DateTime.Parse(dr1[7].ToString());


                            dic1["Remark"] = dr1[8].ToString();
                            dic1["GuidID"] = WebFrame.Util.JString.GetUnique32ID();  //得到32位的GuidID的数据

                            if (String.IsNullOrEmpty(dr1[0].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[2].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[3].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[4].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[6].ToString()) == false &&
                                String.IsNullOrEmpty(dr1[7].ToString()) == false)
                            {
                                da0.NewData(dic1);
                                //插入BUG工单
                                bu2.NewLog(dic1["GuidID"].ToString(), "创建BUG工单", "");
                            }
                        }
                    }
                }
                JConnect.GetConnect().CommitTrans();
                succ = true;
            }
            catch (Exception err)
            {
                JConnect.GetConnect().RollBackTrans();
                WebFrame.Util.JTool.WriteErrorLog(err.ToString());
                if (String.IsNullOrEmpty(xlsFile) == false && File.Exists(xlsFile))
                {
                    File.Delete(xlsFile);
                }
            }
            return(succ);
        }
示例#19
0
        /// <summary>
        /// 创建月度考核数据
        /// </summary>
        /// <param name="byear">考核年份</param>
        /// <param name="bmonth">考核月份</param>
        /// <param name="khDays">考核工作日</param>
        /// <returns></returns>
        public bool CreateMonthKHData(int byear,
                                      int bmonth,
                                      double khDays)
        {
            bool succ = false;

            //code、team和test的工作量系数
            double rate1 = double.Parse(WebFrame.Comm.JStrInfoBU.GetStrTextByID("codeRate"));
            double rate2 = double.Parse(WebFrame.Comm.JStrInfoBU.GetStrTextByID("teamRate"));
            double rate3 = double.Parse(WebFrame.Comm.JStrInfoBU.GetStrTextByID("testRate"));

            JConnect.GetConnect().BeginTrans();
            try
            {
                //1--得到考核人员清单
                List <SearchField> condition = new List <SearchField>();
                JUserDA            da1       = new JUserDA();
                condition.Add(new SearchField("gw='0' or gw='1' or gw='2'", "", SearchOperator.UserDefine));
                DataTable dt1 = da1.GetListData(condition, -1, -1, "num", "UserID,UserName");

                //2--删除原有的考核数据
                Tb_KH_MonthDA da2 = new Tb_KH_MonthDA();
                condition.Clear();
                condition.Add(new SearchField("byear", byear + "", SearchFieldType.NumericType));
                condition.Add(new SearchField("bmonth", bmonth + "", SearchFieldType.NumericType));
                da2.DeleteData(condition);

                //3--根据考核人员名单形成新的月度考核数据
                DataTable khTable = new DataTable();
                khTable.Columns.Add("userid");
                khTable.Columns.Add("username");
                khTable.Columns.Add("workload1", typeof(double));
                khTable.Columns.Add("workload2", typeof(double));
                khTable.Columns.Add("workload3", typeof(double));
                khTable.PrimaryKey = new DataColumn[] { khTable.Columns["userid"] };
                foreach (DataRow dr1 in dt1.Rows)
                {
                    DataRow khrow = khTable.NewRow();
                    khrow["userid"]    = dr1["userid"];
                    khrow["UserName"]  = dr1["username"];
                    khrow["workload1"] = 0;     //code
                    khrow["workload2"] = 0;     //team
                    khrow["workload3"] = 0;     //test
                    khTable.Rows.Add(khrow);
                }

                //4--根据月度考核的任务,修改考核数据
                condition.Clear();
                condition.Add(new SearchField("Status", "4"));
                condition.Add(new SearchField("DatePart('yyyy', finishDate)=" + byear, "", SearchOperator.UserDefine));
                condition.Add(new SearchField("DatePart('M', finishDate)=" + bmonth, "", SearchOperator.UserDefine));
                Tb_TaskDA da3 = new Tb_TaskDA();
                DataTable dt3 = da3.GetListData(condition, -1, -1, "FinishDate", "*");

                Tb_Task_BugDA da4 = new Tb_Task_BugDA();
                foreach (DataRow dr3 in dt3.Rows)
                {
                    int    load1      = int.Parse(dr3["LastWorkLoad"].ToString());
                    String Manager    = dr3["Manager"].ToString();
                    String ExecuteMan = dr3["ExecuteMan"].ToString();

                    //得到测试的情况A-3 B-2 C-1
                    Dictionary <String, double> debugDic = da4.GetTaskDebugRate(dr3["Guidid"].ToString());
                    if (debugDic.Count == 0)
                    {
                        debugDic[dr3["TestMan"].ToString()] = 1.0;
                    }

                    //根据不同的人员分配工作量
                    //code
                    DataRow datarow1 = khTable.Rows.Find(ExecuteMan);
                    if (datarow1 != null)
                    {
                        datarow1["workload1"] = double.Parse(datarow1["workload1"].ToString()) + load1;
                    }

                    //team
                    DataRow datarow2 = khTable.Rows.Find(Manager);
                    if (datarow2 != null)
                    {
                        datarow2["workload2"] = double.Parse(datarow2["workload2"].ToString()) + load1;
                    }

                    //test
                    foreach (string m in debugDic.Keys)
                    {
                        DataRow datarow3 = khTable.Rows.Find(m);
                        if (datarow3 != null)
                        {
                            datarow3["workload3"] = double.Parse(datarow3["workload3"].ToString()) + load1 * debugDic[m];
                        }
                    }
                }

                //5--将数据写入到月度考核任务表
                Dictionary <String, object> dic1 = new Dictionary <string, object>();
                foreach (DataRow dr1 in khTable.Rows)
                {
                    dic1.Clear();
                    dic1["byear"]     = byear;
                    dic1["bmonth"]    = bmonth;
                    dic1["userid"]    = dr1["userid"];
                    dic1["userName"]  = dr1["username"];
                    dic1["Fullload"]  = khDays * 8;
                    dic1["workload1"] = dr1["workload1"];
                    dic1["workload2"] = dr1["workload2"];
                    dic1["workload3"] = dr1["workload3"];
                    dic1["workload"]  = rate1 * double.Parse(dr1["workload1"].ToString()) +
                                        rate2 * double.Parse(dr1["workload2"].ToString()) +
                                        rate3 * double.Parse(dr1["workload3"].ToString());
                    dic1["AddMoney"] = 0;

                    da2.NewData(dic1);
                }

                JConnect.GetConnect().CommitTrans();
                succ = true;
            }
            catch (Exception err)
            {
                JConnect.GetConnect().RollBackTrans();
                WebFrame.Util.JTool.WriteErrorLog(err.ToString());
            }
            return(succ);
        }
        /// <summary>
        /// 创建月度考核数据
        /// </summary>
        /// <param name="YearAndMonth"></param>
        /// <returns></returns>
        public bool CreateMonthKaoHeData(String YearAndMonth, String totalDay,
                                         String UserID)
        {
            bool succ = false;

            JConnect.GetConnect().BeginTrans();
            try
            {
                double totalday1 = double.Parse(totalDay) * 8;   //表示总的工作量

                String[] arr1   = YearAndMonth.Split('-');
                int      byear  = int.Parse(arr1[0]);
                int      bmonth = int.Parse(arr1[1]);

                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("byear", byear + "", SearchFieldType.NumericType));
                condition.Add(new SearchField("bmonth", bmonth + "", SearchFieldType.NumericType));
                if (String.IsNullOrEmpty(UserID) == false)
                {
                    condition.Add(new SearchField("UserID", UserID));
                }

                Dictionary <String, object> dic1 = new Dictionary <string, object>();
                Dictionary <String, object> dic2 = new Dictionary <string, object>();

                //1--清除老数据
                Tb_PL_MonthDA da0 = new Tb_PL_MonthDA();
                da0.DeleteData(condition);

                //2--创建软件开发人员的月度考核数据
                double s1 = 0;
                double w1 = 0;

                Tb_TaskDA da1 = new Tb_TaskDA();
                da1.TableName = "Tb_TaskKHView";
                condition.Clear();
                condition.Add(new SearchField("byear", byear + "", SearchFieldType.NumericType));
                condition.Add(new SearchField("bmonth", bmonth + "", SearchFieldType.NumericType));
                if (String.IsNullOrEmpty(UserID) == false)
                {
                    condition.Add(new SearchField("AddUser", UserID));
                }
                DataTable dt1 = da1.GetListData(condition, -1, -1, "AddUser", "*");
                if (dt1.Rows.Count > 0)
                {
                    String first1   = dt1.Rows[0]["AddUser"].ToString();
                    double workload = 0;
                    double score    = 0;
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        if (dr1["AddUser"].ToString() == first1)
                        {
                            workload += double.Parse(dr1["lastWorkload"].ToString());
                            score    += double.Parse(dr1["lastWorkload"].ToString()) *
                                        double.Parse(dr1["score"].ToString());
                        }
                        else
                        {
                            //插入新的数据
                            dic1.Clear();
                            dic1["byear"]    = byear;
                            dic1["bmonth"]   = bmonth;
                            dic1["UserID"]   = first1;
                            dic1["UserName"] = KORWeb.BUL.JUserBU.GetUserNamByIDS(dic1["UserID"].ToString());

                            s1 = score / workload;
                            dic1["CheckScore"] = Math.Round(s1);
                            dic1["AddScore"]   = 0;
                            dic1["TotalScore"] = dic1["CheckScore"];

                            dic1["TotalWork"] = totalday1;
                            dic1["FactWork"]  = workload;
                            w1 = Math.Round(workload / totalday1, 2);
                            dic1["WorkRate"] = w1;

                            dic1["CheckResult"] = this.GetKhResult(s1, w1);
                            da0.NewData(dic1);


                            first1   = dr1["AddUser"].ToString();
                            workload = double.Parse(dr1["lastWorkload"].ToString());
                            score    = double.Parse(dr1["lastWorkload"].ToString()) *
                                       double.Parse(dr1["score"].ToString());
                        }
                    }

                    //插入最后一条数据
                    dic1.Clear();
                    dic1["byear"]    = byear;
                    dic1["bmonth"]   = bmonth;
                    dic1["UserID"]   = first1;
                    dic1["UserName"] = KORWeb.BUL.JUserBU.GetUserNamByIDS(dic1["UserID"].ToString());

                    s1 = score / workload;
                    dic1["CheckScore"] = Math.Round(s1);
                    dic1["AddScore"]   = 0;
                    dic1["TotalScore"] = dic1["CheckScore"];

                    dic1["TotalWork"] = totalday1;
                    dic1["FactWork"]  = workload;
                    w1 = Math.Round(workload / totalday1, 2);
                    dic1["WorkRate"] = w1;

                    dic1["CheckResult"] = this.GetKhResult(s1, w1);
                    da0.NewData(dic1);


                    //3--调整用户的其他加减分
                    Tb_KaoHeOtherDA da3 = new Tb_KaoHeOtherDA();
                    da3.TableName = "Tb_KaoHeOtherTJView";
                    condition.Clear();
                    condition.Add(new SearchField("byear", byear + "", SearchFieldType.NumericType));
                    condition.Add(new SearchField("bmonth", bmonth + "", SearchFieldType.NumericType));
                    if (String.IsNullOrEmpty(UserID) == false)
                    {
                        condition.Add(new SearchField("userid", UserID));
                    }
                    dt1 = da3.GetListData(condition, -1, -1, "userid", "*");

                    double addscore   = 0;                          //加减分
                    double totalScore = 0;                          //总分
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        String userid1 = dr1["userid"].ToString();
                        addscore = double.Parse(dr1["addscore"].ToString());  //加减分

                        condition.Clear();
                        condition.Add(new SearchField("byear", byear + "", SearchFieldType.NumericType));
                        condition.Add(new SearchField("bmonth", bmonth + "", SearchFieldType.NumericType));
                        condition.Add(new SearchField("userid", userid1));

                        dic1 = da0.GetFirstDictionary(condition, "*");
                        if (dic1 != null && dic1.Count > 0)
                        {
                            totalScore = double.Parse(dic1["TotalScore"].ToString());
                            totalScore = totalScore + addscore;  //调整总分
                            w1         = double.Parse(dic1["WorkRate"].ToString());

                            //调整数据
                            dic2.Clear();
                            dic2["AddScore"]    = addscore;
                            dic2["TotalScore"]  = totalScore;
                            dic2["CheckResult"] = this.GetKhResult(totalScore, w1);
                            da0.EditData(condition, dic2);  //更新数据
                        }
                    }
                }


                JConnect.GetConnect().CommitTrans();
                succ = true;
            }
            catch (Exception err)
            {
                JConnect.GetConnect().RollBackTrans();
            }
            return(succ);
        }