Exemplo n.º 1
0
        /// <summary>
        /// 员工退房
        /// </summary>
        /// <param name="intID"></param>
        public void CheckOut(int intID, string sTotal)
        {
            DataTable           dtCheckIn            = null; //入住信息
            TB_EmployeeCheckOut mTB_EmployeeCheckOut = null; //退房记录
            bool    bCanLeave = false;
            bool    bSuccess  = false;
            decimal?dSum      = null;

            //启用事务
            _db         = DBO.CreateDatabase();
            _connection = _db.CreateConnection();
            _connection.Open();
            _tran = _connection.BeginTransaction();
            try
            {
                dtCheckIn = _mTB_EmployeeCheckInDAL.Get(intID);

                //添加扣费记录
                string[] sData                 = sTotal.Split('@');
                string   sReason               = sData[0].ToString();
                string   sChargeContent        = sData[1].ToString();
                string   sMoney                = sData[2].ToString();
                string   sAirConditionFee      = sData[3].ToString();
                string   sAirConditionFeeMoney = sData[4].ToString();
                string   sRoomKeyFee           = sData[5].ToString();
                string   sRoomKeyFeeMoney      = sData[6].ToString();
                string   sOtherFee             = sData[7].ToString();
                string   sOtherFeeMoney        = sData[8].ToString();
                string   sRemark               = sData[9].ToString();
                string   sCanLeave             = sData[10].ToString();

                //调房--分配到未入住区域
                if (sReason.Contains("调房"))
                {
                    TB_AssignDormArea tB_AssignDormArea = new TB_AssignDormArea();
                    tB_AssignDormArea.DormAreaID = Convert.ToInt32(sReason.Split('#')[1]);
                    tB_AssignDormArea.CardNo     = dtCheckIn.Rows[0]["CardNo"].ToString();
                    tB_AssignDormArea.EmployeeNo = dtCheckIn.Rows[0]["EmployeeNo"].ToString();
                    tB_AssignDormArea.CreateUser = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount;
                    tB_AssignDormArea.CreateDate = System.DateTime.Now;

                    new AssignRoomBLL().AssignArea(tB_AssignDormArea);

                    sReason = sReason.Split('#')[0];
                }

                //添加退房记录
                mTB_EmployeeCheckOut              = new TB_EmployeeCheckOut();
                mTB_EmployeeCheckOut.BedID        = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BedID]);
                mTB_EmployeeCheckOut.BU           = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU].ToString();
                mTB_EmployeeCheckOut.BUID         = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID]);
                mTB_EmployeeCheckOut.CardNo       = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo].ToString();
                mTB_EmployeeCheckOut.CheckInDate  = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate] is DBNull ? DateTime.Now : Convert.ToDateTime(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate]);
                mTB_EmployeeCheckOut.CheckOutDate = DateTime.Now;
                mTB_EmployeeCheckOut.Company      = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company].ToString();
                mTB_EmployeeCheckOut.Creator      = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount;
                mTB_EmployeeCheckOut.EmployeeNo   = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo].ToString();
                mTB_EmployeeCheckOut.IsSmoking    = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking] is DBNull ? false : Convert.ToBoolean(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking]);
                mTB_EmployeeCheckOut.Name         = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name].ToString();
                mTB_EmployeeCheckOut.Province     = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province].ToString();
                mTB_EmployeeCheckOut.RoomID       = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_RoomID]);
                mTB_EmployeeCheckOut.Sex          = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex]);
                mTB_EmployeeCheckOut.SiteID       = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_SiteID]);
                mTB_EmployeeCheckOut.Telephone    = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone].ToString();
                mTB_EmployeeCheckOut.Reason       = sReason == "" ? string.Empty : sReason;
                mTB_EmployeeCheckOut.Remark       = sRemark == "" ? string.Empty : sRemark;
                bCanLeave = (Convert.ToInt32(sCanLeave) > 0);
                mTB_EmployeeCheckOut.CanLeave         = bCanLeave ? 1 : 0;
                mTB_EmployeeCheckOut.EmployeeTypeName = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeTypeName].ToString();

                _mTB_EmployeeCheckOutDAL.Create(mTB_EmployeeCheckOut, _tran, _db);

                //更新床位状态
                _mTB_BedDAL.Update(mTB_EmployeeCheckOut.BedID, _tran, _db, TypeManager.BedStatus.Free);
                //删除入住信息
                _mTB_EmployeeCheckInDAL.Delete(intID, _tran, _db);

                //添加扣费记录
                var dMoney = sMoney.Length > 0 ? Convert.ToDecimal(sMoney) : 0;
                var dAirConditionFeeMoney = sAirConditionFeeMoney.Length > 0 ? Convert.ToDecimal(sAirConditionFeeMoney) : 0;
                var dRoomKeyFeeMoney      = sRoomKeyFeeMoney.Length > 0 ? Convert.ToDecimal(sRoomKeyFeeMoney) : 0;
                var dOtherFeeMoney        = sOtherFeeMoney.Length > 0 ? Convert.ToDecimal(sOtherFeeMoney) : 0;
                dSum = dMoney + dAirConditionFeeMoney + dRoomKeyFeeMoney + dOtherFeeMoney; //总扣费

                ChargingBLL mChargingBLL = new ChargingBLL();
                TB_Charging mTB_Charging = new TB_Charging();
                mTB_Charging.Name                 = mTB_EmployeeCheckOut.Name;
                mTB_Charging.EmployeeNo           = mTB_EmployeeCheckOut.EmployeeNo;
                mTB_Charging.ChargeContent        = sChargeContent;
                mTB_Charging.Money                = dMoney;
                mTB_Charging.AirConditionFee      = sAirConditionFee;
                mTB_Charging.AirConditionFeeMoney = dAirConditionFeeMoney;
                mTB_Charging.RoomKeyFee           = sRoomKeyFee;
                mTB_Charging.RoomKeyFeeMoney      = dRoomKeyFeeMoney;
                mTB_Charging.OtherFee             = sOtherFee;
                mTB_Charging.OtherFeeMoney        = dOtherFeeMoney;
                mTB_Charging.SiteID               = mTB_EmployeeCheckOut.SiteID;
                mTB_Charging.Creator              = mTB_EmployeeCheckOut.Creator;
                mTB_Charging.BU = mTB_EmployeeCheckOut.BU;
                mChargingBLL.Add(mTB_Charging, _tran);

                //提交事务
                _tran.Commit();
                bSuccess = true;
            }
            catch (Exception ex)
            {
                //回滚事务
                _tran.Rollback();
                throw ex;
            }
            finally
            {
                //关闭连接
                _connection.Close();
            }

            if (bSuccess && bCanLeave)
            {
                SigningExitForEM(-1, mTB_EmployeeCheckOut.EmployeeNo, dSum);
            }
        }
