private void btnAprilSave_Click(object sender, EventArgs e) { fourt_mr April = new fourt_mr(); April.memberName = comboBox1.Text.Trim(); April.monthlyAmount = txtMonthlyAmount.Text.Trim(); April.interest = txtInterest.Text.Trim(); April.paidAmount = txtPaidAmount.Text.Trim(); April.collectedAmount = txtCollectAmt.Text.Trim(); April.bcName = labelBcName.Text.Trim(); if (txtInterest.Text == "") { MessageBox.Show("Enter The Interest % Amount"); } else if (txtPaidAmount.Text == "") { MessageBox.Show("Enter Paid Amount"); } else { using (MonthlyContributionEntities ma = new MonthlyContributionEntities()) { ma.fourt_mr.Add(April); ma.SaveChanges(); MessageBox.Show(" Record Save For" + Environment.NewLine + " Member: " + comboBox1.Text + Environment.NewLine + " To Beei Name: " + labelBcName.Text); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (txtFullName.Text == "" || txtEmailId.Text == "" || txtMobile.Text == "") { MessageBox.Show("Fill The Required Fields "); } else if (!this.txtEmailId.Text.Contains('@') || !this.txtEmailId.Text.Contains('.')) { MessageBox.Show("Enter Wright Email Address"); } else { ReloadForm(); model.fullName = txtFullName.Text.Trim(); model.mobile = txtMobile.Text.Trim(); model.emailId = txtEmailId.Text.Trim(); model.DOB = dateTimePickerDOB.Value; model.city = txtCity.Text.Trim(); //model.createdAt = DateTime.Now; using (MonthlyContributionEntities MC = new MonthlyContributionEntities()) { if (model.id == 0) //for Insert { MC.Members.Add(model); } else { MC.Entry(model).State = EntityState.Modified;//for Update } try { MC.SaveChanges(); } catch (DbEntityValidationException c) { foreach (var eve in c.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } } clear(); MessageBox.Show("Submitted Successfully."); dvg(); } }
// Button click private void txtCreate_Click(object sender, EventArgs e) { if (txtBcName.Text == "" || txtTotalAmount.Text == "" || txtTotalMember.Text == "") // validation for empty textbox { MessageBox.Show("Fill The Required Fields"); } else { model.fullName = txtBcName.Text.Trim(); model.totalAmount = txtTotalAmount.Text.Trim(); model.totalMember = txtTotalMember.Text.Trim(); model.duration = txtDuration.Text.Trim(); model.monthlyContryPerPerson = txtCountry.Text.Trim(); model.startDate = dtpStartdate.Value; model.endDate = dtpEndDate.Value; int i = 0; List <int> ChkedRow = new List <int>(); using (MonthlyContributionEntities mc = new MonthlyContributionEntities()) { if (model.id == 0) { mc.Bcs.Add(model); } try // for Entity Exception { mc.SaveChanges(); } catch (DbEntityValidationException c) { foreach (var eve in c.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } MessageBox.Show("Beesi Created Succefully."); } } }
// delet buttons private void btnDeleteFirst_Click(object sender, EventArgs e) { if (MessageBox.Show("Are You Sure to Delete this Record ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (MonthlyContributionEntities MC = new MonthlyContributionEntities()) { var entry = MC.Entry(m1); if (entry.State == EntityState.Detached) { MC.First_mR.Attach(m1); MC.First_mR.Remove(m1); MC.SaveChanges(); MessageBox.Show("Deleted Successfully"); } } } dgvFirstR.DataSource = mc.First_mR.ToList(); }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are You Sure to Delete this Record ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (MonthlyContributionEntities MC = new MonthlyContributionEntities()) { var entry = MC.Entry(model); if (entry.State == EntityState.Detached) { MC.Members.Attach(model); MC.Members.Remove(model); MC.SaveChanges(); clear(); MessageBox.Show("Deleted Successfully"); dvg(); } } } }
private void btnCreate_Click(object sender, EventArgs e) { if (txtFisrtN.Text == "") { MessageBox.Show("Enter First Name"); } else if (txtUserN.Text == "") { MessageBox.Show("Enter User Name"); } else if (txtPassword.Text == "" || txtconfpass.Text == "") { MessageBox.Show("Enter Password"); } else if (txtPassword.Text != txtconfpass.Text) { MessageBox.Show("Password and confirm password not same"); } else { model.FirstName = txtFisrtN.Text.Trim(); model.LastName = txtLastN.Text.Trim(); model.UserName = txtUserN.Text.Trim(); model.Email = txteml.Text.Trim(); model.PhoneNo = txtPhoneN.Text.Trim(); model.Password = txtPassword.Text.Trim(); model.ConfirmPassword = txtconfpass.Text.Trim(); using (MonthlyContributionEntities m = new MonthlyContributionEntities()) { if (m.Users.Any(o => o.UserName == txtUserN.Text)) { MessageBox.Show("User Name Alreaady Exists !"); } else { m.Users.Add(model); m.SaveChanges(); MessageBox.Show("Account Created. "); clear(); } } } }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are You Sure to Delete this Details ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (MonthlyContributionEntities MC = new MonthlyContributionEntities()) { var entry = MC.Entry(model); if (entry.State == EntityState.Detached) { MC.Bcs.Attach(model); MC.Bcs.Remove(model); MC.SaveChanges(); clear(); MessageBox.Show("Deleted Successfully"); dgvBeesi.DataSource = mc.Bcs.ToList(); } } } btnDelete.Enabled = false; txtCreate.Enabled = true; }
// save the Monthly data to table by month private void btnJanSave_Click(object sender, EventArgs e) { First_mR jan = new First_mR(); jan.memberName = comboBox1.Text.Trim(); jan.monthlyAmount = txtMonthlyAmount.Text.Trim(); jan.interest = txtInterest.Text.Trim(); jan.paidAmount = txtPaidAmount.Text.Trim(); jan.collectedAmount = txtCollectAmt.Text.Trim(); jan.bcName = labelBcName.Text.Trim(); if (txtInterest.Text == "") { MessageBox.Show("Enter Interest"); } else if (txtPaidAmount.Text == "") { MessageBox.Show("Enter Paid Amount"); } else if (comboBox1.Text == "Select") { MessageBox.Show("Please Select Member"); } else { MC.First_mR.Add(jan); MC.SaveChanges(); MessageBox.Show(" Record Save For" + Environment.NewLine + " Member: " + comboBox1.Text + Environment.NewLine + " To Beei Name: " + labelBcName.Text); } }