/// <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(); } }
/// <summary> /// 房间分配 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> public bool AssignRoom(TB_EmployeeCheckIn tb_EmployeeCheckIn) { //启用事务 var bAssign = true; _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //更新床位状态为已分配未入住(已修改分配且入住) _mTB_BedDAL.Update(tb_EmployeeCheckIn.BedID, _tran, _db, TypeManager.BedStatus.Busy); //添加入住记录,注意现在的入住记录是无效的(已修改未一键分配,入住记录有效) _mTB_EmployeeCheckInDAL.Create(tb_EmployeeCheckIn, _tran, _db); //删除分配信息 _mTB_BedDAL.DeleteAssignDormArea(tb_EmployeeCheckIn.CardNo, _tran, _db); //提交事务 _tran.Commit(); } catch (Exception ex) { //回滚事务 bAssign = false; _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } return(bAssign); }
/// <summary> /// 调房---退房记录 /// </summary> /// <param name="intID"></param> public void AddCheckOut(int intID) { DataTable dtCheckIn = null; //入住信息 TB_EmployeeCheckOut mTB_EmployeeCheckOut = null; //退房记录 //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); try { dtCheckIn = _mTB_EmployeeCheckInDAL.Get(intID); //添加退房记录 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 = "换房"; mTB_EmployeeCheckOut.Remark = "换房产生"; mTB_EmployeeCheckOut.EmployeeTypeName = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeTypeName].ToString(); _mTB_EmployeeCheckOutDAL.Create(mTB_EmployeeCheckOut); //提交事务 } catch (Exception ex) { //回滚事务 _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } }
/// <summary> /// 更新用户信息 /// </summary> /// <param name="tb_User"></param> /// <param name="lstDormAreaID"></param> private void Update(TB_User tb_User, List <int> lstDormAreaID) { TB_UserConnectDormArea mTB_UserConnectDormArea = null; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //更新用户信息 _mTB_UserDAL.Edit(tb_User, _tran, _db); //删除用户关联宿舍区信息 _mTB_UserConnectDormAreaDAL.Delete(tb_User.ID, _tran, _db); //添加用户关联宿舍区信息 foreach (var item in lstDormAreaID) { mTB_UserConnectDormArea = new TB_UserConnectDormArea() { UserID = tb_User.ID, DormAreaID = item, }; _mTB_UserConnectDormAreaDAL.Create(mTB_UserConnectDormArea, _tran, _db); } //提交事务 _tran.Commit(); } catch { //回滚事务 _tran.Rollback(); } finally { //关闭连接 _connection.Close(); } }
/// <summary> /// 添加用户信息 /// </summary> /// <param name="tb_User"></param> /// <param name="lstDormAreaID"></param> /// <returns></returns> private int Add(TB_User tb_User, List <int> lstDormAreaID) { TB_UserConnectDormArea mTB_UserConnectDormArea = null; int intUserID = 0; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //添加用户信息 intUserID = _mTB_UserDAL.Create(tb_User, _tran, _db); //添加用户关联宿舍区信息 foreach (var item in lstDormAreaID) { mTB_UserConnectDormArea = new TB_UserConnectDormArea() { UserID = intUserID, DormAreaID = item, }; _mTB_UserConnectDormAreaDAL.Create(mTB_UserConnectDormArea, _tran, _db); } //提交事务 _tran.Commit(); } catch { //回滚事务 _tran.Rollback(); } finally { //关闭连接 _connection.Close(); } return(intUserID); }
/// <summary> /// 更新角色信息 /// </summary> /// <param name="tb_Role"></param> /// <param name="lstModuleID"></param> private void Update(TB_Role tb_Role, List <int> lstModuleID) { TB_RoleConnectModule mTB_RoleConnectModule = null; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //更新角色信息 _mTB_RoleDAL.Edit(tb_Role, _tran, _db); //删除角色关联模块信息 _mTB_RoleConnectModuleDAL.Delete(tb_Role.ID, _tran, _db); //添加角色关联模块信息 foreach (var item in lstModuleID) { mTB_RoleConnectModule = new TB_RoleConnectModule() { RoleID = tb_Role.ID, ModuleID = item, }; _mTB_RoleConnectModuleDAL.Create(mTB_RoleConnectModule, _tran, _db); } //提交事务 _tran.Commit(); } catch { //回滚事务 _tran.Rollback(); } finally { //关闭连接 _connection.Close(); } }
/// <summary> /// 添加角色信息 /// </summary> /// <param name="tb_Role"></param> /// <param name="lstModuleID"></param> /// <returns></returns> private int Add(TB_Role tb_Role, List <int> lstModuleID) { TB_RoleConnectModule mTB_RoleConnectModule = null; int intRoleID = 0; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //添加角色信息 intRoleID = _mTB_RoleDAL.Create(tb_Role, _tran, _db); //添加角色关联模块信息 foreach (var item in lstModuleID) { mTB_RoleConnectModule = new TB_RoleConnectModule() { RoleID = intRoleID, ModuleID = item, }; _mTB_RoleConnectModuleDAL.Create(mTB_RoleConnectModule, _tran, _db); } //提交事务 _tran.Commit(); } catch { //回滚事务 _tran.Rollback(); } finally { //关闭连接 _connection.Close(); } return(intRoleID); }
//更改退宿原因 public bool ChangeCheckOutReason(int id, string sTotal) { string[] sData = sTotal.Split('@'); var sReason = sData[0]; var bCanLeave = Convert.ToInt32(sData[1]) > 0; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); var bSuccess = false; try { _mTB_EmployeeCheckOutDAL.ChangeCheckOutReason(id, sReason, bCanLeave, _tran, _db); //提交事务 _tran.Commit(); bSuccess = true; } catch (Exception ex) { //回滚事务 _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } if (bSuccess && bCanLeave) { SigningExitForEM(id); } return(bSuccess); }
/// <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); } }
/// <summary> /// 员工换房 /// </summary> /// <param name="intID">需要换房的员工ID</param> /// <param name="intBedID">新换的床位ID</param> public void ChangeRoom(int intID, int intBedID) { TB_EmployeeCheckIn mTB_EmployeeCheckIn = null; TB_ChangeRoomRecord mTB_ChangeRoomRecord = null; string operatorUser = SessionHelper.Get(HttpContext.Current, TypeManager.User) != null ? ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount : ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account; int intOldBedID = 0; TB_Bed mTB_Bed = null; //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { mTB_EmployeeCheckIn = this.ConvertTableToList(_mTB_EmployeeCheckInDAL.Get(intID)).FirstOrDefault(); mTB_Bed = _mTB_BedDAL.Get(intBedID); intOldBedID = mTB_EmployeeCheckIn.BedID; TB_Bed mOldTB_Bed = _mTB_BedDAL.Get(intOldBedID); //更新床位状态为入住 _mTB_BedDAL.Update(intBedID, _tran, _db, TypeManager.BedStatus.Busy); //更新床位状态为空闲 _mTB_BedDAL.Update(intOldBedID, _tran, _db, TypeManager.BedStatus.Free); //添加换房记录 mTB_ChangeRoomRecord = new TB_ChangeRoomRecord(); mTB_ChangeRoomRecord.BU = mTB_EmployeeCheckIn.BU; mTB_ChangeRoomRecord.BUID = mTB_EmployeeCheckIn.BUID; //new add buid 2015-02-07 mTB_ChangeRoomRecord.CardNo = mTB_EmployeeCheckIn.CardNo; mTB_ChangeRoomRecord.ChangeRoomDate = DateTime.Now; mTB_ChangeRoomRecord.CheckInDate = mTB_EmployeeCheckIn.CheckInDate; mTB_ChangeRoomRecord.Company = mTB_EmployeeCheckIn.Company; mTB_ChangeRoomRecord.Creator = operatorUser; mTB_ChangeRoomRecord.EmployeeNo = mTB_EmployeeCheckIn.EmployeeNo; mTB_ChangeRoomRecord.IsSmoking = mTB_EmployeeCheckIn.IsSmoking; mTB_ChangeRoomRecord.Name = mTB_EmployeeCheckIn.Name; mTB_ChangeRoomRecord.NewBedID = intBedID; mTB_ChangeRoomRecord.OldBedID = mTB_EmployeeCheckIn.BedID; mTB_ChangeRoomRecord.Province = mTB_EmployeeCheckIn.Province; mTB_ChangeRoomRecord.Sex = mTB_EmployeeCheckIn.Sex; mTB_ChangeRoomRecord.SiteID = mTB_EmployeeCheckIn.SiteID; mTB_ChangeRoomRecord.Telephone = mTB_EmployeeCheckIn.Telephone; mTB_ChangeRoomRecord.EmployeeTypeName = mTB_EmployeeCheckIn.EmployeeTypeName; _mTB_ChangeRoomRecordDAL.Create(mTB_ChangeRoomRecord, _tran, _db); if (mTB_Bed.BuildingID != mOldTB_Bed.BuildingID)//不是一栋的增加退宿记录 { //增加退宿记录 AddCheckOut(intID); } //更新入住人员信息 mTB_EmployeeCheckIn.BedID = intBedID; mTB_EmployeeCheckIn.RoomID = mTB_Bed.RoomID; mTB_EmployeeCheckIn.UpdateBy = operatorUser; mTB_EmployeeCheckIn.CheckInDate = DateTime.Now; _mTB_EmployeeCheckInDAL.Edit(mTB_EmployeeCheckIn, _tran, _db); //提交事务 _tran.Commit(); } catch (Exception ex) { //回滚事务 _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } }
//访问离职系统,进行签退 private int SigningExitForEM(int id, string workID = "", decimal?cost = null) { var sWorkID = workID; DbConnection dbConn = null; if (string.IsNullOrEmpty(sWorkID)) { try {// get checkout Employee No var dbDorm = DBO.CreateDatabase(); dbConn = dbDorm.CreateConnection(); dbConn.Open(); string strSQL = @"select RoomID,BedID,EmployeeNo,Name,CardNo from TB_EmployeeCheckOut where id=@ID"; var dbCommandWrapper = dbDorm.DbProviderFactory.CreateCommand(); dbCommandWrapper.CommandType = CommandType.Text; dbCommandWrapper.CommandText = strSQL; dbDorm.AddInParameter(dbCommandWrapper, "@ID", DbType.Int32, id); var ds = dbDorm.ExecuteDataSet(dbCommandWrapper); if (DataTableHelper.IsEmptyDataSet(ds)) { return(-1); } var dr = DataTableHelper.GetDataSet_Row0(ds); sWorkID = dr["EmployeeNo"] as string; } catch (Exception ex) { } finally { dbConn.Close(); } } if (string.IsNullOrEmpty(sWorkID)) { return(-1); } //update DbTransaction dbTran = null; try { string sAppGroupID = "097F36B9-B8A2-478B-97DA-79E76E384571"; var dbEM = DBO.CreateDatabaseEM(); dbConn = dbEM.CreateConnection(); dbConn.Open(); dbTran = dbConn.BeginTransaction(); var strSQL = string.Empty; int nRet = 0; var sCreateUser = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).EName; //create EM_Approved if (null != cost && cost.HasValue) { strSQL = @"insert into EM_Approved([Approved_ID],[FormID],[ApprovalGroupID],[EmpID],[Cost],[Balance], [DeleteMark],[Remark],[CreateDate],[CreateUserId],[CreateUserName]) select [Approving_ID],[FormID],[ApprovalGroupID],[EmpID],@Cost,[Balance], [DeleteMark],'宿舍系统自动签退',GetDate(),NULL,@CreateUserName from EM_Approving where ApprovalGroupID=@AppGroupID and EmpID=@EmpID "; } else { strSQL = @"insert into EM_Approved([Approved_ID],[FormID],[ApprovalGroupID],[EmpID],[Cost],[Balance], [DeleteMark],[Remark],[CreateDate],[CreateUserId],[CreateUserName]) select [Approving_ID],[FormID],[ApprovalGroupID],[EmpID],[Cost],[Balance], [DeleteMark],'宿舍系统自动签退',GetDate(),NULL,@CreateUserName from EM_Approving where ApprovalGroupID=@AppGroupID and EmpID=@EmpID "; } var dbCommandWrapper = dbEM.DbProviderFactory.CreateCommand(); dbCommandWrapper.CommandType = CommandType.Text; dbCommandWrapper.CommandText = strSQL; dbEM.AddInParameter(dbCommandWrapper, "@CreateUserName", DbType.String, sCreateUser); dbEM.AddInParameter(dbCommandWrapper, "@AppGroupID", DbType.String, sAppGroupID); dbEM.AddInParameter(dbCommandWrapper, "@EmpID", DbType.String, sWorkID); if (null != cost && cost.HasValue) { dbEM.AddInParameter(dbCommandWrapper, "@Cost", DbType.Decimal, cost.Value); } nRet = dbEM.ExecuteNonQuery(dbCommandWrapper, dbTran); //delete EM_Approving strSQL = @"delete from EM_Approving where 1 = 1 and ApprovalGroupID = @AppGroupID and EmpID = @EmpID"; dbCommandWrapper = dbEM.DbProviderFactory.CreateCommand(); dbCommandWrapper.CommandType = CommandType.Text; dbCommandWrapper.CommandText = strSQL; dbEM.AddInParameter(dbCommandWrapper, "@AppGroupID", DbType.String, sAppGroupID); dbEM.AddInParameter(dbCommandWrapper, "@EmpID", DbType.String, sWorkID); nRet = dbEM.ExecuteNonQuery(dbCommandWrapper, dbTran); dbTran.Commit(); } catch (Exception ex) { dbTran.Rollback(); throw ex; } finally { dbConn.Close(); } return(0); }
/// <summary> /// 通过上传excel批量退房 /// 不支持换房 /// </summary> public bool CheckOutBatch(string filePath, out int nSuccess, out DataTable dtErr) { nSuccess = 0; dtErr = null; //读取Excel内容 DataTable dt = _mExcelHelper.GetDataFromExcel(filePath); if (DataTableHelper.IsEmptyDataTable(dt)) { LogManager.GetInstance().ErrorLog("CheckOutBatch,导入的excel表记录为空"); return(false); } int nTotalCnt = dt.Rows.Count; //全部待导入的个数 dtErr = dt.Clone(); var lstDel = new List <DataRow>(); try { foreach (DataRow r in dt.Rows) { var sWorkID = r["工号"].ToString().Trim(); var sIDCardNo = r["身份证号码"].ToString().Trim(); var sReason = r["退房原因"].ToString().Trim(); //排除明显无效的项 var bValid = true; if (string.IsNullOrEmpty(sWorkID) && string.IsNullOrEmpty(sIDCardNo)) { bValid = false; } bValid = bValid && IsValidReason(sReason); if (!bValid) { DataTableHelper.CopyDataRow(dtErr, r); lstDel.Add(r); } } } catch (Exception ex) { LogManager.GetInstance().ErrorLog("CheckOutBatch,关键列不存在", ex); return(false); } foreach (var oDel in lstDel) { dt.Rows.Remove(oDel); } _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); try { foreach (DataRow rImp in dt.Rows) { if (!CheckOutBatch_part(rImp)) { DataTableHelper.CopyDataRow(dtErr, rImp); } else { nSuccess++; } } } finally { _connection.Close(); } return(nSuccess == nTotalCnt); }