private bool GetGridData(string tex) { try { using (var context = new RubberSoftEntities()) { if (tex.Trim() == "" || tex.Length <= 0) { var query = context.spt_GetUsers().Where(o => o.Active == true).ToList(); GridUsers.DataSource = query; } else { var query = context.spt_GetUsers().Where(o => o.Active == true && o.UserName == tex || o.FirstName == tex || o.LastName == tex).ToList(); GridUsers.DataSource = query; } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool GetUserData(int UserId) { try { using (var context = new RubberSoftEntities()) { var query = context.spt_GetUsers().Where(o => o.UserId == UserId).ToList(); if (query.Count > 0) { foreach (spt_GetUsers_Result dt in query) { ClassProperty.permisUserNm = dt.UserName; ClassProperty.permisRole = dt.RoleName; ClassProperty.permisRoleId = dt.UserTypeId.Value; lblUserName.Text = "ยินดีต้อนรับ : " + ClassProperty.permisUserNm; } } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool GetData(int id) { try { using (var context = new RubberSoftEntities()) { var query = context.spt_GetUsers().Where(o => o.UserId == id).ToList(); if (query.Count > 0) { foreach (spt_GetUsers_Result dt in query) { userName = dt.UserName; strUserName = dt.UserName; roleId = dt.UserTypeId.Value; TxtUserName.Text = dt.UserName; TxtPassword.Text = SQLData.DecryptString(dt.Password); TxtFirstName.Text = dt.FirstName; TxtLastName.Text = dt.LastName; SLRole.EditValue = roleId; } } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool CheckData(int id) { try { using (var context = new RubberSoftEntities()) { var query = context.spt_GetUsers().Where(o => o.UserId == id).ToList(); if (query.Count > 0) { foreach (spt_GetUsers_Result dt in query) { userId = dt.UserId; } return(true); } else { return(false); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool CheckDuplicate() { try { using (var context = new RubberSoftEntities()) { var query = context.spt_GetUsers().Where(o => o.UserName == userName && o.Active == true).ToList(); if (query.Count > 0) { return(true); } else { return(false); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool Login() { try { if (SQLData.CheckRubberSoftConnection() == false || SQLData.CheckConnection() == false) { XtraMessageBox.Show("ไม่สามารถเชื่อมต่อระบบได้", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (TxtUserName.Text.Trim() == "" || TxtPassword.Text == "") { Alert(); return(false); } if (TxtUserName.Text.Trim() == SQLData.ID && TxtPassword.Text.Trim() == SQLData.DecryptString(SQLData.KEY)) { ClassProperty.permisUserID = -1; ClassProperty.permisUserNm = SQLData.ID; ClassProperty.permisRole = "IT"; ClassProperty.permisRoleId = -1; ClassProperty.permisUserPass = TxtPassword.Text.Trim(); CheckLogin(); } else { if (ClassProperty.EnableTerminal == false) { XtraMessageBox.Show("เครื่องใช้งานไม่มีสิทธิ์เข้าใช้งานระบบ", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } using (var context = new RubberSoftEntities()) { var query = context.spt_GetUsers().Where(o => o.UserName == TxtUserName.Text && SQLData.DecryptString(o.Password) == TxtPassword.Text.Trim()).ToList(); if (query.Count > 0) { foreach (spt_GetUsers_Result dt in query) { ClassProperty.permisUserID = dt.UserId; ClassProperty.permisUserNm = dt.UserName; ClassProperty.permisRole = dt.RoleName; ClassProperty.permisRoleId = dt.UserTypeId.Value; ClassProperty.permisUserPass = TxtPassword.Text.Trim(); // 1-001 1 : สิทธิ์ใช้งานหน้าเข้าสู่ระบบ เข้าสู่ระบบ int AuthorizeId = 1; if (SQLAuthorized.CheckAuthorized(ClassProperty.permisRoleId, AuthorizeId) == false) { SQLAuthorized.AlertAuthorized("สิทธิ์ใช้งานหน้าเข้าสู่ระบบ", "ไม่มีสิทธิ์การใช้งานระบบ"); return(false); } CheckLogin(); } } else { //XtraMessageBox.Show("ข้อมูลผู้ใช้งานมีปัญหา กรุณาติดต่อ IT !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); Alert(); return(false); } } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }