private void btnSave_Click(object sender, EventArgs e) { string message = ""; string name = textCustomerName.Text.Trim(); string contact_no = textContactNo.Text.Trim(); string address = textAddress.Text.Trim(); if (Checks.checkEmpty(name) || Checks.checkEmpty(contact_no) || Checks.checkEmpty(address)) { message = "Please Fill All Boxes"; } else if (btnSave.Text.Contains("Add")) { if (common.AddCustomer(name, address, contact_no)) { message = "New Customer is Added"; LoadDatabase(); } else { message = "Customer Addition is Failed"; } } else if (btnSave.Text.Contains("Update")) { string customer_id = textCustomerID.Text.Trim(); if (Checks.checkNumber(customer_id)) { int cid = int.Parse(customer_id); if (common.UpdateCustomer(cid, name, address, contact_no)) { message = "Customer Record is Updated"; LoadDatabase(); } else { message = " Customer Update is Failed"; } textCustomerID.Text = textCustomerName.Text = textContactNo.Text = textAddress.Text = ""; btnSave.Text = "Add New Customer"; btnDelete.Enabled = false; } else { message = "Invalid Customer ID"; } } else { message = "Invalid Operations"; } MessageBox.Show(message); }
private void btnSave_Click(object sender, EventArgs e) { string message = ""; string video_title = textVideoTitle.Text.Trim(); string genre = textGenre.Text.Trim(); string year_of_release = textYear.Text.Trim(); int hours = (int)numericHour.Value; int minutes = (int)numericMinute.Value; if (Checks.checkEmpty(video_title) || Checks.checkEmpty(genre) || Checks.checkEmpty(year_of_release)) { message = "Please Fill All Boxes"; } else if (!Checks.checkNumber(year_of_release)) { message = "Please Enter Number in Year of Release"; } else { int year = int.Parse(year_of_release); int rental_cost = 5; if (year < DateTime.Now.Year - 5) { rental_cost = 2; } if (btnSave.Text.Contains("Add")) { if (common.AddVideo(video_title, year, genre, hours, minutes, rental_cost)) { textRentalCost.Text = rental_cost.ToString(); message = "Video Details is Saved"; LoadDatabase(); } else { message = "Video Details does not Saved"; } } else if (btnSave.Text.Contains("Update")) { string videoid = textVideoID.Text.Trim(); if (Checks.checkNumber(videoid)) { int vid = int.Parse(videoid); if (common.UpdateVideo(vid, video_title, year, genre, hours, minutes, rental_cost)) { message = "Record is Updated"; LoadDatabase(); } else { message = "Record in not Updated"; } } textVideoID.Text = textVideoTitle.Text = textGenre.Text = textYear.Text = textRentalCost.Text = "";; numericHour.Value = numericMinute.Value = 0; btnSave.Text = "Add New Video"; btnDelete.Enabled = false; } else { message = "Invalid Operation"; } } MessageBox.Show(message); }