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) { if (BizObject != null && Validation.Validate(BizObject)) { try { if (BizObject.Id != 0) { Models.Customer Customer = (Models.Customer)TaxiDbContext.Instance.Users.Find(BizObject.Id); Customer.FullName = BizObject.FullName; Customer.Mobile = BizObject.Mobile; Customer.Address = BizObject.Address; TaxiDbContext.Instance.SaveChanges(); BizObject = null; MessageBoxRTL.Info(".مشتری با موفقیت ویرایش شد", string.Empty); UpdateGrid(); } else if (BizObject.Id == 0) { BizObject.Role = Roles.Customer; BizObject.DateJoined = DateTime.Today; TaxiDbContext.Instance.Users.Add(BizObject); TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".مشتری با موفقیت افزوده شد", string.Empty); UpdateGrid(); } BizObject = null; } catch { MessageBoxRTL.Error("ذخیره سازی مشتری با خطا روبرو شد.", string.Empty); } } }
private void btnSecretaryThumbnail_Click(object sender, EventArgs e) { if (Session.CurrentUser.Role == Models.Roles.Admin) { this.CloseWithoutAsk(); new frmSecretaries(); } else { MessageBoxRTL.Info("لطفا درخواست خود را از طریق مدیریت تاکسی تلفنی پیگیری نمایید.", string.Empty); } }
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 UpdatePath() { Models.Path Path = TaxiDbContext.Instance.Paths.Find(BizObject.Id); Path.IsDeleted = false; Path.Origin = BizObject.Origin; Path.Destination = BizObject.Destination; Path.Cost = BizObject.Cost; TaxiDbContext.Instance.SaveChanges(); BizObject = null; MessageBoxRTL.Info(".مسیر با موفقیت ویرایش شد", string.Empty); UpdateGrid(); }
private void btnSave_Click(object sender, EventArgs e) { int cost = 0; int.TryParse(txtCost.Text.PersianToEnglish(), out cost); if (BizObject != null && !BizObject.IsDeleted) { BizObject.Cost = cost; } if (BizObject != null && Validation.Validate(BizObject)) { try { if (BizObject.Id != 0) { UpdatePath(); } else if (BizObject.Id == 0) { var CheckExistingPath = TaxiDbContext.Instance.Paths .SingleOrDefault(p => p.Origin == BizObject.Origin && p.Destination == BizObject.Destination); if (CheckExistingPath != null) { DialogResult dr = MessageBoxRTL.Ask("این مسیر قبلا ثبت شده است. آیا تمایل به ویرایش آن دارید؟", string.Empty); if (dr == DialogResult.OK) { BizObject = null; BizObject = CheckExistingPath; BizObject.Cost = cost; UpdatePath(); return; } else { return; } } BizObject.Cost = cost; TaxiDbContext.Instance.Paths.Add(BizObject); TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".مسیر با موفقیت افزوده شد", string.Empty); UpdateGrid(); } BizObject = null; } catch { MessageBoxRTL.Error("ذخیره سازی مسیر با خطا روبرو شد.", string.Empty); } } }
void UpdateDriver() { Models.Driver Driver = (Models.Driver)TaxiDbContext.Instance.Users.Single(d => d.Id == BizObject.Id); //Driver = BizObject; Driver.FullName = BizObject.FullName; Driver.Mobile = BizObject.Mobile; Driver.SharePercent = BizObject.SharePercent; Driver.Car.Color = BizObject.Car.Color; Driver.Car.Model = BizObject.Car.Model; Driver.Car.LicensePlate1 = BizObject.Car.LicensePlate1; Driver.Car.LicensePlate2 = BizObject.Car.LicensePlate2; Driver.Car.LicensePlate3 = BizObject.Car.LicensePlate3; Driver.Car.LicensePlate4 = BizObject.Car.LicensePlate4; BizObject.IsDeleted = false; TaxiDbContext.Instance.SaveChanges(); BizObject = null; MessageBoxRTL.Info(".راننده با موفقیت ویرایش شد", string.Empty); UpdateGrid(); }
void DeleteBizObject() { Models.Driver DriverToRemove = TaxiDbContext.Instance.Users.Find(int.Parse(gridDrivers.CurrentRow.Cells["Id"].Value.ToString())) as Models.Driver; DialogResult dr = MessageBoxRTL.Ask("آیا از حذف راننده اطمینان دارید؟", string.Empty); if (dr == DialogResult.OK) { try { //TaxiDbContext.Instance.Users.Remove(DriverToRemove); DriverToRemove.IsDeleted = true; TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".راننده با موفقیت حذف شد", string.Empty); UpdateGrid(); BizObject = null; } catch { MessageBoxRTL.Error("حذف راننده با خطا روبرو شد", string.Empty); } } }
private void btnChangePassword_Click(object sender, EventArgs e) { if (txtPassword.Text == txtPasswordRepeation.Text && Validation.ValidatePassword(txtPassword.Text)) { user.Password = EasyHash.Hash(txtPassword.Text); try { TaxiDbContext.Instance.AuthenticatedUsers.AddOrUpdate(user); TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info("کلمه عبور شما با موفقیت تغییر یافت.", string.Empty); this.Close(); } catch { MessageBoxRTL.Error("عملیات تغییر کلمه عبور موفقیت آمیز نبود. لطفا مجددا تلاش نمایید.", "خطا"); } } else { MessageBoxRTL.Error("کلمه عبور باید حداقل 8 کاراکتر شامل حداقل یک حرف بزرگ، یک حرف کوچک و یک عدد باشد", "خطا"); } }
void DeleteBizObject() { Models.Service ServiceToRemove = db.Services.Find(int.Parse(gridServices.CurrentRow.Cells["Id"].Value.ToString())); DialogResult dr = MessageBoxRTL.Ask("آیا از حذف سرویس اطمینان دارید؟", string.Empty); if (dr == DialogResult.OK) { try { ServiceToRemove.IsDeleted = true; db.SaveChanges(); MessageBoxRTL.Info(".سرویس با موفقیت حذف شد", string.Empty); ClearForm(); UpdateGrid(); BizObject = null; } catch { MessageBoxRTL.Error("حذف سرویس با خطا روبرو شد", string.Empty); } } }
void DeleteBizObject() { Models.Path PathToRemove = TaxiDbContext.Instance.Paths.Find(gridPaths.CurrentRow.Cells["Id"].Value); DialogResult dr = MessageBoxRTL.Ask("آیا از حذف مسیر اطمینان دارید؟", string.Empty); if (dr == DialogResult.OK) { try { //TaxiDbContext.Instance.Paths.Remove(PathToRemove); PathToRemove.IsDeleted = true; TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".مسیر با موفقیت حذف شد", string.Empty); UpdateGrid(); } catch { MessageBoxRTL.Error("حذف مسیر با خطا روبرو شد", string.Empty); } } BizObject = null; }
public override void btnLogin_Click(object sender, EventArgs e) { if (txtUsername.Text != string.Empty && txtPassword.Text != string.Empty) { string Password = EasyHash.Hash(txtPassword.Text); Session.CurrentUser = TaxiDbContext.Instance.AuthenticatedUsers.FirstOrDefault(au => au.Username == txtUsername.Text && au.Password == Password); if (Session.CurrentUser != null) { MessageBoxRTL.Info(string.Format("کاربر گرامی، {0} خوش آمدید", Session.CurrentUser.Username), ""); Session.RecentlyLogedIn = true; new frmDashboard(); Utility.Session.LoginForm = this; this.Hide(); //checking Role //switch (Session.CurrentUser.Role) //{ // case Roles.Admin: // new ManagerPanel(); // break; // case Roles.Secretary: // new SecretaryPanel(); // break; //} } else { MessageBoxRTL.Info("کاربری با این مشخصات یافت نشد. لطفا از صحت نام کاربری و کلمه عبور خود اطمینان حاصل نمایید", ""); } } else { MessageBoxRTL.Info("نام کاربری و کلمه عبور نمیتواند خالی باشد", ""); } base.btnLogin_Click(sender, e); }
private void btnSave_Click(object sender, EventArgs e) { if (BizObject != null) { try { if (ServiceToEdit != null && ServiceToEdit.Id != 0) { //BizObject = (Models.Driver)DriverToEdit.Clone(); //BizObject = (Models.Service)ServiceToEdit.Clone(); //Models.Service Service = (Models.Service)db.Services // .Single(d => d.Id == BizObject.Id); using (TaxiDbContext taxiDb = new TaxiDbContext()) { Models.Service service = taxiDb.Services.Find(ServiceToEdit.Id); service.DriverId = taxiDb.Users.OfType <Models.Driver>() .SingleOrDefault(d => d.FullName == comboboxDrivers.Text).Id; var NewPath = taxiDb.Paths.SingleOrDefault(p => p.OriginDestination == comboboxPaths.Text); service.ServicePaths.First().PathId = NewPath.Id; service.Transaction.Amount = NewPath.Cost; service.Transaction.IsPaid = checkboxIsPaid.Checked; if (taxiDb.Users.OfType <Models.Customer>().Any(c => c.FullName == txtCustomerName.Text)) { service.CustomerId = taxiDb.Users.OfType <Models.Customer>().Single(c => c.FullName == txtCustomerName.Text).Id; } else { service.Customer = new Models.Customer() { Role = Models.Roles.Customer, FullName = txtCustomerName.Text, Mobile = txtCustomerPhone.Text, Address = "ثبت نشده" }; } taxiDb.SaveChanges(); } db = new TaxiDbContext(); BizObject = null; MessageBoxRTL.Info(".سرویس با موفقیت ویرایش شد", string.Empty); ClearForm(); } else if (BizObject.Id == 0) { using (TaxiDbContext taxiDb = new TaxiDbContext()) { if (string.IsNullOrEmpty(txtCustomerName.Text)) { MessageBoxRTL.Error("نام مشتری ضروری است.", string.Empty); txtCustomerName.Focus(); return; } if (string.IsNullOrEmpty(txtCustomerPhone.Text) && !txtCustomerPhone.Text.StartsWith("09") && txtCustomerPhone.Text.Length != 11) { MessageBoxRTL.Error("شماره همراه مشتری ضروری است. و با 09 آغاز میشود", string.Empty); txtCustomerPhone.Focus(); return; } if (string.IsNullOrEmpty(comboboxDrivers.Text)) { MessageBoxRTL.Error("نام راننده ضروری است.", string.Empty); comboboxDrivers.Focus(); return; } if (string.IsNullOrEmpty(comboboxPaths.Text)) { MessageBoxRTL.Error("مسیر ضروری است.", string.Empty); comboboxPaths.Focus(); return; } //avoid adding a new customer with different name but exisiting phone -- TWO Customer With Same Phone if (taxiDb.Users.OfType <Models.Customer>().Any(c => c.Mobile == txtCustomerPhone.Text && c.FullName != txtCustomerName.Text)) { MessageBoxRTL.Error("شماره همراه مشتری قبلا ثبت شده است. لطفا شماره دیگری وارد نمایید", string.Empty); txtCustomerPhone.Focus(); return; } BizObject.Customer = taxiDb.Users.OfType <Models.Customer>().SingleOrDefault(c => c.Mobile == txtCustomerPhone.Text); if (BizObject.Customer == null) { BizObject.Customer = new Models.Customer() { FullName = txtCustomerName.Text, Mobile = txtCustomerPhone.Text, Address = "ثبت نشده", Role = Models.Roles.Customer }; } //driver if (!comboboxDrivers.Items.Contains(comboboxDrivers.Text)) { MessageBoxRTL.Error("رانندهای با این مشخصات وجود ندارد", string.Empty); comboboxDrivers.Focus(); return; } BizObject.Driver = taxiDb.Users.OfType <Models.Driver>() .SingleOrDefault(d => d.FullName == comboboxDrivers.Text); //path if (!comboboxPaths.Items.Contains(comboboxPaths.Text)) { MessageBoxRTL.Error("مسیری با این مشخصات وجود ندارد", string.Empty); comboboxPaths.Focus(); return; } BizObject.ServicePaths = new List <Models.ServicePath>(); var NewPath = taxiDb.Paths .SingleOrDefault(p => p.OriginDestination == comboboxPaths.Text); BizObject.ServicePaths.Add(new Models.ServicePath() { Path = NewPath }); BizObject.Transaction.IsPaid = checkboxIsPaid.Checked; BizObject.Transaction.Amount = NewPath.Cost; BizObject.OriginInDetail = txtOriginInDetail.Text; BizObject.DestinationInDetail = txtDestinationInDetail.Text; BizObject.DateTime = DateTime.Now; int Delay = 0; int.TryParse(txtDelay.Text, out Delay); BizObject.Delay = Delay; BizObject.IsActive = true; BizObject.IsDeleted = false; taxiDb.Services.Add(BizObject); taxiDb.SaveChanges(); } db = new TaxiDbContext(); BizObject = null; MessageBoxRTL.Info(".سرویس با موفقیت افزوده شد", string.Empty); ClearForm(); } } catch { MessageBoxRTL.Error("ذخیره سازی سرویس با خطا روبرو شد.", string.Empty); } } }
private void btnSave_Click(object sender, EventArgs e) { int SharePercent = 0; int.TryParse(txtSharePercent.Text.PersianToEnglish(), out SharePercent); if (BizObject != null && !BizObject.IsDeleted) { BizObject.SharePercent = SharePercent; } if (BizObject != null && Validation.Validate(BizObject)) { if (!LicensePlateCalculation.IsCompelete(BizObject.Car)) { return; } try { if (BizObject.Id != 0) { UpdateDriver(); } else if (BizObject.Id == 0) { //if(TaxiDbContext.Instance.Users.OfType<Models.Driver>().Any(u => u.Mobile == BizObject.Mobile)) //avoid repeating Driver 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.Driver CheckExistingDriver = TaxiDbContext.Instance.Users .OfType <Models.Driver>().Single(u => u.Mobile == BizObject.Mobile && u.FullName == BizObject.FullName); BizObject = null; BizObject = CheckExistingDriver; BizObject.SharePercent = SharePercent; UpdateDriver(); return; } return; } BizObject.SharePercent = SharePercent; BizObject.Role = Roles.Driver; TaxiDbContext.Instance.Users.Add(BizObject); TaxiDbContext.Instance.SaveChanges(); MessageBoxRTL.Info(".راننده با موفقیت افزوده شد", string.Empty); UpdateGrid(); BizObject = null; } } catch { MessageBoxRTL.Error("ذخیره سازی راننده با خطا روبرو شد.", string.Empty); } } }
private void btnContactUs_Click(object sender, EventArgs e) { MessageBoxRTL.Info("با شماره 09182871349 تماس بگیرید", string.Empty); }