Exemplo n.º 2
0
        private bool CheckOutBatch_part(DataRow rImp)
        {
            var bSuccess  = false;
            var dtCheckIn = _mTB_EmployeeCheckInDAL.GetByWorkID(DataTableHelper.TryGet(rImp, "工号"),
                                                                DataTableHelper.TryGet(rImp, "身份证号码"));

            if (DataTableHelper.IsEmptyDataTable(dtCheckIn))
            {
                return(false);
            }

            bool    bCanLeave = false;
            decimal?dSum      = null;
            var     sWorkID   = string.Empty;

            //启用事务
            using (_tran = _connection.BeginTransaction())
            {
                try
                {
                    var sReason   = DataTableHelper.TryGet(rImp, "退房原因");
                    var sRemark   = DataTableHelper.TryGet(rImp, "备注");
                    var sCanLeave = DataTableHelper.TryGet(rImp, "同步签退离职系统");

                    //添加退房记录
                    var mTB_EmployeeCheckOut = new TB_EmployeeCheckOut();
                    mTB_EmployeeCheckOut.BedID        = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BedID]);
                    mTB_EmployeeCheckOut.BU           = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU].ToString();
                    mTB_EmployeeCheckOut.BUID         = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID]);
                    mTB_EmployeeCheckOut.CardNo       = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo].ToString();
                    mTB_EmployeeCheckOut.CheckInDate  = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate] is DBNull ? DateTime.Now : Convert.ToDateTime(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate]);
                    mTB_EmployeeCheckOut.CheckOutDate = DateTime.Now;
                    mTB_EmployeeCheckOut.Company      = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company].ToString();
                    mTB_EmployeeCheckOut.Creator      = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount;
                    sWorkID = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo].ToString();
                    mTB_EmployeeCheckOut.EmployeeNo = sWorkID;
                    mTB_EmployeeCheckOut.IsSmoking  = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking] is DBNull ? false : Convert.ToBoolean(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking]);
                    mTB_EmployeeCheckOut.Name       = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name].ToString();
                    mTB_EmployeeCheckOut.Province   = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province].ToString();
                    mTB_EmployeeCheckOut.RoomID     = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_RoomID]);
                    mTB_EmployeeCheckOut.Sex        = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex]);
                    mTB_EmployeeCheckOut.SiteID     = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_SiteID]);
                    mTB_EmployeeCheckOut.Telephone  = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone].ToString();
                    mTB_EmployeeCheckOut.Reason     = sReason == "" ? string.Empty : sReason;
                    mTB_EmployeeCheckOut.Remark     = sRemark == "" ? string.Empty : sRemark;
                    bCanLeave = (0 == string.Compare(sCanLeave, "是", true));
                    mTB_EmployeeCheckOut.CanLeave         = bCanLeave ? 1 : 0;
                    mTB_EmployeeCheckOut.EmployeeTypeName = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeTypeName].ToString();

                    //调房--分配到未入住区域
                    //if (sReason.Contains("调房"))
                    //{
                    //    TB_AssignDormArea tB_AssignDormArea = new TB_AssignDormArea();
                    //    tB_AssignDormArea.DormAreaID = Convert.ToInt32(sReason.Split('#')[1]);
                    //    tB_AssignDormArea.CardNo = dtCheckIn.Rows[0]["CardNo"].ToString();
                    //    tB_AssignDormArea.EmployeeNo = dtCheckIn.Rows[0]["EmployeeNo"].ToString();
                    //    tB_AssignDormArea.CreateUser = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount;
                    //    tB_AssignDormArea.CreateDate = System.DateTime.Now;
                    //    new AssignRoomBLL().AssignArea(tB_AssignDormArea);
                    //    sReason = sReason.Split('#')[0];
                    //}

                    _mTB_EmployeeCheckOutDAL.Create(mTB_EmployeeCheckOut, _tran, _db);

                    //更新床位状态
                    _mTB_BedDAL.Update(mTB_EmployeeCheckOut.BedID, _tran, _db, TypeManager.BedStatus.Free);
                    //删除入住信息
                    int intID = (int)dtCheckIn.Rows[0]["ID"];
                    _mTB_EmployeeCheckInDAL.Delete(intID, _tran, _db);

                    //添加扣费记录
                    ChargingBLL mChargingBLL = new ChargingBLL();
                    TB_Charging mTB_Charging = new TB_Charging();
                    mTB_Charging.Name          = mTB_EmployeeCheckOut.Name;
                    mTB_Charging.EmployeeNo    = mTB_EmployeeCheckOut.EmployeeNo;
                    mTB_Charging.ChargeContent = "管理费";
                    decimal num = 0.0M;
                    decimal.TryParse(DataTableHelper.TryGet(rImp, "管理费"), out num);
                    mTB_Charging.Money = num;

                    mTB_Charging.AirConditionFee = "空调费";
                    num = 0.0M;
                    decimal.TryParse(DataTableHelper.TryGet(rImp, "空调费"), out num);
                    mTB_Charging.AirConditionFeeMoney = num;

                    mTB_Charging.RoomKeyFee = "钥匙费";
                    num = 0.0M;
                    decimal.TryParse(DataTableHelper.TryGet(rImp, "钥匙费"), out num);
                    mTB_Charging.RoomKeyFeeMoney = num;

                    mTB_Charging.OtherFee = "其他费";
                    num = 0.0M;
                    decimal.TryParse(DataTableHelper.TryGet(rImp, "其他费"), out num);
                    mTB_Charging.OtherFeeMoney = num;
                    mTB_Charging.SiteID        = mTB_EmployeeCheckOut.SiteID;
                    mTB_Charging.Creator       = mTB_EmployeeCheckOut.Creator;
                    mTB_Charging.BU            = mTB_EmployeeCheckOut.BU;
                    mChargingBLL.Add(mTB_Charging, _tran);

                    dSum = mTB_Charging.Money + mTB_Charging.AirConditionFeeMoney
                           + mTB_Charging.RoomKeyFeeMoney + mTB_Charging.OtherFeeMoney; //总扣费

                    //提交事务
                    _tran.Commit();
                    bSuccess = true;
                }
                catch (Exception ex)
                {
                    //回滚事务
                    _tran.Rollback();
                    //throw ex;
                    LogManager.GetInstance().ErrorLog("批量退房失败CheckOutBatch_part", ex);
                }
            }

            if (bSuccess && bCanLeave)
            {
                SigningExitForEM(-1, sWorkID, dSum);
            }
            return(bSuccess);
        }