public static int AddProjectBudgetInfo(ProjectBudgetInfo projectBudgetInfo, XBase.Common.UserInfoUtil userinfo, string valuelist, string basevaluelist)
 {
     return ProjectBudgetDBHelper.AddProjectBudgetInfo(projectBudgetInfo, userinfo, valuelist, basevaluelist);
 }
        public static int AddProjectBudgetInfo(ProjectBudgetInfo projectBudgetInfo, XBase.Common.UserInfoUtil userinfo, string valuelist, string basevaluelist)
        {
            StringBuilder sqlstr = new StringBuilder();
            sqlstr.AppendLine("delete from officedba.ProjectBudget where [email protected] and [email protected]");
            sqlstr.AppendLine("insert into officedba.ProjectBudget(CompanyCD,ProjectID,TotalPrice,BudgetPerson,BudgetTime,status,userlist) values(@CompanyCD,@ProjectID,@TotalPrice,@BudgetPerson,@BudgetTime,1,@userlist)");
            sqlstr.AppendLine("delete from officedba.ProjectBudgetDetails where [email protected] and [email protected]");
            if (valuelist.Length > 0)
            {
                string[] arr = valuelist.Split(',');
                for (int i = 0; i < arr.Length; i++)
                {
                    string[] item = arr[i].Split('#');
                    for (int j = 0; j < 3; j++)
                    {
                        if (item[j] == "" || item[j].Trim().Length < 1)
                        {
                            item[j] = "0";
                        }
                    }
                    sqlstr.AppendLine("insert into officedba.ProjectBudgetDetails(CompanyCD,ProjectID,SummaryID,PriceID,budgetValue) values(@CompanyCD,@ProjectID," + int.Parse(item[0]) + "," + int.Parse(item[1]) + "," + decimal.Parse(item[2]) + ")");
                }
            }

            sqlstr.AppendLine("delete from officedba.ProjectBaseNum where [email protected] and [email protected]");
            if (basevaluelist.Length > 0)
            {
                string[] arr = basevaluelist.Split(',');
                for (int i = 0; i < arr.Length; i++)
                {
                    string[] item = arr[i].Split('#');
                    if (item[1].Length < 1)
                    {
                        item[1] = "0";
                    }
                    sqlstr.AppendLine("insert into officedba.ProjectBaseNum(CompanyCD,ProjectID,SummaryID,BaseNum) values(@CompanyCD,@ProjectID," + int.Parse(item[0]) + "," + decimal.Parse(item[1]) + ")");
                }
            }

            SqlParameter[] param = {
                                       new SqlParameter("@CompanyCD",SqlDbType.VarChar,50),
                                       new SqlParameter("@ProjectID",SqlDbType.Int),
                                       new SqlParameter("@TotalPrice",SqlDbType.Decimal),
                                       new SqlParameter("@BudgetPerson",SqlDbType.Int),
                                       new SqlParameter("@BudgetTime",SqlDbType.DateTime),
                                       new SqlParameter("@userlist",SqlDbType.VarChar)
                                   };
            param[0].Value = userinfo.CompanyCD;
            param[1].Value = projectBudgetInfo.ProjectID;
            param[2].Value = projectBudgetInfo.TotalPrice;
            param[3].Value = projectBudgetInfo.BudgetPerson;
            param[4].Value = projectBudgetInfo.BudgetTime;
            if (projectBudgetInfo.Userlist.Length > 0)
            {
                List<string> arr = new List<string>();
                foreach (string i in projectBudgetInfo.Userlist.Split(','))
                {
                    arr.Add(i);
                }
                if(!arr.Contains(userinfo.EmployeeID.ToString()))
                {
                    projectBudgetInfo.Userlist += "," + userinfo.EmployeeID;
                }

                
            }
            param[5].Value = projectBudgetInfo.Userlist;

            //删除该项目明细

            TransactionManager tran = new TransactionManager();
            int num = 0;
            tran.BeginTransaction();
            try
            {
                num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr.ToString(), param);
                tran.Commit();
            }
            catch (Exception ex)
            {
                string str = ex.Message;
                tran.Rollback();
            }
            return num;
        }