/// <summary> /// 将datatable转换成list对象 /// </summary> /// <param name="dt"></param> /// <returns></returns> private List <TB_EmployeeCheckIn> ConvertTableToList(DataTable dtCheckIn) { TB_EmployeeCheckIn mTB_EmployeeCheckIn = null; List <TB_EmployeeCheckIn> lstTB_EmployeeCheckIn = new List <TB_EmployeeCheckIn>(); for (int i = 0; i < dtCheckIn.Rows.Count; i++) { mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); mTB_EmployeeCheckIn.ID = Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_ID]); mTB_EmployeeCheckIn.RoomID = Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_RoomID]); mTB_EmployeeCheckIn.BedID = Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_BedID]); mTB_EmployeeCheckIn.BU = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_BU] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_BU].ToString(); mTB_EmployeeCheckIn.BUID = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_BUID] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_BUID]); mTB_EmployeeCheckIn.CardNo = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_CardNo] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_CardNo].ToString(); mTB_EmployeeCheckIn.CheckInDate = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_CheckInDate] is DBNull ? DateTime.Now : Convert.ToDateTime(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_CheckInDate]); mTB_EmployeeCheckIn.Company = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Company] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Company].ToString(); mTB_EmployeeCheckIn.Creator = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Creator].ToString(); mTB_EmployeeCheckIn.EmployeeNo = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_EmployeeNo] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_EmployeeNo].ToString(); mTB_EmployeeCheckIn.IsSmoking = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_IsSmoking] is DBNull ? false : Convert.ToBoolean(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_IsSmoking]); mTB_EmployeeCheckIn.Name = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Name] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Name].ToString(); mTB_EmployeeCheckIn.Province = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Province] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Province].ToString(); mTB_EmployeeCheckIn.CreateDate = Convert.ToDateTime(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_CreateDate]); mTB_EmployeeCheckIn.Sex = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Sex] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Sex]); mTB_EmployeeCheckIn.SiteID = Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_SiteID]); mTB_EmployeeCheckIn.Telephone = dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Telephone] is DBNull ? string.Empty : dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_Telephone].ToString(); mTB_EmployeeCheckIn.IsActive = Convert.ToInt32(dtCheckIn.Rows[i][TB_EmployeeCheckIn.col_IsActive]); mTB_EmployeeCheckIn.EmployeeTypeName = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeTypeName].ToString(); lstTB_EmployeeCheckIn.Add(mTB_EmployeeCheckIn); } return(lstTB_EmployeeCheckIn); }
/// <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="sender"></param> /// <param name="e"></param> protected void btnExport_Click(object sender, EventArgs e) { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); EmployeeCheckInBLL mEmployeeCheckInBLL = new EmployeeCheckInBLL(); mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.EmployeeNo = this.txtWorkDayNo.Text.Trim(); mTB_EmployeeCheckIn.Name = this.txtName.Text.Trim(); mTB_EmployeeCheckIn.CardNo = this.txtScanCardNO.Text.Trim(); mTB_EmployeeCheckIn.BUID = Convert.ToInt32(Request.Form[this.ddlBuildingName.UniqueID.ToString()]); mTB_EmployeeCheckIn.BU = GetSelectedBu();//this.txtBu.Text.Trim(); mTB_EmployeeCheckIn.Telephone = this.txtMobile.Text.Trim(); DateTime dtVal = DateTime.Now; if (DateTime.TryParse(this.txtStartDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateBegin = dtVal; } if (DateTime.TryParse(this.txtEndDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateEnd = dtVal; } int iDormAreaID = Convert.ToInt32(this.ddlDormArea.SelectedValue); int iRoomTypeID = Convert.ToInt32(this.ddlRoomType.SelectedValue); string sRoomName = Convert.ToString(this.txtRoom.Text); string strFileName = mEmployeeCheckInBLL.Export(mTB_EmployeeCheckIn, iDormAreaID, iRoomTypeID, sRoomName); this.DownLoadFile(this.Request, this.Response, "入住记录.xls", File.ReadAllBytes(strFileName), 10240000); //File.Delete(strFileName); }
private void Bind(int intCurrentIndex) { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); EmployeeCheckInBLL mEmployeeCheckInBLL = new EmployeeCheckInBLL(); Pager pager = new Pager(); DataTable dtSource = null; pager.CurrentPageIndex = intCurrentIndex; pager.srcOrder = " ID desc"; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.CardNo = this.txtScanCardNO.Text.Trim(); mTB_EmployeeCheckIn.Name = this.txtName.Text.Trim(); mTB_EmployeeCheckIn.EmployeeNo = this.txtWorkDayNo.Text.Trim(); DateTime dtVal = DateTime.Now; if (DateTime.TryParse(this.txtStartDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateBegin = dtVal; } if (DateTime.TryParse(this.txtEndDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateEnd = dtVal; } dtSource = mEmployeeCheckInBLL.GetPagerData(mTB_EmployeeCheckIn, ref pager); GridView1.DataSource = dtSource; GridView1.DataBind(); this.Pager1.ItemCount = pager.TotalRecord; this.Pager1.PageCount = pager.TotalPage; this.Pager1.CurrentIndex = pager.CurrentPageIndex; this.Pager1.PageSize = pager.PageSize; }
/// <summary> /// 添加 /// </summary> /// <param name="info"></param> /// <returns></returns> public int Create(TB_EmployeeCheckIn info) { try { Database db = DBO.CreateDatabase(); return(this.Create(info, (DbTransaction)null, db)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 导出 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> /// <returns></returns> public string Export(TB_EmployeeCheckIn tb_EmployeeCheckIn, int iDormAreaID, int iRoomTypeID, string sRoomName) { DataTable dt = _mTB_EmployeeCheckInDAL.GetTable(tb_EmployeeCheckIn, iDormAreaID, iRoomTypeID, sRoomName); dt.Columns.Remove("楼层"); dt.Columns.Remove("单元"); string strFilePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("..\\..\\"), "Report"); if (!Directory.Exists(strFilePath)) { Directory.CreateDirectory(strFilePath); } string strFileName = Path.Combine(strFilePath, DateTime.Now.ToString("yyMMddHHmmssms_") + "入住记录.xls"); _mExcelHelper.RenderToExcel(dt, strFileName); return(strFileName); }
/// <summary> /// 更新 /// </summary> /// <param name="info"></param> /// <param name="tran"></param> /// <param name="db"></param> /// <returns></returns> public int EditTB_EmployeeCheckIn(TB_EmployeeCheckIn info) { Database db = DBO.CreateDatabase(); DbCommand dbCommandWrapper = null; string strUpdateSql = @"UPDATE TB_EmployeeCheckIn SET [EmployeeNo]=@EmployeeNo ,[BU]=@BU ,[Telephone]=@Telephone ,[CheckInDate]=@CheckInDate ,[UpdateBy]=@UpdateBy ,[UpdateDate]=@UpdateDate ,EmployeeTypeName=@EmployeeTypeName WHERE ID=@ID"; try { dbCommandWrapper = db.GetSqlStringCommand(strUpdateSql); #region Add parameters db.AddInParameter(dbCommandWrapper, "@ID", DbType.Int32, info.ID); db.AddInParameter(dbCommandWrapper, "@EmployeeNo", DbType.String, info.EmployeeNo); db.AddInParameter(dbCommandWrapper, "@BU", DbType.String, info.BU); db.AddInParameter(dbCommandWrapper, "@CardNo", DbType.String, info.CardNo); db.AddInParameter(dbCommandWrapper, "@Telephone", DbType.String, info.Telephone); db.AddInParameter(dbCommandWrapper, "@CheckInDate", DbType.DateTime, info.CheckInDate); db.AddInParameter(dbCommandWrapper, "@UpdateBy", DbType.String, info.UpdateBy); db.AddInParameter(dbCommandWrapper, "@UpdateDate", DbType.DateTime, DateTime.Now); db.AddInParameter(dbCommandWrapper, "@EmployeeTypeName", DbType.String, info.EmployeeTypeName); #endregion return(db.ExecuteNonQuery(dbCommandWrapper)); } catch (Exception ex) { throw ex; } finally { if (dbCommandWrapper != null) { dbCommandWrapper.Dispose(); dbCommandWrapper = null; } } }
private void Bind(int intCurrentIndex) { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); EmployeeCheckInBLL mEmployeeCheckInBLL = new EmployeeCheckInBLL(); Pager pager = new Pager(); DataTable dtSource = null; pager.CurrentPageIndex = intCurrentIndex; pager.srcOrder = " ID desc"; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.EmployeeNo = this.txtWorkDayNo.Text.Trim(); mTB_EmployeeCheckIn.Name = this.txtName.Text.Trim(); mTB_EmployeeCheckIn.CardNo = this.txtScanCardNO.Text.Trim(); mTB_EmployeeCheckIn.BUID = Convert.ToInt32(Request.Form[this.ddlBuildingName.UniqueID.ToString()]); mTB_EmployeeCheckIn.BU = GetSelectedBu(); //this.txtBu.Text.Trim(); mTB_EmployeeCheckIn.Telephone = this.txtMobile.Text.Trim(); DateTime dtVal = DateTime.Now; if (DateTime.TryParse(this.txtStartDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateBegin = dtVal; } if (DateTime.TryParse(this.txtEndDay.Text.Trim(), out dtVal)) { mTB_EmployeeCheckIn.CheckInDateEnd = dtVal; } int iDormAreaID = Convert.ToInt32(this.ddlDormArea.SelectedValue); int iRoomTypeID = Convert.ToInt32(this.ddlRoomType.SelectedValue); string sRoomName = Convert.ToString(this.txtRoom.Text); dtSource = mEmployeeCheckInBLL.GetPagerData(mTB_EmployeeCheckIn, iDormAreaID, iRoomTypeID, sRoomName, ref pager); GridView1.DataSource = dtSource; GridView1.DataBind(); this.Pager1.ItemCount = pager.TotalRecord; this.Pager1.PageCount = pager.TotalPage; this.Pager1.CurrentIndex = pager.CurrentPageIndex; this.Pager1.PageSize = pager.PageSize; }
protected void btnSave_Click(object sender, EventArgs e) { try { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); EmployeeCheckInBLL mEmployeeCheckInBLL = new EmployeeCheckInBLL(); mTB_EmployeeCheckIn.ID = Convert.ToInt32(Request.QueryString["id"].ToString()); mTB_EmployeeCheckIn.EmployeeNo = txtEmployeeNo.Text.Trim(); mTB_EmployeeCheckIn.BU = txtBU.Text; mTB_EmployeeCheckIn.EmployeeTypeName = txtEmployeeType.Text; mTB_EmployeeCheckIn.CheckInDate = Convert.ToDateTime(txtCheckinDate.Text); mTB_EmployeeCheckIn.Telephone = txtPhone.Text; mEmployeeCheckInBLL.EditTB_EmployeeCheckIn(mTB_EmployeeCheckIn); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>saveComplete();</script>"); } catch (Exception ex) { LogManager.GetInstance().ErrorLog(ex.Message); } }
/// <summary> /// 事务更新 /// </summary> /// <param name="info"></param> /// <param name="tran"></param> /// <param name="db"></param> /// <returns></returns> public int Edit(TB_EmployeeCheckIn info, DbTransaction tran, Database db) { DbCommand dbCommandWrapper = null; string strUpdateSql = @"UPDATE TB_EmployeeCheckIn SET [RoomID]=@RoomID ,[BedID]=@BedID ,[EmployeeNo]=@EmployeeNo ,[Name]=@Name ,[Sex]=@Sex ,[BUID]=@BUID ,[BU]=@BU ,[Company]=@Company ,[CardNo]=@CardNo ,[Telephone]=@Telephone ,[Province]=@Province ,[IsSmoking]=@IsSmoking ,[CheckInDate]=@CheckInDate ,[UpdateBy]=@UpdateBy ,[UpdateDate]=@UpdateDate WHERE ID=@ID"; try { dbCommandWrapper = db.GetSqlStringCommand(strUpdateSql); #region Add parameters db.AddInParameter(dbCommandWrapper, "@ID", DbType.Int32, info.ID); db.AddInParameter(dbCommandWrapper, "@RoomID", DbType.Int32, info.RoomID); db.AddInParameter(dbCommandWrapper, "@BedID", DbType.Int32, info.BedID); db.AddInParameter(dbCommandWrapper, "@EmployeeNo", DbType.String, info.EmployeeNo); db.AddInParameter(dbCommandWrapper, "@Name", DbType.String, info.Name); db.AddInParameter(dbCommandWrapper, "@Sex", DbType.Int32, info.Sex); db.AddInParameter(dbCommandWrapper, "@BUID", DbType.Int32, info.BUID); db.AddInParameter(dbCommandWrapper, "@BU", DbType.String, info.BU); db.AddInParameter(dbCommandWrapper, "@Company", DbType.String, info.Company); db.AddInParameter(dbCommandWrapper, "@CardNo", DbType.String, info.CardNo); db.AddInParameter(dbCommandWrapper, "@Telephone", DbType.String, info.Telephone); db.AddInParameter(dbCommandWrapper, "@Province", DbType.String, info.Province); db.AddInParameter(dbCommandWrapper, "@IsSmoking", DbType.Boolean, info.IsSmoking); db.AddInParameter(dbCommandWrapper, "@CheckInDate", DbType.DateTime, info.CheckInDate); db.AddInParameter(dbCommandWrapper, "@UpdateBy", DbType.String, info.UpdateBy); db.AddInParameter(dbCommandWrapper, "@UpdateDate", DbType.DateTime, DateTime.Now); #endregion if (tran == null) { return(db.ExecuteNonQuery(dbCommandWrapper)); } else { return(db.ExecuteNonQuery(dbCommandWrapper, tran)); } } catch (Exception ex) { throw ex; } finally { if (dbCommandWrapper != null) { dbCommandWrapper.Dispose(); dbCommandWrapper = null; } } }
//分配 protected void btnAssign_Click(object sender, EventArgs e) { try { //获取选中的ID string bagID = selbagID.Value; //查询room信息 DataTable dt = ViewState["dtFreeRoom"] as DataTable; DataRow[] drAssignRoomArr = dt.Select("ID=" + bagID + ""); var drAssign = drAssignRoomArr[0]; var sIdCard = this.txtScanCardNO.Text.Trim(); var sName = this.txtScanName.Text.Trim(); if (!Util.IsValidIDCard(sIdCard)) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('不是有效的中国身份证!')", true); return; } if (string.IsNullOrEmpty(sIdCard) || string.IsNullOrEmpty(sName)) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('姓名应当提供!')", true); return; } //查询人员信息 var sSex = Util.IsIDCardMan(sIdCard) > 0 ? "男" : "女"; if (sSex != drAssign["RoomSexType"].ToString()) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('身份证的性别与房间的性别不匹配,不能分配!')", true); return; } string sDormAreaName = drAssign["DormAreaName"].ToString(); string sBuildingName = drAssign["BuildingName"].ToString(); string sRoomName = drAssign["RoomName"].ToString(); string sBedName = drAssign["Name"].ToString(); //检查是否已经有CheckIn的记录 DataTable DtCheckIDCard = new AssignRoomBLL().GetAssignedData(sIdCard, ""); if (DtCheckIDCard != null && DtCheckIDCard.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('此用户已有分配记录!')", true); return; } else { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); mTB_EmployeeCheckIn.RoomID = Convert.ToInt32(drAssign["RoomID"]); mTB_EmployeeCheckIn.BedID = int.Parse(drAssign["ID"].ToString()); mTB_EmployeeCheckIn.BU = string.Empty; //TODO 2018-02-07 //由于 EHR.[Segment] 的ID 与 DormManage.[TB_BU]根本不对应 //因此,换房记录无法导出事业部 mTB_EmployeeCheckIn.BUID = 0; mTB_EmployeeCheckIn.CardNo = sIdCard; mTB_EmployeeCheckIn.CheckInDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); mTB_EmployeeCheckIn.Company = string.Empty; mTB_EmployeeCheckIn.EmployeeNo = string.Empty; mTB_EmployeeCheckIn.Name = sName; mTB_EmployeeCheckIn.Sex = drAssign["RoomSexType"].ToString() == "男" ? 1 : 2; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.Creator = (base.UserInfo == null ? base.SystemAdminInfo.Account : base.UserInfo.ADAccount); mTB_EmployeeCheckIn.IsActive = (int)TypeManager.IsActive.Valid; mTB_EmployeeCheckIn.Telephone = string.Empty; mTB_EmployeeCheckIn.EmployeeTypeName = string.Empty; var bAssign = new AssignRoomBLL().AssignRoom(mTB_EmployeeCheckIn); if (!bAssign) { var msg = "分配房间失败,请重新分配"; ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + msg + "')", true); return; } ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('分配成功!')", true); ClearControl(); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + ex.Message + "')", true); } }
/// <summary> /// 事务添加 /// </summary> /// <param name="info"></param> /// <param name="tran"></param> /// <param name="db"></param> /// <returns></returns> public int Create(TB_EmployeeCheckIn info, DbTransaction tran, Database db) { DbCommand dbCommandWrapper = null; int intId; string strInsertSql = @"INSERT INTO TB_EmployeeCheckIn ([RoomID] ,[BedID] ,[EmployeeNo] ,[Name] ,[Sex] ,[BUID] ,[BU] ,[Company] ,[CardNo] ,[Telephone] ,[Province] ,[IsSmoking] ,[CheckInDate] ,[Creator] ,[SiteID] ,[IsActive] ,EmployeeTypeName ) VALUES(@RoomID ,@BedID ,@EmployeeNo ,@Name ,@Sex ,@BUID ,@BU ,@Company ,@CardNo ,@Telephone ,@Province ,@IsSmoking ,@CheckInDate ,@Creator ,@SiteID ,@IsActive ,@EmployeeTypeName)"; string strSelectIdSql = ";SELECT SCOPE_IDENTITY()"; try { dbCommandWrapper = db.GetSqlStringCommand(strInsertSql + strSelectIdSql); #region Add parameters db.AddInParameter(dbCommandWrapper, "@RoomID", DbType.Int32, info.RoomID); db.AddInParameter(dbCommandWrapper, "@BedID", DbType.Int32, info.BedID); db.AddInParameter(dbCommandWrapper, "@EmployeeNo", DbType.String, info.EmployeeNo); db.AddInParameter(dbCommandWrapper, "@Name", DbType.String, info.Name); db.AddInParameter(dbCommandWrapper, "@Sex", DbType.Int32, info.Sex); db.AddInParameter(dbCommandWrapper, "@BUID", DbType.Int32, info.BUID); db.AddInParameter(dbCommandWrapper, "@BU", DbType.String, info.BU); db.AddInParameter(dbCommandWrapper, "@Company", DbType.String, info.Company); db.AddInParameter(dbCommandWrapper, "@CardNo", DbType.String, info.CardNo); db.AddInParameter(dbCommandWrapper, "@Telephone", DbType.String, info.Telephone); db.AddInParameter(dbCommandWrapper, "@Province", DbType.String, info.Province); db.AddInParameter(dbCommandWrapper, "@IsSmoking", DbType.Boolean, info.IsSmoking); db.AddInParameter(dbCommandWrapper, "@CheckInDate", DbType.DateTime, info.CheckInDate); db.AddInParameter(dbCommandWrapper, "@Creator", DbType.String, info.Creator); db.AddInParameter(dbCommandWrapper, "@SiteID", DbType.Int32, info.SiteID); db.AddInParameter(dbCommandWrapper, "@IsActive", DbType.Int32, info.IsActive); db.AddInParameter(dbCommandWrapper, "@EmployeeTypeName", DbType.String, info.EmployeeTypeName); #endregion if (tran == null) { intId = Convert.ToInt32(db.ExecuteScalar(dbCommandWrapper)); } else { intId = Convert.ToInt32(db.ExecuteScalar(dbCommandWrapper, tran)); } return(intId); } catch (Exception ex) { throw ex; } finally { if (dbCommandWrapper != null) { dbCommandWrapper.Dispose(); dbCommandWrapper = null; } } }
/// <summary> /// 查询入住记录, 用来进行excel导出的 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> /// <returns></returns> public DataTable GetTable(TB_EmployeeCheckIn tb_EmployeeCheckIn, int iDormAreaID, int iRoomTypeID, string sRoomName) { DataTable dt = null; DbCommand dbCommandWrapper = null; try { StringBuilder strBuilder = new StringBuilder(@" SELECT A.[EmployeeNo] '工号' ,A.[Name] '姓名' ,A.BU '事业部' ,A.EmployeeTypeName '用工类型' ,A.[Company] '公司' ,A.[CardNo] '身份证号码' ,A.[Telephone] '手机号码' ,Convert(varchar(12),A.[CheckInDate],111) as '入住日期' ,G.Name As '宿舍区' ,F.Name As '楼栋' ,E.Name As '单元' ,D.Name As '楼层' ,C.Name AS '房间号' ,B.Name AS '床位号' ,JJ.Name 房间类型 ,'' AS '扣费内容' ,'' AS '扣费金额' FROM [TB_EmployeeCheckIn] AS A LEFT JOIN [TB_Bed] AS B ON A.[BedID]=B.ID LEFT JOIN [TB_Room] AS C ON B.[RoomID]=C.ID LEFT JOIN [TB_Floor] AS D ON B.FloorID=D.ID LEFT JOIN [TB_Unit] AS E ON B.UnitID=E.ID LEFT JOIN [TB_Building] AS F on B.BuildingID=F.ID LEFT JOIN [TB_DormArea] AS G ON B.DormAreaID=G.ID LEFT JOIN TB_BU AS I ON A.BUID=I.ID Left join TB_RoomType as JJ on JJ.ID=C.RoomType"); Database db = DBO.GetInstance(); dbCommandWrapper = db.DbProviderFactory.CreateCommand(); dbCommandWrapper.CommandType = CommandType.Text; #region 拼接条件 if (null != SessionHelper.Get(HttpContext.Current, TypeManager.User)) { strBuilder.AppendLine(@" inner join [TB_UserConnectDormArea] AS H on G.ID=H.[DormAreaID] where 1=1"); strBuilder.AppendLine(" AND H.[UserID] = @UserID"); db.AddInParameter(dbCommandWrapper, "@UserID", DbType.Int32, ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ID); } else { strBuilder.AppendLine(" where 1=1"); } strBuilder.AppendLine(" AND A.IsActive = @IsActive"); db.AddInParameter(dbCommandWrapper, "@IsActive", DbType.Int32, (int)TypeManager.IsActive.Valid); strBuilder.AppendLine(" AND A.SiteID = @SiteID"); db.AddInParameter(dbCommandWrapper, "@SiteID", DbType.Int32, tb_EmployeeCheckIn.SiteID); if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.CardNo)) { strBuilder.AppendLine(" AND A.CardNo = @CardNo"); db.AddInParameter(dbCommandWrapper, "@CardNo", DbType.String, tb_EmployeeCheckIn.CardNo); } if (!String.IsNullOrEmpty(tb_EmployeeCheckIn.EmployeeNo)) { strBuilder.AppendLine(" AND A.EmployeeNo = @EmployeeNo"); db.AddInParameter(dbCommandWrapper, "@EmployeeNo", DbType.String, tb_EmployeeCheckIn.EmployeeNo); } if (!String.IsNullOrEmpty(tb_EmployeeCheckIn.Name)) { strBuilder.AppendLine(" AND A.Name = @Name"); db.AddInParameter(dbCommandWrapper, "@Name", DbType.String, tb_EmployeeCheckIn.Name); } if (tb_EmployeeCheckIn.BUID > 0) { strBuilder.AppendLine(" AND F.ID = @BUID"); db.AddInParameter(dbCommandWrapper, "@BUID", DbType.String, tb_EmployeeCheckIn.BUID); } if (iDormAreaID > 0) { strBuilder.AppendLine(" AND G.ID = @DormAreaID"); db.AddInParameter(dbCommandWrapper, "@DormAreaID", DbType.Int32, iDormAreaID); } if (iRoomTypeID > 0) { strBuilder.AppendLine(" AND JJ.ID = @iRoomTypeID"); db.AddInParameter(dbCommandWrapper, "@iRoomTypeID", DbType.Int32, iRoomTypeID); } if (!string.IsNullOrEmpty(sRoomName)) { strBuilder.AppendLine(" AND C.Name = @sRoomName"); db.AddInParameter(dbCommandWrapper, "@sRoomName", DbType.String, sRoomName); } if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.BU)) { var spara = string.Format("%{0}%", tb_EmployeeCheckIn.BU); strBuilder.AppendLine(" AND A.BU like @BU"); db.AddInParameter(dbCommandWrapper, "@BU", DbType.String, spara); } if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.Telephone)) { strBuilder.AppendLine(" AND A.Telephone =@Telephone"); db.AddInParameter(dbCommandWrapper, "@Telephone", DbType.String, tb_EmployeeCheckIn.Telephone); } if (tb_EmployeeCheckIn.CheckInDate != default(DateTime)) { strBuilder.AppendLine(" AND CAST(CheckInDate as Date) =@CheckInDate"); db.AddInParameter(dbCommandWrapper, "@CheckInDate", DbType.String, tb_EmployeeCheckIn.CheckInDate.ToString("yyyy/MM/dd")); } //根据时间范围来查询 if (tb_EmployeeCheckIn.CheckInDateBegin != default(DateTime)) { strBuilder.AppendLine(" AND CAST(CheckInDate as Date) between @CheckInDateBegin and @CheckInDateEnd"); db.AddInParameter(dbCommandWrapper, "@CheckInDateBegin", DbType.String, tb_EmployeeCheckIn.CheckInDateBegin.ToString("yyyy/MM/dd")); db.AddInParameter(dbCommandWrapper, "@CheckInDateEnd", DbType.String, tb_EmployeeCheckIn.CheckInDateEnd.ToString("yyyy/MM/dd")); } #endregion dbCommandWrapper.CommandText = strBuilder.ToString(); dt = db.ExecuteDataSet(dbCommandWrapper).Tables[0]; return(dt); } catch (Exception ex) { throw ex; } finally { if (dbCommandWrapper != null) { dbCommandWrapper.Dispose(); dbCommandWrapper = null; } } }
/// <summary> /// 查询入住记录分页数据 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> /// <param name="pager"></param> /// <returns></returns> public DataTable GetTable(TB_EmployeeCheckIn tb_EmployeeCheckIn, int iDormAreaID, int iRoomTypeID, string sRoomName, ref Pager pager) { DataTable dt = null; DbCommand dbCommandWrapper = null; try { StringBuilder strBuilder = new StringBuilder(@" SELECT A.[ID] ,A.[EmployeeNo] ,A.[Sex] ,A.[BU] ,A.EmployeeTypeName ,I.[Name] as RoomType ,A.[CardNo] ,A.[Telephone] ,A.[Province] ,Convert(varchar(12),A.[CheckInDate],111) as CheckInDate ,A.[Name] ,A.[SiteID] ,B.Name AS BedName ,C.Name AS RoomName ,C.RoomSexType ,D.Name As FloorName ,E.Name As UnitName ,F.Name As BuildingName ,G.Name As DormAreaName ,B.KeyCount FROM [TB_EmployeeCheckIn] AS A LEFT JOIN [TB_Bed] AS B ON A.[BedID]=B.ID LEFT JOIN [TB_Room] AS C ON B.[RoomID]=C.ID LEFT JOIN [TB_Floor] AS D ON B.FloorID=D.ID LEFT JOIN [TB_Unit] AS E ON B.UnitID=E.ID LEFT JOIN [TB_Building] AS F on B.BuildingID=F.ID LEFT JOIN [TB_DormArea] AS G ON B.DormAreaID=G.ID LEFT JOIN TB_RoomType AS I ON C.RoomType=I.ID "); Database db = DBO.GetInstance(); dbCommandWrapper = db.DbProviderFactory.CreateCommand(); dbCommandWrapper.CommandType = CommandType.Text; if (null != SessionHelper.Get(HttpContext.Current, TypeManager.User)) { strBuilder.AppendLine(@" inner join [TB_UserConnectDormArea] AS H on G.ID=H.[DormAreaID] where 1=1"); strBuilder.AppendLine(" AND H.[UserID] = @UserID"); db.AddInParameter(dbCommandWrapper, "@UserID", DbType.Int32, ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ID); } else { strBuilder.AppendLine(" where 1=1"); } strBuilder.AppendLine(" AND A.IsActive = @IsActive"); db.AddInParameter(dbCommandWrapper, "@IsActive", DbType.Int32, (int)TypeManager.IsActive.Valid); if (tb_EmployeeCheckIn.SiteID > 0) { strBuilder.AppendLine(" AND A.SiteID = @SiteID"); db.AddInParameter(dbCommandWrapper, "@SiteID", DbType.Int32, tb_EmployeeCheckIn.SiteID); } if (!String.IsNullOrEmpty(tb_EmployeeCheckIn.EmployeeNo)) { strBuilder.AppendLine(" AND A.EmployeeNo = @EmployeeNo"); db.AddInParameter(dbCommandWrapper, "@EmployeeNo", DbType.String, tb_EmployeeCheckIn.EmployeeNo); } if (!String.IsNullOrEmpty(tb_EmployeeCheckIn.Name)) { strBuilder.AppendLine(" AND A.Name = @Name"); db.AddInParameter(dbCommandWrapper, "@Name", DbType.String, tb_EmployeeCheckIn.Name); } if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.CardNo)) { strBuilder.AppendLine(" AND A.CardNo = @CardNo"); db.AddInParameter(dbCommandWrapper, "@CardNo", DbType.String, tb_EmployeeCheckIn.CardNo); } if (tb_EmployeeCheckIn.BUID > 0) { strBuilder.AppendLine(" AND F.ID = @BUID"); db.AddInParameter(dbCommandWrapper, "@BUID", DbType.String, tb_EmployeeCheckIn.BUID); } if (iDormAreaID > 0) { strBuilder.AppendLine(" AND G.ID = @DormAreaID"); db.AddInParameter(dbCommandWrapper, "@DormAreaID", DbType.Int32, iDormAreaID); } if (iRoomTypeID > 0) { strBuilder.AppendLine(" AND I.ID = @iRoomTypeID"); db.AddInParameter(dbCommandWrapper, "@iRoomTypeID", DbType.Int32, iRoomTypeID); } if (!string.IsNullOrEmpty(sRoomName)) { strBuilder.AppendLine(" AND C.Name = @sRoomName"); db.AddInParameter(dbCommandWrapper, "@sRoomName", DbType.String, sRoomName); } if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.BU)) { var spara = string.Format("%{0}%", tb_EmployeeCheckIn.BU); strBuilder.AppendLine(" AND A.BU like @BU"); db.AddInParameter(dbCommandWrapper, "@BU", DbType.String, spara); } if (!string.IsNullOrEmpty(tb_EmployeeCheckIn.Telephone)) { strBuilder.AppendLine(" AND A.Telephone =@Telephone"); db.AddInParameter(dbCommandWrapper, "@Telephone", DbType.String, tb_EmployeeCheckIn.Telephone); } if (tb_EmployeeCheckIn.CheckInDateBegin != default(DateTime)) { strBuilder.AppendLine(" AND CAST(CheckInDate as Date) between @CheckInDateBegin and @CheckInDateEnd"); db.AddInParameter(dbCommandWrapper, "@CheckInDateBegin", DbType.String, tb_EmployeeCheckIn.CheckInDateBegin.ToString("yyyy/MM/dd")); db.AddInParameter(dbCommandWrapper, "@CheckInDateEnd", DbType.String, tb_EmployeeCheckIn.CheckInDateEnd.ToString("yyyy/MM/dd")); } if (pager != null && !pager.IsNull) { dbCommandWrapper.CommandText = pager.GetPagerSql4Count(strBuilder.ToString()); dt = db.ExecuteDataSet(dbCommandWrapper).Tables[0]; pager.TotalRecord = Convert.ToInt32(dt.Rows[0][0]); dbCommandWrapper.CommandText = pager.GetPagerSql4Data(strBuilder.ToString(), DataBaseTypeEnum.sqlserver); } else { dbCommandWrapper.CommandText = strBuilder.ToString(); } dt = db.ExecuteDataSet(dbCommandWrapper).Tables[0]; return(dt); } catch (Exception ex) { throw ex; } finally { if (dbCommandWrapper != null) { dbCommandWrapper.Dispose(); dbCommandWrapper = null; } } }
/// <summary> /// 查询入住记录分页数据 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> /// <param name="pager"></param> /// <returns></returns> public DataTable GetPagerData(TB_EmployeeCheckIn tb_EmployeeCheckIn, int iDormAreaID, int iRoomTypeID, string sRoomName, ref Pager pager) { return(_mTB_EmployeeCheckInDAL.GetTable(tb_EmployeeCheckIn, iDormAreaID, iRoomTypeID, sRoomName, ref pager)); }
/// <summary> /// 查询入住记录分页数据 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> /// <param name="pager"></param> /// <returns></returns> public DataTable GetPagerData(TB_EmployeeCheckIn tb_EmployeeCheckIn, ref Pager pager) { return(_mTB_EmployeeCheckInDAL.GetTable(tb_EmployeeCheckIn, ref pager)); }
/// <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(); } }
protected void btnAssign_Click(object sender, EventArgs e) { try { //获取选中的ID string bagID = selbagID.Value; //查询room信息 DataTable dt = ViewState["dtFreeRoom"] as DataTable; DataRow[] drAssignRoomArr = dt.Select("ID=" + bagID + ""); var drAssign = drAssignRoomArr[0]; var sInputID = this.txtScanCardNO.Text.Trim(); var sWorkDayNO = this.txtWorkDayNo.Text.Trim(); string sIdCard = string.Empty; GetIdCardNumber(sInputID, sWorkDayNO, out sIdCard); //查询人员信息 DataTable dtEmployeeInfo = new StaffingBLL().GetTableWithIDL(sWorkDayNO, sIdCard); if (!DataTableHelper.IsEmptyDataTable(dtEmployeeInfo)) { var drEmp = dtEmployeeInfo.Rows[0]; if (drEmp["Sex"].ToString() != drAssign["RoomSexType"].ToString()) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('性别不符合宿舍定义,不能分配!')", true); return; } string sDormAreaName = drAssign["DormAreaName"].ToString(); string sBuildingName = drAssign["BuildingName"].ToString(); string sRoomName = drAssign["RoomName"].ToString(); string sBedName = drAssign["Name"].ToString(); //检查是否已经有CheckIn的记录 DataTable DtCheckIDCard = new AssignRoomBLL().GetAssignedData(drEmp["IDCardNumber"].ToString(), ""); DataTable DtCheckEmployeeID = new AssignRoomBLL().GetAssignedData(drEmp["EmployeeID"].ToString(), ""); if (DtCheckIDCard != null && DtCheckIDCard.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('此用户已有分配记录!')", true); } else if (DtCheckEmployeeID != null && DtCheckEmployeeID.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('此用户已有分配记录!')", true); } else { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); mTB_EmployeeCheckIn.RoomID = Convert.ToInt32(drAssign["RoomID"]); mTB_EmployeeCheckIn.BedID = int.Parse(drAssign["ID"].ToString()); mTB_EmployeeCheckIn.BU = Util.NormalBU(drEmp["SegmentName"].ToString()); //TODO 2018-02-07 //由于 EHR.[Segment] 的ID 与 DormManage.[TB_BU]根本不对应 //因此,换房记录无法导出事业部 mTB_EmployeeCheckIn.BUID = drEmp["SegmentID"] != DBNull.Value ? Convert.ToInt32(drEmp["SegmentID"]) : 0; mTB_EmployeeCheckIn.CardNo = string.IsNullOrEmpty(sIdCard) ? drEmp["IDCardNumber"].ToString() : sIdCard; mTB_EmployeeCheckIn.CheckInDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); mTB_EmployeeCheckIn.Company = string.Empty; mTB_EmployeeCheckIn.EmployeeNo = drEmp["EmployeeID"].ToString(); mTB_EmployeeCheckIn.Name = drEmp["ChineseName"].ToString(); mTB_EmployeeCheckIn.Sex = drAssign["RoomSexType"].ToString() == "男" ? 1 : 2; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.Creator = (base.UserInfo == null ? base.SystemAdminInfo.Account : base.UserInfo.ADAccount); mTB_EmployeeCheckIn.IsActive = (int)TypeManager.IsActive.Valid; mTB_EmployeeCheckIn.Telephone = drEmp["Phone"].ToString(); mTB_EmployeeCheckIn.EmployeeTypeName = drEmp["EmployeeTypeName"].ToString(); var bAssign = new AssignRoomBLL().AssignRoom(mTB_EmployeeCheckIn); if (!bAssign) { var msg = "分配房间失败,请重新分配"; ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + msg + "')", true); return; } ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('分配成功!')", true); ClearControl(); if (drEmp["Phone"].ToString() != "") { string sContent = drEmp["EmployeeID"].ToString() + "亲,以下是你被分配的宿舍信息:" + sDormAreaName + "宿舍 " + sBuildingName + "栋 " + sRoomName + "房间 " + sBedName + "床. 该宿舍的服务热线18926980019,请于3天内前往宿舍区办理入住手续,谢谢! "; try { //SendSMS(drEmp["Phone"].ToString(), sContent); } catch { return; } } } } else { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('招聘系统找不到此用户!')", true); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + ex.Message + "')", true); } finally { ClearWorkIDInput(); } }
protected void btnAssign_Click(object sender, EventArgs e) { try { var sInputID = this.txtScanCardNO.Text.Trim(); var sWorkDayNO = this.txtWorkDayNo.Text.Trim(); string sIdCard = string.Empty; GetIdCardNumber(sInputID, sWorkDayNO, out sIdCard); DataTable dt = ViewState["dtSetupContent"] as DataTable; DataRow[] drArr = null; DataTable dtAssignRoom = ViewState["dtAssignedRoom"] as DataTable; DataRow[] drAssignRoomArr = null; //ServiceReference1.EmployeeInfoSoapClient employee = new ServiceReference1.EmployeeInfoSoapClient(); //DataTable dtEmployeeInfo = employee.GetEmployee(this.txtScanCardNO.Text.Trim()); //查询人员信息 DataTable dtEmployeeInfo = new StaffingBLL().GetTableWithIDL(sWorkDayNO, sIdCard); //DataTable dtEmployeeInfo = new DataTable(); //dtEmployeeInfo.Columns.Add("Segment"); //dtEmployeeInfo.Columns.Add("EmployeeID"); //dtEmployeeInfo.Columns.Add("IDCard"); //dtEmployeeInfo.Columns.Add("ChineseName"); //dtEmployeeInfo.Columns.Add("Sex"); //DataRow drNew = dtEmployeeInfo.NewRow(); //drNew["Segment"] = "BU1"; //drNew["EmployeeID"] = "2051773"; //drNew["IDCard"] = "1234567890"; //drNew["ChineseName"] = "Eric liu"; //drNew["Sex"] = "男"; //dtEmployeeInfo.Rows.Add(drNew); if (!DataTableHelper.IsEmptyDataTable(dtEmployeeInfo)) { string condition = " BU='" + dtEmployeeInfo.Rows[0]["SegmentName"] + "' and Sex ='" + dt.Rows[0]["Sex"] + "' "; drArr = dt.Select(condition); drAssignRoomArr = dtAssignRoom.Select("DormAreaID=" + drArr[0]["DormAreaID"] + " and BuildingID=" + drArr[0]["BuildingID"] + " and RoomType=" + drArr[0]["RoomType"] + " and RoomSexType='" + drArr[0]["Sex"] + "'"); string sDormAreaName = drAssignRoomArr[0]["DormAreaName"].ToString(); string sBuildingName = drAssignRoomArr[0]["BuildingName"].ToString(); string sRoomName = drAssignRoomArr[0]["RoomName"].ToString(); string sBedName = drAssignRoomArr[0]["BedName"].ToString(); if (dtEmployeeInfo.Rows[0]["Sex"].ToString() == RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male)) { this.txtEmployeeNo.Text = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); this.txtCardNo.Text = dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(); this.txtName.Text = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); this.txtBU.Text = dtEmployeeInfo.Rows[0]["SegmentName"].ToString(); this.txtDormArea.Text = drAssignRoomArr[0]["DormAreaName"].ToString(); this.txtBuilding.Text = drAssignRoomArr[0]["BuildingName"].ToString(); this.txtRoom.Text = drAssignRoomArr[0]["RoomName"].ToString(); this.txtBed.Text = drAssignRoomArr[0]["BedName"].ToString(); } else { //this.rbSex.SelectedValue = Convert.ToString((int)TypeManager.Sex.Female); this.txtFemaleEmployeeNo.Text = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); this.txtFemaleCardNo.Text = dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(); this.txtFemaleName.Text = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); this.txtFemaleBU.Text = dtEmployeeInfo.Rows[0]["SegmentName"].ToString(); this.txtFemaleDormArea.Text = drAssignRoomArr[0]["DormAreaName"].ToString(); this.txtFemaleBuilding.Text = drAssignRoomArr[0]["BuildingName"].ToString(); this.txtFemaleRoom.Text = drAssignRoomArr[0]["RoomName"].ToString(); this.txtFemaleBed.Text = drAssignRoomArr[0]["BedName"].ToString(); } //检查是否已经有CheckIn的记录 DataTable DtCheck = new AssignRoomBLL().GetAssignedData(dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(), ""); if (DtCheck != null && DtCheck.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('此用户已有分配记录!')", true); } else { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); mTB_EmployeeCheckIn.RoomID = Convert.ToInt32(drAssignRoomArr[0]["RoomID"]); mTB_EmployeeCheckIn.BedID = int.Parse(drAssignRoomArr[0]["BedID"].ToString()); mTB_EmployeeCheckIn.BU = Util.NormalBU(dtEmployeeInfo.Rows[0]["SegmentName"].ToString()); mTB_EmployeeCheckIn.CardNo = sIdCard; //this.txtScanCardNO.Text; mTB_EmployeeCheckIn.CheckInDate = DateTime.Now; mTB_EmployeeCheckIn.Company = string.Empty; mTB_EmployeeCheckIn.EmployeeNo = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); mTB_EmployeeCheckIn.Name = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); mTB_EmployeeCheckIn.Sex = drAssignRoomArr[0]["RoomSexType"].ToString() == "男" ? 1 : 2; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.Creator = (base.UserInfo == null ? base.SystemAdminInfo.Account : base.UserInfo.ADAccount); mTB_EmployeeCheckIn.IsActive = (int)TypeManager.IsActive.Invalid; mTB_EmployeeCheckIn.Telephone = dtEmployeeInfo.Rows[0]["Phone"].ToString(); var bAssign = new AssignRoomBLL().AssignRoom(mTB_EmployeeCheckIn); if (!bAssign) { var msg = "分配房间失败,请重新分配"; ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + msg + "')", true); return; } dtAssignRoom.Rows.Remove(drAssignRoomArr[0]); ViewState["dtAssignedRoom"] = dtAssignRoom; //this.txtNation.Text = dt.Rows[0]["Nation"].ToString(); //this.txtAddress.Text = dt.Rows[0]["Address"].ToString(); //this.txtDept.Text = dt.Rows[0]["Segment"].ToString(); //this.txtBirthDay.Text = dt.Rows[0]["Birth"].ToString(); if (dtEmployeeInfo.Rows[0]["Phone"].ToString() != "") { string sContent = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString() + "亲,以下是你被分配的宿舍信息:" + sDormAreaName + "宿舍 " + sBuildingName + "栋 " + sRoomName + "房间 " + sBedName + "床. 该宿舍的服务热线18926980019,请于3天内前往宿舍区办理入住手续,谢谢! "; try { SendSMS(dtEmployeeInfo.Rows[0]["Phone"].ToString(), sContent); } catch { return; } } } } else { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('招聘系统找不到此用户!')", true); } //this.txtScanCardNO.Text = string.Empty; //this.ReadCardTimer.Enabled = true; //this.txtScanCardNO.Focus(); } catch { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('异常错误,请检查!')", true); } finally { ClearWorkIDInput(); } }
public int EditTB_EmployeeCheckIn(TB_EmployeeCheckIn info) { return(_mTB_EmployeeCheckInDAL.EditTB_EmployeeCheckIn(info)); }