private void btnBill_Click(object sender, EventArgs e) { CookieSubscriber.ID = subscriberBLL.MaxSubscriberId(); CookieSubscriber.FullName = subscriber.Name + " " + subscriber.LastName; CookieSubscriber.PersonalNumber = subscriber.PersonalNo; CookieSubscriber.SubscriptionPlan = subscriptionPlanVariable; CookieSubscriber.BillingDate = bill.BillingDate; CookieSubscriber.ExpirationDate = bill.ExpirationDate; CookieSubscriber.Price = bill.Price; CookieSubscriber.Cashier = FormLoggedUser.Name + "\t " + FormLoggedUser.LastName; BillingAddMember billingAddMember = new BillingAddMember(); billingAddMember.ShowDialog(); }
private void btnUpdateMemberSubscription_Click(object sender, EventArgs e) { try { subscriber = subscriberBLL.Get(int.Parse(txtMemberID.Text)); subscriber.UpdDate = DateTime.Parse(txtFromDate.Text); subscriber.ExpirationDate = DateTime.Parse(txtTillDate.Text); subscriber.IsActive = true; subscriber.UpdBy = FormLoggedUser.Id; SubscriberValidation subscriberValidator = new SubscriberValidation(); subscriberValidator.subscriber = subscriber; subscriberValidator.ValidateSubscriber(); ValidationResult results = subscriberValidator.Validate(subscriber); if (results.IsValid == false) { foreach (ValidationFailure failure in results.Errors) { MessageBox.Show($"{failure.ErrorMessage}", "Error Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { subscriberBLL.Update(subscriber); #region BILL/////////////////////////////////////////// bill.BillingDate = DateTime.Now; bill.RegistrationDate = DateTime.Parse(txtFromDate.Text); bill.ExpirationDate = DateTime.Parse(txtTillDate.Text); if (bill.ExpirationDate.Month == bill.RegistrationDate.AddMonths(1).Month) { bill.Price = 10;//10euro per Muaj } if (bill.ExpirationDate.Year == bill.RegistrationDate.AddYears(1).Year) { bill.Price = 100;//100euro per Vit } bill.BillTypeId = 1; bill.IsActive = true; bill.InsBy = FormLoggedUser.Id; BillValidation billValidator = new BillValidation(); billValidator.bill = bill; billValidator.ValidateBill(); ValidationResult resultsBill = billValidator.Validate(bill); if (resultsBill.IsValid == false) { foreach (ValidationFailure failure in resultsBill.Errors) { MessageBox.Show($"{failure.ErrorMessage}", "Error Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { bill.SubscriberId = int.Parse(txtMemberID.Text); billBLL.Add(bill); MessageBox.Show("The subscription was successfully updated!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); CookieSubscriber.ID = int.Parse(txtMemberID.Text); CookieSubscriber.FullName = subscriber.Name + " " + subscriber.LastName; CookieSubscriber.PersonalNumber = subscriber.PersonalNo; CookieSubscriber.SubscriptionPlan = subscriptionPlanVariable; CookieSubscriber.BillingDate = bill.BillingDate; CookieSubscriber.ExpirationDate = subscriber.ExpirationDate; CookieSubscriber.Price = bill.Price; CookieSubscriber.Cashier = FormLoggedUser.Name + "\t " + FormLoggedUser.LastName; BillingAddMember billingAddMember = new BillingAddMember(); billingAddMember.ShowDialog(); } #endregion } } catch (Exception ex) { MessageBox.Show(ex.Message); } }