private void btnSave_Click(object sender, EventArgs e) { if (txtPlanName.Text == "") { MessageBox.Show("Please enter Inspection Plan Name!", "Inspection / Mitigation Planner", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (datePlanDate.Text == "") { MessageBox.Show("Please enter Inspection Plan Date!", "Inspection / Mitigation Planner", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { INSPECTION_PLAN ip = new INSPECTION_PLAN(); ip.InspPlanName = txtPlanName.Text; ip.InspPlanDate = datePlanDate.DateTime; INSPECTION_PLAN_BUS ipBus = new INSPECTION_PLAN_BUS(); List <INSPECTION_PLAN> listPlan = ipBus.getDataSource(); foreach (INSPECTION_PLAN ds in listPlan) { if (ds.InspPlanName == txtPlanName.Text) { MessageBox.Show("Plan Name already exist!", "Inspection / Mitigation Planner", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } } ButtonSaveClicked = true; ipBus.add(ip); this.Close(); } } }
private void Display() { try { gridControl.DataSource = null; INSPECTION_PLAN_BUS busisp = new INSPECTION_PLAN_BUS(); gridControl.DataSource = busisp.getDataSource(); } catch (Exception e) { MessageBox.Show(e.ToString()); } }