private void btnremove_Click(object sender, EventArgs e) { DialogResult confirm = MessageBox.Show("Are you sure to remove it?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { try { Customer customer = mbmsEntities.Customers.Where(x => x.MeterID == meter.MeterID).SingleOrDefault(); MeterHistory meterhistory = new MeterHistory(); meterhistory.MeterHistoryID = Guid.NewGuid().ToString(); meterhistory.OldMeterID = meter.MeterID; meterhistory.CustomerID = customer.CustomerID; meterhistory.Remark = txtRemark.Text; meterhistory.RemovedDate = dtpremoveddate.Value; meterhistory.Active = true; meterhistory.CreatedDate = DateTime.Now; meterhistory.CreatedUserID = meter.CreatedUserID; meterservice.RemoveMeter(meterhistory); meterservice.DeletedMeter(meter); MessageBox.Show("Successfully removed Meter record'.", "Remove Success"); //EditCustomer Customerfrm customerForm = new Customerfrm(); customerForm.isEdit = true; customerForm.Text = "Edit Customer"; customerForm.meterHistory = meterhistory; customerForm.customerID = customer.CustomerID; customerForm.UserID = meter.CreatedUserID; customerForm.ShowDialog(); } catch (Exception ex) { MessageBox.Show("Error Occur"); } } }
private void dgvCustomerList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (e.ColumnIndex == 13) { //DeleteForCustomer if (!CheckingRoleManagementFeature("CustomerEditOrDelete")) { MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult result = MessageBox.Show(this, "Are you sure you want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result.Equals(DialogResult.OK)) { DataGridViewRow row = dgvCustomerList.Rows[e.RowIndex]; customerID = Convert.ToString(row.Cells[0].Value); dgvCustomerList.DataSource = ""; Customer customer = (from c in mbsEntities.Customers where c.CustomerID == customerID select c).FirstOrDefault(); customer.Active = false; customer.DeletedUserID = UserID; customer.DeletedDate = DateTime.Now; customerController.DeleteCustomer(customer); dgvCustomerList.DataSource = (from c in mbsEntities.Customers where c.Active == true orderby c.CustomerCode descending select c).ToList(); MessageBox.Show(this, "Successfully Deleted!", "Delete Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); FormRefresh(); } } else if (e.ColumnIndex == 11) { if (!CheckingRoleManagementFeature("CustomerView")) { MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DetailCustomerfrm detailCustomerForm = new DetailCustomerfrm(); detailCustomerForm.customerID = Convert.ToString(dgvCustomerList.Rows[e.RowIndex].Cells[0].Value); detailCustomerForm.ShowDialog(); } else if (e.ColumnIndex == 12) { //EditCustomer if (!CheckingRoleManagementFeature("CustomerEditOrDelete")) { MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Customerfrm customerForm = new Customerfrm(); customerForm.isEdit = true; customerForm.Text = "Edit Customer"; customerForm.customerID = Convert.ToString(dgvCustomerList.Rows[e.RowIndex].Cells[0].Value); customerForm.UserID = UserID; customerForm.ShowDialog(); this.Close(); } } }
private void btnAddNewCustomer_Click(object sender, EventArgs e) { if (!CheckingRoleManagementFeature("CustomerAdd")) { MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Customerfrm customerForm = new Customerfrm(); customerForm.Show(); }
// ADD private void simpleButton2_Click(object sender, EventArgs e) { Customerfrm frm = new Customerfrm(); frm.ListTours = this.toursList; frm.ListCus = this.cusList; frm.ListTrips = this.tripsList; frm.ListOrd = this.ordersList; frm.ShowDialog(); if (frm.DialogResult == System.Windows.Forms.DialogResult.OK) { btnAll.PerformClick(); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (lvCustomers.SelectedItems.Count > 0) { Customerfrm frm = new Customerfrm(); frm.ListTours = this.toursList; frm.ListCus = this.cusList; frm.ListTrips = this.tripsList; frm.ListOrd = this.ordersList; frm.Code = lvCustomers.SelectedItems[0].SubItems[0].Text; frm.ShowDialog(); if (frm.DialogResult == System.Windows.Forms.DialogResult.OK) { btnAll.PerformClick(); } } else { MessageBox.Show("Please choose the customer!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAddNewCustomer_Click(object sender, EventArgs e) { Customerfrm customerForm = new Customerfrm(); customerForm.Show(); }