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 btnSelect_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int _id = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, ColInvisiblePlanID); INSPECTION_PLAN ip = new INSPECTION_PLAN(); ip.PlanID = _id; UCInspectionHistory uchis = new UCInspectionHistory(ip.PlanID); ButtonSelectClicked = ip.PlanID; this.Close(); }
public List <INSPECTION_PLAN> getDataSource() { SqlConnection conn = MSSQLDBUtils.GetDBConnection(); conn.Open(); List <INSPECTION_PLAN> list = new List <INSPECTION_PLAN>(); INSPECTION_PLAN obj = null; String sql = " Use [rbi] Select [PlanID]" + ",[InspPlanName]" + ",[InspPlanDate]" + ",[Remarks]" + "From [dbo].[INSPECTION_PLAN]"; try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sql; using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (reader.HasRows) { obj = new INSPECTION_PLAN(); obj.PlanID = reader.GetInt32(0); obj.InspPlanName = reader.GetString(1); if (!reader.IsDBNull(2)) { obj.InspPlanDate = reader.GetDateTime(2); } if (!reader.IsDBNull(3)) { obj.Remarks = reader.GetString(3); } list.Add(obj); } } } } catch (Exception e) { MessageBox.Show(e.ToString(), "GET DATA FAIL!"); } finally { conn.Close(); conn.Dispose(); } return(list); }
private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { DialogResult dlr = MessageBox.Show("Are you sure to delete this inspection plan detail!", "Inspection Planner", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { //int rowSelected = gridView1.FocusedRowHandle;DataRow row = gridView1.GetFocusedDataRow(); // lấy dòng đang chọn int _id = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, ColInvisiblePlanID); INSPECTION_PLAN ip = new INSPECTION_PLAN(); ip.PlanID = _id; INSPECTION_PLAN_BUS busisp = new INSPECTION_PLAN_BUS(); busisp.delete(ip); Display(); } }
public void delete(INSPECTION_PLAN obj) { DAL.delete(obj.PlanID); }
public void edit(INSPECTION_PLAN obj) { DAL.edit(obj.PlanID, obj.InspPlanName, obj.InspPlanDate, obj.Remarks); }
public void add(INSPECTION_PLAN obj) { DAL.add(obj.InspPlanName, obj.InspPlanDate, obj.Remarks); }