/// <summary> /// Delete menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void deleteMenu_Click(object sender, EventArgs e) { if ((null != resultGrid.CurrentRow) && (MessageBox.Show(this, "آیا برای حذف اطمینان دارید؟", "حذف رکورد", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)) { int id; // Get id id = Convert.ToInt32(resultGrid.CurrentRow.Cells["id"].Value); Common.BLL.Entity.GasStation.Base__CarType model = new Common.BLL.Entity.GasStation.Base__CarType() { id = id }; Common.BLL.Logic.GasStation.Base__CarType lCarType = new Common.BLL.Logic.GasStation.Base__CarType(Common.Enum.EDatabase.GasStation); CommandResult opResult = lCarType.delete(model); if (opResult.status == BaseDAL.Base.EnumCommandStatus.success) { reload(); } } else { MessageBox.Show("رکوردی انتخاب نشده است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Modify menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void modifyMenu_Click(object sender, EventArgs e) { if (null != resultGrid.CurrentRow) { int id; // Get id id = Convert.ToInt32(resultGrid.CurrentRow.Cells["id"].Value); Common.BLL.Entity.GasStation.Base__CarType model = new Common.BLL.Entity.GasStation.Base__CarType() { id = id }; CarTypeEntryForm form = new CarTypeEntryForm(model); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { reload(); } } else { MessageBox.Show("رکوردی انتخاب نشده است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Constructor /// </summary> public CarTypeEntryForm(Common.BLL.Entity.GasStation.Base__CarType model = null) { InitializeComponent(); // Set data this.model = model; init(); }
/// <summary> /// Prepare /// </summary> private void prepare() { if (null == model) { model = new Common.BLL.Entity.GasStation.Base__CarType(); } else { // Load model data from db Common.BLL.Logic.GasStation.Base__CarType lCarType = new Common.BLL.Logic.GasStation.Base__CarType(Common.Enum.EDatabase.GasStation); CommandResult opResult = lCarType.read(model); ///TODO: CHECK ERRORS } // Fill Controls BaseBLL.General.FormModelHelper <Common.BLL.Entity.GasStation.Base__CarType> .fillControl(dataGroupBox, model); }