public Boolean ReLogin(string tsHashCode) { if (tsHashCode == "") { return(false); } string lsSql = @"select b.* from t_S_OnLine_Employee a inner join t_S_Employee b on a.Employee_Id=b.Employee_Id where a.HashCode='" + tsHashCode + "'"; DataTable lodtEmployee = new DataTable(); DAL.DBA.FillDataTable(lodtEmployee, lsSql); if (lodtEmployee.Rows.Count == 1) { this.loUserInfo = new UserInfo(); loUserInfo.UserId = Convert.ToInt32(lodtEmployee.Rows[0]["Employee_ID"].ToString()); loUserInfo.UserName = lodtEmployee.Rows[0]["Employee_Name"].ToString(); loUserInfo.DeptId = Convert.ToInt32(lodtEmployee.Rows[0]["Dept_ID"].ToString()); loUserInfo.Is_Employee_Pwd_Reset = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Employee_Pwd_Reset"])); loUserInfo.Employee_Status = (EnumDef.EStatus)IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"].ToString()); loUserInfo.Login_ID = lodtEmployee.Rows[0]["Employee_Login_ID"].ToString(); loUserInfo.Is_Admin = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Admin"])); loUserInfo.Password = lodtEmployee.Rows[0]["employee_login_pwd"].ToString(); loUserInfo.PositionID = IntUtil.SafeCIntNullable(lodtEmployee.Rows[0]["Position_ID"]); this.moSession["UserSession"] = this; this.InitMenu(); return(true); } else { return(false); } }
//判断是否有某个页面的权限 public static Boolean ValidatePageRight(int tnEmployeeId, int tnPageId) { string lsSql = @" select c.Page_Id from t_S_Employee_Role a inner join t_S_Role b on a.ROLE_ID=b.Role_ID inner join t_S_Role_Page c on b.Role_ID=c.Role_ID where a.Valid_Date<Sysdate and a.Invalid_Date>Sysdate and a.Employee_ID=" + tnEmployeeId + @" and Page_Id=" + tnPageId + @" union select Page_ID from t_S_Employee_Module_Add d where d.Valid_Date<Sysdate and d.Invalid_Date>Sysdate and d.Employee_ID=" + tnEmployeeId + @" and Page_Id=" + tnPageId; DataTable lodtpage = new DataTable(); int lnPageid = IntUtil.SafeCInt(DAL.DBA.ExecuteScalar(lsSql)); if (lnPageid == tnPageId) { return(true); } else { return(false); } }
public string Login(string tsUserAccount, string tsPassword, ref string tsUserHash, bool lsBool) { string lsMessage = ""; string lsSql = "Select * from t_S_Employee where Employee_Login_ID='" + tsUserAccount + "'"; DataTable lodtEmployee = new DataTable(); DAL.DBA.FillDataTable(lodtEmployee, lsSql); if (lodtEmployee.Rows.Count >= 1) { try { this.loUserInfo = new UserInfo(); loUserInfo.UserId = Convert.ToInt32(lodtEmployee.Rows[0]["Employee_ID"].ToString()); loUserInfo.UserName = lodtEmployee.Rows[0]["Employee_Name"].ToString(); loUserInfo.DeptId = Convert.ToInt32(lodtEmployee.Rows[0]["Dept_ID"].ToString()); loUserInfo.Is_Employee_Pwd_Reset = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Employee_Pwd_Reset"])); loUserInfo.Employee_Status = (EnumDef.EStatus)IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"].ToString()); loUserInfo.Login_ID = lodtEmployee.Rows[0]["Employee_Login_ID"].ToString(); loUserInfo.Is_Admin = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Admin"])); loUserInfo.Password = lodtEmployee.Rows[0]["employee_login_pwd"].ToString(); loUserInfo.PositionID = IntUtil.SafeCIntNullable(lodtEmployee.Rows[0]["Position_ID"]); if (IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"]) != 1) { lsMessage = "此用户处于未激活状态!"; return(lsMessage); } //密码不正确 if (loUserInfo.Password != CommonFunction.GetCode(tsPassword)) { lsMessage = "登录密码错误,请重新输入!"; return(lsMessage); } if (!lsBool) { if (StrUtil.SafeCString(lodtEmployee.Rows[0]["Is_Out_Accesss"]) != "1") { lsMessage = "此用户无权登录!"; return(lsMessage); } } #region 添加在线用户表记录 string lsSQL = "select HashCode from t_S_OnLine_Employee where Employee_ID=" + loUserInfo.UserId + " and rownum =1"; object loUserHash = DAL.DBA.ExecuteScalar(lsSQL); if (loUserHash != null && loUserHash != DBNull.Value) { tsUserHash = loUserHash.ToString(); } else { tsUserHash = CommonFunction.GetCode(loUserInfo.Login_ID + loUserInfo.Password); int lnOnlineID = Convert.ToInt32(CommonDBFunction.GenerateSEQIdentity("t_S_OnLine_Employee")); lsSQL = @"insert into t_S_OnLine_Employee(OnLine_Employee_id,Employee_ID,Status,HashCode,LoginTime) values(" + lnOnlineID.ToString() + "," + loUserInfo.UserId.ToString() + ",1,'" + tsUserHash + "',to_date('" + DateTime.Now + "','yyyy-MM-dd HH24:MI:SS'))"; DAL.DBA.ExecSQL("userlogin", lsSQL, ref lsMessage); } #endregion this.moSession["UserSession"] = this; this.InitMenu(); return(lsMessage); } catch (Exception ex) { lsMessage = "登陆失败!\r\n" + ex.Message; return(lsMessage); } } else { lsMessage = "用户“" + tsUserAccount + "”不存在!"; return(lsMessage); } }
//更新房态基本信息表 public static void UpdateHotelStatus(EnumDef.EHRoomStatusType tnUpdateStyle, int tnUpdateNum, DateTime tsUpdateDate, String tsHBaseInfoId, int tnEmployeeID) { String lsSQL = "SELECT * FROM HOTELSTATUS WHERE HOTELINFOID = " + tsHBaseInfoId.Trim() + " AND USEDATE = to_date('" + tsUpdateDate + "','yyyy-mm-dd hh24:mi:ss')"; int lnRoomBuyNum = 0; int lnRoomHold = 0; DataSet ds = new DataSet(); String lsError = ""; if (DBA.SelectSQL("", lsSQL, ref ds, ref lsError) > 0) { switch (tnUpdateStyle) { case EnumDef.EHRoomStatusType.买房: if (ds.Tables[0].Rows.Count > 0) { lnRoomBuyNum += IntUtil.SafeCInt(ds.Tables[0].Rows[0]["BUYHOUSENUM"]) + tnUpdateNum; } break; case EnumDef.EHRoomStatusType.占房: break; case EnumDef.EHRoomStatusType.预留房: if (ds.Tables[0].Rows.Count > 0) { lnRoomHold += IntUtil.SafeCInt(ds.Tables[0].Rows[0]["OBLIGATEHOUSENUM"]) + tnUpdateNum; } break; case EnumDef.EHRoomStatusType.满房: break; } String lsSQLUpdate = @"update HOTELSTATUS set BuyHouseNum = :BuyHouseNum,OBLIGATEHOUSENUM = :OBLIGATEHOUSENUM where HOUSESTATETYPEID = :HOUSESTATETYPEID "; OracleConnection loOraConn = DBA.GetOraConnection("CRMDB"); try { OracleCommand loOraComm = new OracleCommand(lsSQLUpdate, loOraConn); DBUtil.AddParameter(loOraComm, "BuyHouseNum", lnRoomBuyNum); DBUtil.AddParameter(loOraComm, "OBLIGATEHOUSENUM", lnRoomHold); DBUtil.AddParameter(loOraComm, "HOUSESTATETYPEID", IntUtil.SafeCInt(ds.Tables[0].Rows[0]["HOUSESTATETYPEID"])); loOraComm.ExecuteNonQuery(); } finally { DBA.CloseOraConnection(loOraConn); } } else { switch (tnUpdateStyle) { case EnumDef.EHRoomStatusType.买房: lnRoomBuyNum += tnUpdateNum; break; case EnumDef.EHRoomStatusType.占房: break; case EnumDef.EHRoomStatusType.预留房: lnRoomHold += tnUpdateNum; break; case EnumDef.EHRoomStatusType.满房: break; } String lsSQLInsert = @"insert into HOTELSTATUS (HOUSESTATETYPEID,HOTELINFOID,USEDATE,BUYHOUSENUM,OBLIGATEHOUSENUM,OPERATETIME,EmployeeInfoID) Values(:HOUSESTATETYPEID,:HOTELINFOID,:USEDATE,:BUYHOUSENUM,:OBLIGATEHOUSENUM,:OPERATETIME,:EmployeeInfoID)"; OracleConnection loOraConn = DBA.GetOraConnection("CRMDB"); try { OracleCommand loOraComm = new OracleCommand(lsSQLInsert, loOraConn); DBUtil.AddParameter(loOraComm, "HOUSESTATETYPEID", IntUtil.SafeCInt(CommonDBFunction.GenerateIdentity("HOTELSTATUS"))); DBUtil.AddParameter(loOraComm, "HOTELINFOID", IntUtil.SafeCInt(tsHBaseInfoId)); DBUtil.AddParameter(loOraComm, "USEDATE", Convert.ToDateTime(tsUpdateDate)); DBUtil.AddParameter(loOraComm, "BUYHOUSENUM", lnRoomBuyNum); DBUtil.AddParameter(loOraComm, "OBLIGATEHOUSENUM", lnRoomHold); DBUtil.AddParameter(loOraComm, "OPERATETIME", DateUitl.GetDateTime()); DBUtil.AddParameter(loOraComm, "EmployeeInfoID", tnEmployeeID); loOraComm.ExecuteNonQuery(); } finally { DBA.CloseOraConnection(loOraConn); } } }