public frmSecretaries() { InitializeComponent(); if (TaxiDbContext.Instance.Users.OfType <Models.AuthenticatedUser>().Any()) { UpdateGrid(); } BizObject = null; BizObject = new Models.AuthenticatedUser() { Id = 0, FullName = string.Empty, Mobile = string.Empty, IsDeleted = false, Username = string.Empty, Password = string.Empty, Role = Roles.Secretary, TaxiName = TaxiDbContext.Instance.AuthenticatedUsers.Where(u => u.Role == Roles.Admin).First().TaxiName, DateJoined = DateTime.Today, SecurityQuestion = " ", SecurityAnswer = " " }; gridSecretaries.CellClick += gridSecretaries_CellClick; lblDateJoined.Text = DateTime.Today.ToPersianDateString(); }
void UpdateSecretary() { Models.AuthenticatedUser Secretary = (Models.AuthenticatedUser)TaxiDbContext.Instance.Users.Single(d => d.Id == BizObject.Id); Secretary.FullName = BizObject.FullName; Secretary.Mobile = BizObject.Mobile; DialogResult dr = MessageBoxRTL.Ask("آیا مایل به ویرایش کلمه عبور هستید؟", string.Empty); if (dr == DialogResult.OK) { Secretary.Password = EasyHash.Hash(BizObject.Password); } Secretary.Role = Roles.Secretary; Secretary.SecurityQuestion = string.Empty; Secretary.SecurityAnswer = string.Empty; Secretary.TaxiName = TaxiDbContext.Instance.AuthenticatedUsers.Where(u => u.Role == Roles.Admin).First().TaxiName; BizObject.IsDeleted = false; TaxiDbContext.Instance.SaveChanges(); BizObject = null; MessageBoxRTL.Info(".منشی با موفقیت ویرایش شد", string.Empty); UpdateGrid(); }
private void btnSave_Click(object sender, EventArgs e) { BizObject.TaxiName = TaxiDbContext.Instance.AuthenticatedUsers.Where(u => u.Role == Roles.Admin).First().TaxiName; if (BizObject != null && Validation.Validate(BizObject)) { try { if (BizObject.Id != 0) { UpdateSecretary(); } else if (BizObject.Id == 0) { //avoid repeating Secretary Mobile if (TaxiDbContext.Instance.Users.Any(u => u.Mobile == BizObject.Mobile && u.FullName != BizObject.FullName)) { MessageBoxRTL.Error("شماره همراه قبلا ثبت شده است. لطفا شماره دیگری وارد کنید", string.Empty); return; } if (TaxiDbContext.Instance.Users.Any(u => u.Mobile == BizObject.Mobile && u.FullName == BizObject.FullName)) { DialogResult dr = MessageBoxRTL.Ask("این منشی قبلا ثبت شده است. آیا مایل به ویرایش آن هستید؟", string.Empty); if (dr == DialogResult.OK) { Models.AuthenticatedUser CheckExistingSecretary = TaxiDbContext.Instance.Users .OfType <Models.AuthenticatedUser>().Single(u => u.Mobile == BizObject.Mobile && u.FullName == BizObject.FullName); BizObject = null; BizObject = CheckExistingSecretary; UpdateSecretary(); return; } return; } BizObject.Role = Roles.Secretary; BizObject.TaxiName = TaxiDbContext.Instance.AuthenticatedUsers.Where(u => u.Role == Roles.Admin).First().TaxiName; BizObject.Password = EasyHash.Hash(txtSecretaryPassword.Text); TaxiDbContext.Instance.Users.Add(BizObject); TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".منشی با موفقیت افزوده شد", string.Empty); UpdateGrid(); BizObject = null; } } catch { MessageBoxRTL.Error("ذخیره سازی منشی با خطا روبرو شد.", string.Empty); } } }
void EditBizObject() { BizObject = null; int id; int.TryParse(gridSecretaries.SelectedCells.First().RowInfo.Cells["Id"].Value.ToString(), out id); UpdateGrid(); Models.AuthenticatedUser SecretaryToEdit = TaxiDbContext.Instance.Users.OfType <Models.AuthenticatedUser>().SingleOrDefault(c => c.Id == (int)id && c.Role == Roles.Secretary); if (SecretaryToEdit != null) { //BizObject = (Models.Driver)DriverToEdit.Clone(); BizObject = (Models.AuthenticatedUser)SecretaryToEdit.Clone(); } }
void DeleteBizObject() { Models.AuthenticatedUser SecretaryToRemove = TaxiDbContext.Instance.Users .Find(int.Parse(gridSecretaries.CurrentRow.Cells["Id"].Value.ToString())) as Models.AuthenticatedUser; DialogResult dr = MessageBoxRTL.Ask("آیا از حذف منشی اطمینان دارید؟", string.Empty); if (dr == DialogResult.OK) { try { //TaxiDbContext.Instance.Users.Remove(DriverToRemove); SecretaryToRemove.IsDeleted = true; TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".منشی با موفقیت حذف شد", string.Empty); UpdateGrid(); BizObject = null; } catch { MessageBoxRTL.Error("حذف منشی با خطا روبرو شد", string.Empty); } } }
private void btnCancel_Click(object sender, EventArgs e) { BizObject = null; }
public DadosStorage(AuthenticatedUser user) { _user = user; StringBlopService = "DefaultEndpointsProtocol=https;AccountName=ac2020storage;AccountKey=5fAS2v1hAZnoxilyas06ZvZwd7ehsftjBQkGlhsnW8+qtGiqboSO3UhsMS4+y59mx+DKJhmulzSx4NG2UF78SQ==;EndpointSuffix=core.windows.net"; ContainerName = "joaomachado"; }