/// <summary> /// Authes the logon. /// </summary> /// <returns></returns> private bool AuthLogon() { if (Verify()) { var oUser = UserProfileEx.GetLoginUser(txtStaffNumber.Text.Trim().Replace("'", ""), txtPassword.Text.Trim().Replace("'", "")); if (oUser != null) { var oStaff = StaffEx.GetByStaffId(oUser.UserSid); if (oStaff != null) { if (oStaff.Status > Convert.ToInt32(EnumHelper.Status.Inactive.ToString("d"))) { if (!oStaff.Retired) { this.Context.Session.IsLoggedOn = true; ConfigHelper.CurrentUserId = oStaff.StaffId; ConfigHelper.CurrentZoneId = new Guid(cboZone.SelectedValue.ToString()); ConfigHelper.CurrentUserType = oUser.UserType.Value; // The below code will logout the loggedin user when idle for the time specified if (ConfigurationManager.AppSettings["sessionTimeout"] != null) { this.Context.HttpContext.Session.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings["sessionTimeout"]); } RT2020.Controls.Log4net.LogInfo(RT2020.Controls.Log4net.LogAction.Login, this.ToString()); } else { this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("msg_retired_staff"); this.Context.Session.IsLoggedOn = false; } } else { this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("msg_inactive_staff"); this.Context.Session.IsLoggedOn = false; } } } else { // When user inputs incorrect staff number or password, prompt user the error message. // To Do: We can try to limited the times of attempt to 5 or less. this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("err_incorrect_staff"); this.Context.Session.IsLoggedOn = false; } } else { this.Context.Session.IsLoggedOn = false; } return(this.Context.Session.IsLoggedOn); }
/// <summary> /// the Allowed permission. /// According to PermissionLevel: /// 1, 2, 3 - Can Read /// 4, 5, 6 - Can Write /// 7, 8 - Can Modify /// 9 - All /// </summary> /// <returns></returns> private static EnumHelper.Permission AllowedPermission() { bool canRead = true, canWrite = false, canDelete = false, canPost = false; EnumHelper.Permission allowedPermission = EnumHelper.Permission.Read; //string query = "StaffId = '" + ConfigHelper.CurrentUserId.ToString() + "' AND GradeCode = '" + PermissionLevel() + "'"; var oSecurity = StaffSecurityEx.GetByStaffId(ConfigHelper.CurrentUserId, PermissionLevel()); if (oSecurity != null) { canRead = oSecurity.CanRead.Value; canWrite = oSecurity.CanWrite.Value; canDelete = oSecurity.CanDelete.Value; canPost = oSecurity.CanPost.Value; } else { var oStaff = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (oStaff != null) { var oGroup = StaffGroupEx.GetById(oStaff.GroupId.Value); if (oGroup != null) { canRead = oGroup.CanRead.Value; canWrite = oGroup.CanWrite.Value; canDelete = oGroup.CanDelete.Value; canPost = oGroup.CanPost.Value; } } } if (canRead) { allowedPermission = EnumHelper.Permission.Read; } if (canWrite) { allowedPermission = allowedPermission | EnumHelper.Permission.Write; } if (canDelete) { allowedPermission = allowedPermission | EnumHelper.Permission.Delete; } if (canPost) { allowedPermission = allowedPermission | EnumHelper.Permission.Posting; } return(allowedPermission); }
public static String SecurityLevel() { String result = String.Empty; var staff = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (staff != null) { result = StaffGroupEx.GetGradeCodeById(staff.GroupId.Value); } return(result); }
public static string PermissionLevel() { string result = "1"; // Guest var user = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (user != null) { result = StaffGroupEx.GetGradeCodeById(user.GroupId.Value); } return(result); }
private void ChangePassword_Load(object sender, EventArgs e) { SetCaptions(); if (_StaffId != Guid.Empty) { var Staff = StaffEx.GetByStaffId(_StaffId); if (Staff != null) { this.Password = Staff.Password; } } txtOldPwd.Focus(); }
public static bool IsSuperUser(Guid userId) { bool result = false; var staff = StaffEx.GetByStaffId(userId); if (staff != null) { if (staff.CreatedBy == Guid.Empty) { result = true; } } return(result); }
private void LoadDetail() { var oStaff = StaffEx.GetByStaffId(_StaffId); if (oStaff != null) { txtStaffNumber.Text = oStaff.StaffNumber; txtFullName.Text = oStaff.FullName; cboGrade.SelectedValue = oStaff.GroupId; } var oSecurity = StaffSecurityEx.GetById(_SecurityId); if (oSecurity != null) { chkCanRead.Checked = oSecurity.CanRead.Value; chkCanWrite.Checked = oSecurity.CanWrite.Value; chkCanPost.Checked = oSecurity.CanPost.Value; chkCanDelete.Checked = oSecurity.CanDelete.Value; } }
private bool IsPostable(string headerId, ref DataTable errorTable) { bool isPostable = true; using (var ctx = new EF6.RT2020Entities()) { Guid id = Guid.Empty; if (Guid.TryParse(headerId, out id)) { var oBatchHeader = InvtBatchADJ_HeaderEx.Get(id); if (oBatchHeader != null) { if (!CheckTxDate(oBatchHeader.TxDate.Value)) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = string.Empty; row["APPENDIX1"] = string.Empty; row["APPENDIX2"] = string.Empty; row["APPENDIX3"] = string.Empty; row["ErrorReason"] = "Transaction date does not belong to current system month."; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } if (oBatchHeader.Status == (int)EnumHelper.Status.Active && oBatchHeader.PostedBy != System.Guid.Empty) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = string.Empty; row["APPENDIX1"] = string.Empty; row["APPENDIX2"] = string.Empty; row["APPENDIX3"] = string.Empty; row["ErrorReason"] = "Transaction already had been posted! Cannot post again!"; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } var detailList = ctx.InvtBatchADJ_Details.Where(x => x.HeaderId == oBatchHeader.HeaderId).AsNoTracking().ToList(); foreach (var detail in detailList) { bool retired = false; string stk = string.Empty, a1 = string.Empty, a2 = string.Empty, a3 = string.Empty; var oProduct = ProductEx.Get(detail.ProductId); if (oProduct != null) { stk = oProduct.STKCODE; a1 = oProduct.APPENDIX1; a2 = oProduct.APPENDIX2; a3 = oProduct.APPENDIX3; retired = oProduct.Retired; } if (retired) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = stk; row["APPENDIX1"] = a1; row["APPENDIX2"] = a2; row["APPENDIX3"] = a3; row["ErrorReason"] = "Product does not exist or has been removed!"; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } decimal qty = ProductHelper.GetOnHandQtyByWorkplaceId(detail.ProductId, oBatchHeader.WorkplaceId); if ((qty + detail.Qty) < 0) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = stk; row["APPENDIX1"] = a1; row["APPENDIX2"] = a2; row["APPENDIX3"] = a3; row["ErrorReason"] = "Product does not have enough on-hand qty!"; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } } var oStaff = StaffEx.GetByStaffId(oBatchHeader.StaffId); if (oStaff != null) { if (oStaff.Retired) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = string.Empty; row["APPENDIX1"] = string.Empty; row["APPENDIX2"] = string.Empty; row["APPENDIX3"] = string.Empty; row["ErrorReason"] = "Staff does not exist or has been removed!"; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } } var oInvtLedger = ctx.InvtLedgerHeader.Where(x => x.TxNumber == oBatchHeader.TxNumber && x.TxType == "ADJ").AsNoTracking().FirstOrDefault(); if (oInvtLedger != null) { #region 加一行 DataRow row = errorTable.NewRow(); row["HeaderId"] = oBatchHeader.HeaderId.ToString(); row["TxNumber"] = oBatchHeader.TxNumber; row["STKCODE"] = string.Empty; row["APPENDIX1"] = string.Empty; row["APPENDIX2"] = string.Empty; row["APPENDIX3"] = string.Empty; row["ErrorReason"] = "Transaction existed in Inventory Ledger!"; row["PostDate"] = DateTime.Now; errorTable.Rows.Add(row); #endregion isPostable = isPostable & false; } } else { return(false); } } } return(isPostable); }
private void btnFind_Click(object sender, EventArgs e) { string whereClause = string.Empty; EF6.Staff staff = null; if (!txtStaff.Text.Trim().Equals("*")) { staff = StaffEx.GetByStaffNumber(txtStaff.Text.Trim()); } var smartTag4Staff = SmartTag4StaffEx.GetByTagCode("HKID"); if (!txtHKID.Text.Trim().Equals("*")) { if (smartTag4Staff != null) { if (staff != null) { whereClause = " StaffId = '" + staff.StaffId.ToString() + "' AND TagId = '" + smartTag4Staff.TagId.ToString() + "' AND SmartTagValue = '" + txtHKID.Text.Trim() + "'"; } else { whereClause = " TagId = '" + smartTag4Staff.TagId.ToString() + "' AND SmartTagValue = '" + txtHKID.Text.Trim() + "'"; } } } else { if (smartTag4Staff != null) { if (staff != null) { whereClause = " StaffId = '" + staff.StaffId.ToString() + "' AND TagId = '" + smartTag4Staff.TagId.ToString() + "'"; } else { whereClause = " TagId = '" + smartTag4Staff.TagId.ToString() + "'"; } } } using (var ctx = new EF6.RT2020Entities()) { var list = ctx.StaffSmartTag.SqlQuery( String.Format( "Select * from StaffSmartTag Where {0}", String.IsNullOrEmpty(whereClause) ? "1 = 1" : whereClause )) .AsNoTracking() .ToList(); if (list.Count > 0) { int iCount = 1; foreach (var item in list) { ListViewItem objItem = this.lvStaffList.Items.Add(iCount.ToString()); if (staff == null) { var sta = StaffEx.GetByStaffId(item.StaffId); if (sta != null) { objItem.SubItems.Add(sta.StaffNumber); } } else { objItem.SubItems.Add(txtStaff.Text.Trim()); } objItem.SubItems.Add(item.SmartTagValue); iCount++; } } } }