Пример #1
0
        /// <summary>
        /// 新建社会保险录入信息
        /// </summary>
        /// <param name="model">社会保险录入信息</param>
        /// <returns></returns>
        private static SqlCommand InsertInsuEmployeeInfo(InsuEmployeeModel model)
        {
            #region 登陆SQL文
            StringBuilder insertSql = new StringBuilder();
            insertSql.AppendLine(" INSERT INTO            ");
            insertSql.AppendLine(" officedba.InsuEmployee ");
            insertSql.AppendLine(" 	(CompanyCD            ");
            insertSql.AppendLine(" 	,EmployeeID           ");
            insertSql.AppendLine(" 	,StartDate            ");
            insertSql.AppendLine(" 	,Addr                 ");
            insertSql.AppendLine(" 	,InsuranceID          ");
            insertSql.AppendLine(" 	,InsuranceBase        ");
            insertSql.AppendLine(" 	,ModifiedDate         ");
            insertSql.AppendLine(" 	,ModifiedUserID)      ");
            insertSql.AppendLine(" VALUES                 ");
            insertSql.AppendLine(" 	(@CompanyCD           ");
            insertSql.AppendLine(" 	,@EmployeeID          ");
            insertSql.AppendLine(" 	,@StartDate           ");
            insertSql.AppendLine(" 	,@Addr                ");
            insertSql.AppendLine(" 	,@InsuranceID         ");
            insertSql.AppendLine(" 	,@InsuranceBase       ");
            insertSql.AppendLine(" 	,getdate()            ");
            insertSql.AppendLine(" 	,@ModifiedUserID)     ");
            #endregion

            //定义更新基本信息的命令
            SqlCommand comm = new SqlCommand();
            //设置存储过程名
            comm.CommandText = insertSql.ToString();
            //设置保存的参数
            SetSaveParameter(comm, model);

            //执行插入并返回插入结果
            return(comm);
        }
Пример #2
0
        /// <summary>
        /// 更新社会保险录入信息
        /// </summary>
        /// <param name="model">社会保险录入信息</param>
        /// <returns></returns>
        private static SqlCommand UpdateInsuEmployeeInfo(InsuEmployeeModel model)
        {
            #region SQL文拼写
            StringBuilder updateSql = new StringBuilder();
            updateSql.AppendLine(" UPDATE                             ");
            updateSql.AppendLine(" officedba.InsuEmployee             ");
            updateSql.AppendLine(" SET  StartDate = @StartDate        ");
            updateSql.AppendLine(" 	,Addr = @Addr                     ");
            updateSql.AppendLine(" 	,InsuranceBase = @InsuranceBase   ");
            updateSql.AppendLine(" 	,ModifiedDate = getdate()         ");
            updateSql.AppendLine(" 	,ModifiedUserID = @ModifiedUserID ");
            updateSql.AppendLine(" WHERE                              ");
            updateSql.AppendLine(" 	CompanyCD = @CompanyCD            ");
            updateSql.AppendLine(" 	AND InsuranceID = @InsuranceID    ");
            updateSql.AppendLine(" 	AND EmployeeID = @EmployeeID      ");

            #endregion

            //定义更新基本信息的命令
            SqlCommand comm = new SqlCommand();
            comm.CommandText = updateSql.ToString();
            //其他参数
            SetSaveParameter(comm, model);
            //执行更新
            return(comm);
        }
Пример #3
0
 /// <summary>
 /// 保存时参数设置
 /// </summary>
 /// <param name="comm">命令</param>
 /// <param name="model">员工社会保险信息</param>
 private static void SetSaveParameter(SqlCommand comm, InsuEmployeeModel model)
 {
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));           //公司代码
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@EmployeeID", model.EmployeeID));         //员工ID
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@InsuranceID", model.InsuranceID));       //保险ID
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@StartDate", model.StartDate));           //参保时间
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Addr", model.Addr));                     //参保地
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@InsuranceBase", model.InsuranceBase));   //金额
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID)); //更新用户ID
 }
Пример #4
0
        /// <summary>
        /// 保存社会保险录入信息
        /// </summary>
        /// <param name="lstEdit">社会保险录入信息</param>
        /// <param name="modifyUserID">最后修改人</param>
        /// <returns></returns>
        public static bool SaveInsuEmployeeInfo(ArrayList lstEdit, string companyCD, string modifyUserID)
        {
            //定义返回变量
            bool isSucc = true;

            //信息存在时,进行操作
            if (lstEdit != null && lstEdit.Count > 0)
            {
                //保存库列表
                ArrayList lstSave = new ArrayList();
                //遍历所有社会保险录入,进行增删改操作
                for (int i = 0; i < lstEdit.Count; i++)
                {
                    //获取值
                    InsuEmployeeModel model = (InsuEmployeeModel)lstEdit[i];
                    //设置最后修改人
                    model.ModifiedUserID = modifyUserID;
                    //设置公司代码
                    model.CompanyCD = companyCD;
                    //更新
                    if ("1".Equals(model.EditFlag))
                    {
                        //执行更新操作
                        lstSave.Add(UpdateInsuEmployeeInfo(model));
                    }
                    //插入
                    else if ("0".Equals(model.EditFlag))
                    {
                        //执行插入操作
                        lstSave.Add(InsertInsuEmployeeInfo(model));
                    }
                    else
                    {
                        //执行删除操作
                        lstSave.Add(DeleteInsuEmployeeInfo(model.CompanyCD, model.EmployeeID, model.InsuranceID));
                    }
                }
                //执行保存操作
                isSucc = SqlHelper.ExecuteTransWithArrayList(lstSave);
            }

            return(isSucc);
        }