Example #1
0
 /// <summary>
 /// 取消入住
 /// </summary>
 /// <param name="intID"></param>
 /// <param name="intBedID"></param>
 /// <param name="intEmployeeCheckInID"></param>
 public void CancelCheckIn(int intID, int intBedID, int intEmployeeCheckInID)
 {
     //启用事务
     _db         = DBO.CreateDatabase();
     _connection = _db.CreateConnection();
     _connection.Open();
     _tran = _connection.BeginTransaction();
     try
     {
         //更新床位状态为空闲
         _mTB_BedDAL.Update(intBedID, _tran, _db, TypeManager.BedStatus.Free);
         //删除入住记录
         _mTB_EmployeeCheckInDAL.Delete(intEmployeeCheckInID, _tran, _db);
         //删除分配记录
         _mTB_AssignRoomDAL.Delete(intID, _tran, _db);
         //提交事务
         _tran.Commit();
     }
     catch (Exception ex)
     {
         //回滚事务
         _tran.Rollback();
         throw ex;
     }
     finally
     {
         //关闭连接
         _connection.Close();
     }
 }
Example #2
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);
            }
        }