Esempio n. 1
0
        /// <summary>
        /// 获取LR_Base_TempUser表实体数据
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public LR_Base_TempUserEntity GetLR_Base_TempUserEntity(string keyValue, string orderID)
        {
            try
            {
                var dp = new DynamicParameters(new { });
                dp.Add("userID", keyValue, DbType.String);
                dp.Add("orderID", orderID, DbType.String);

                string type = this.BaseRepository().FindObject("SELECT F_CategoryId FROM F_Base_TempWorkOrderUserDetail WHERE F_UserId=@userID AND F_TempWorkOrderId=@orderID", dp).ToString();
                LR_Base_TempUserEntity info = this.BaseRepository().FindEntity <LR_Base_TempUserEntity>(keyValue);
                info.F_EmployerTypeId = type;
                return(info);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public int SaveEntity(ref string keyValue, LR_Base_TempUserEntity entity, string orderID)
 {
     try
     {
         return(orderUsersDetailService.SaveEntity(ref keyValue, entity, orderID));
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public int WorkSubstituteSaveForm(string keyValue, string orderID, LR_Base_TempUserEntity entity)
 {
     try
     {
         return(tempUserService.WorkSubstituteSaveForm(keyValue, orderID, entity));
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, LR_Base_TempUserEntity entity)
 {
     try
     {
         tempUserService.SaveEntity(keyValue, entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public int SaveEntity(ref string keyValue, LR_Base_TempUserEntity entity, string orderID)
        {
            int checkError = 0;

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    entity.Modify(keyValue);

                    // 虚拟参数
                    var dp = new DynamicParameters(new { });
                    dp.Add("userid", keyValue, DbType.String);
                    dp.Add("orderid", orderID, DbType.String);
                    dp.Add("type", entity.F_EmployerTypeId, DbType.String);
                    dp.Add("employerid", entity.F_EmployerId, DbType.String);

                    //修改该 临时工 在特定订单里的工种类型
                    this.BaseRepository().ExecuteBySql("UPDATE F_Base_TempWorkOrderUserDetail SET f_employerid=@employerid,F_CategoryId=@type WHERE F_TempWorkOrderId=@orderid AND f_userid=@userid", dp);
                    entity.F_EmployerTypeId = string.Empty;
                    //修改临时工基本信息(大表)
                    this.BaseRepository().Update(entity);
                }
                else
                {
                    var dp = new DynamicParameters(new {});
                    dp.Add("identity", entity.F_Identity, DbType.String);
                    //首先从大表获取新将要添加的小时工数据,用于判断该小时工是否以前已经存在
                    object userid = this.BaseRepository().FindObject("SELECT f_userid AS num FROM LR_Base_TempUser WHERE F_Identity=@identity", dp);

                    dp = new DynamicParameters(new {});
                    dp.Add("orderID", orderID, DbType.String);
                    //根据订单ID获取劳务公司ID
                    entity.F_EmployerId = this.BaseRepository().FindObject("SELECT F_EmployerId FROM F_Base_TempWorkOrder WHERE f_orderid=@orderID", dp).ToString();
                    string type = entity.F_EmployerTypeId;
                    entity.F_EmployerTypeId = string.Empty;
                    object f_id = null;

                    //用身份证判断用户是否存在大表中,如果存在直接修改临时工表数据(因为用户基本信息是通用一样的,只有工种是挂在每个订单下)。
                    if (userid != null && (string)userid != string.Empty)
                    {
                        entity.Modify((string)userid);

                        dp = new DynamicParameters(new {});
                        dp.Add("userID", (string)userid, DbType.String);
                        dp.Add("orderID", orderID, DbType.String);

                        //判断该小时工是否已在本次活动中
                        f_id = this.BaseRepository().FindObject("SELECT f_id FROM F_Base_TempWorkOrderUserDetail WHERE f_userid=@userID AND F_TempWorkOrderId=@orderID", dp);

                        if (f_id != null && !string.IsNullOrEmpty(f_id.ToString()))
                        {
                            checkError = 2;  //代表该订单已经包含该临时工
                        }
                        else
                        {
                            //修改临时工大表
                            this.BaseRepository().Update(entity);
                        }
                    }
                    else
                    {
                        entity.Create();
                        this.BaseRepository().Insert(entity);
                        userid   = entity.F_UserId;
                        keyValue = (string)userid;
                    }

                    if (checkError != 2)
                    {
                        // 虚拟参数
                        dp = new DynamicParameters(new
                        {
                        });
                        dp.Add("f_id", Guid.NewGuid().ToString(), DbType.String);
                        dp.Add("userid", (string)userid, DbType.String);
                        dp.Add("orderid", orderID, DbType.String);
                        dp.Add("type", type, DbType.String);
                        dp.Add("employerid", entity.F_EmployerId, DbType.String);
                        dp.Add("createUser", LoginUserInfo.Get().userId, DbType.String);
                        //往关联细表中添加临时工与订单关联
                        this.BaseRepository().ExecuteBySql("INSERT F_Base_TempWorkOrderUserDetail(f_id,F_TempWorkOrderId,f_userid,f_employerid,f_categoryid,F_WorkSubstitute,F_CreateUser) VALUES(@f_id,@orderid,@userid,@employerid,@type,0,@createUser)", dp);

                        //获取订单的开始时间和结束时间
                        dp = new DynamicParameters(new
                        {
                        });
                        dp.Add("orderID", orderID, DbType.String);

                        DataTable dt        = this.BaseRepository().FindTable("SELECT * FROM F_Base_TempWorkOrder WHERE f_orderid=@orderID", dp);
                        DateTime  startTime = DateTime.Parse(dt.Rows[0]["F_StartTime"].ToString());
                        DateTime  endTime   = DateTime.Parse(dt.Rows[0]["F_EndTime"].ToString());

                        for (DateTime t = startTime; t <= endTime; t = t.AddDays(1))
                        {
                            // 虚拟参数
                            var dp2 = new DynamicParameters(new
                            {
                            });
                            dp2.Add("F_RecordId", Guid.NewGuid().ToString(), DbType.String);
                            dp2.Add("F_Identity", entity.F_Identity, DbType.String);
                            dp2.Add("F_CreateTime", t, DbType.String);
                            dp2.Add("F_RealName", entity.F_RealName, DbType.String);
                            dp2.Add("F_Gender", entity.F_Gender, DbType.Int32);
                            dp2.Add("F_OrderId", orderID, DbType.String);
                            dp2.Add("F_RecordDate", t.ToString("yyyy-MM-dd"), DbType.String);

                            //自动给临时工往打卡记录里初始化打卡记录
                            this.BaseRepository().ExecuteBySql("INSERT LR_Base_CardRecord(F_RecordId,F_Identity,F_CreateTime,F_RealName,F_Gender,F_OrderId,F_RecordDate) VALUES (@F_RecordId,@F_Identity,@F_CreateTime,@F_RealName,@F_Gender,@F_OrderId,@F_RecordDate)", dp2);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }

            return(checkError);
        }
Esempio n. 6
0
        /// <summary>
        /// 保存替工数据(新增、修改)
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="orderID"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int WorkSubstituteSaveForm(string keyValue, string orderID, LR_Base_TempUserEntity entity)
        {
            int checkError = 0;

            try
            {
                //根据替工者的身份证获取他在表中主键
                object userid = this.BaseRepository().FindObject("SELECT f_userid AS num FROM LR_Base_TempUser WHERE F_Identity='" + entity.F_Identity + "'");

                var dp = new DynamicParameters(new
                {
                });

                dp.Add("orderID", orderID, DbType.String);

                //根据订单ID获取用人单位ID
                entity.F_EmployerId = this.BaseRepository().FindObject("SELECT F_EmployerId AS employerID FROM F_Base_TempWorkOrder WHERE f_orderid=@orderID", dp).ToString();

                //用身份证判断用户是否存在,如果存在直接修改临时工表数据(因为用户基本信息是通用一样的,只有工种是挂在每个订单下)。
                if (userid != null && (string)userid != string.Empty)
                {
                    entity.Modify((string)userid);

                    // 虚拟参数
                    var dp2 = new DynamicParameters(new
                    {
                    });
                    dp2.Add("userID", (string)userid, DbType.String);
                    dp2.Add("orderID", orderID, DbType.String);

                    int num = Convert.ToInt32(this.BaseRepository().FindObject("SELECT COUNT(*) FROM F_Base_TempWorkOrderUserDetail WHERE f_userid=@userID AND F_TempWorkOrderId=@orderID", dp2));

                    //判断替工人是否在订单中
                    if (num > 0)
                    {
                        checkError = 2;  //代表该订单已经包含该临时工
                    }
                    else
                    {
                        this.BaseRepository().Update(entity);
                    }
                }
                else
                {
                    entity.Create();
                    this.BaseRepository().Insert(entity);
                    userid = entity.F_UserId;
                }

                if (checkError != 2)
                {
                    // 虚拟参数
                    dp = new DynamicParameters(new
                    {
                    });
                    dp.Add("userid", (string)userid, DbType.String);
                    dp.Add("orderid", orderID, DbType.String);

                    string type = Convert.ToString(this.BaseRepository().FindObject("SELECT F_CategoryId FROM F_Base_TempWorkOrderUserDetail WHERE F_TempWorkOrderId='" + orderID + "' AND F_UserId='" + keyValue + "'"));
                    dp.Add("type", type, DbType.String);

                    dp.Add("employerid", entity.F_EmployerId, DbType.String);
                    dp.Add("F_Replacement", keyValue, DbType.String);
                    dp.Add("createUser", LoginUserInfo.Get().userId, DbType.String);
                    //往关联细表中添加临时工与订单关联
                    this.BaseRepository().ExecuteBySql("INSERT F_Base_TempWorkOrderUserDetail(F_TempWorkOrderId,f_userid,f_employerid,f_categoryid,F_WorkSubstitute,F_CreateUser,F_Replacement) VALUES(@orderid,@userid,employerid,@type,1,@createUser,@F_Replacement)", dp);
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }

            return(checkError);
        }
Esempio n. 7
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(string keyValue, LR_Base_TempUserEntity entity)
        {
            try
            {
                string userid = keyValue;

                if (!string.IsNullOrEmpty(userid))
                {
                    entity.Modify(userid);
                    this.BaseRepository().Update(entity);

                    var dp = new DynamicParameters(new
                    {
                    });

                    dp.Add("orderid", entity.F_OrderId, DbType.String);
                    dp.Add("userid", entity.F_UserId, DbType.String);
                    dp.Add("F_EmployerId", entity.F_EmployerId, DbType.String);
                    dp.Add("F_CategoryId", entity.F_EmployerTypeId, DbType.String);

                    //插入临时工的同时往订单与用户细表中插入一条记录(关联订单)
                    this.BaseRepository().ExecuteBySql("UPDATE F_Base_TempWorkOrderUserDetail SET F_TempWorkOrderId=@orderid,F_EmployerId=@F_EmployerId,F_CategoryId=@F_CategoryId WHERE F_UserId=@userid", dp);
                }
                else
                {
                    DataTable dt = this.BaseRepository().FindTable("SELECT F_UserId FROM LR_Base_TempUser WHERE F_Identity='" + entity.F_Identity + "'");
                    entity.Create();

                    //根据身份证号判断该人是否已在DB中,如果存在就直接往订单与用户细表中插入一条记录
                    if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                    {
                        entity.F_UserId = dt.Rows[0]["F_UserId"].ToString();
                    }
                    else
                    {
                        this.BaseRepository().Insert(entity);
                    }

                    var dp = new DynamicParameters(new
                    {
                    });

                    dp.Add("f_id", Guid.NewGuid().ToString(), DbType.String);
                    dp.Add("orderid", entity.F_OrderId, DbType.String);
                    dp.Add("userid", entity.F_UserId, DbType.String);
                    dp.Add("F_EmployerId", entity.F_EmployerId, DbType.String);
                    dp.Add("F_CategoryId", entity.F_EmployerTypeId, DbType.String);

                    //插入临时工的同时往订单与用户细表中插入一条记录(关联订单)
                    this.BaseRepository().ExecuteBySql("INSERT F_Base_TempWorkOrderUserDetail(f_id,F_TempWorkOrderId,F_UserId,F_EmployerId,F_CategoryId,F_WorkSubstitute) VALUES(@f_id,@orderid,@userid,@F_EmployerId,@F_CategoryId,0)", dp);
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }