/// <summary>
 /// 根据条件,修改一个数据
 /// </summary>
 /// <param name="condition">修改数据的条件</param>
 /// <param name="data1">新的数据</param>
 public void EditData(List <SearchField> condition, Dictionary <String, object> data1)
 {
     try
     {
         Tb_PL_MonthDA da1 = new Tb_PL_MonthDA();
         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="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);
        }