/// <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__PlateCity model = new Common.BLL.Entity.GasStation.Base__PlateCity() { id = id }; Common.BLL.Logic.GasStation.Base__PlateCity lPlateCity = new Common.BLL.Logic.GasStation.Base__PlateCity(Common.Enum.EDatabase.GasStation); CommandResult opResult = lPlateCity.delete(model); if (opResult.status == BaseDAL.Base.EnumCommandStatus.success) { reload(); } } else { MessageBox.Show("رکوردی انتخاب نشده است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Reload data /// </summary> void reload() { Common.BLL.Logic.GasStation.Base__PlateCity lPlateCity = new Common.BLL.Logic.GasStation.Base__PlateCity(Common.Enum.EDatabase.GasStation); CommandResult opResult = lPlateCity.allData("", "code, city", false); resultGrid.DataSource = opResult.model; resultGrid.loadHeader(this.GetType().Name); }
/// <summary> /// Get Name City and Get cityId /// </summary> /// <param name="code"></param> /// <returns></returns> private string getNameCity(string code) { string result = null; Common.BLL.Logic.GasStation.Base__PlateCity lPlateCity = new Common.BLL.Logic.GasStation.Base__PlateCity(Common.Enum.EDatabase.GasStation); DataTable resultPlateCity = lPlateCity.allData("", "", false).model as DataTable; var resultItem = (from myRow in resultPlateCity.AsEnumerable() where myRow.Field <string>("code") == code select myRow).FirstOrDefault(); if (null != resultItem) { plateModel.plateCityId = (int)resultItem.ItemArray[0]; result = resultItem.ItemArray[3].ToString(); } return(result); }
/// <summary> /// Prepare /// </summary> private void prepare() { if (null == model) { model = new Common.BLL.Entity.GasStation.Base__PlateCity(); } else { // Load model data from db Common.BLL.Logic.GasStation.Base__PlateCity lPlateCity = new Common.BLL.Logic.GasStation.Base__PlateCity(Common.Enum.EDatabase.GasStation); CommandResult opResult = lPlateCity.read(model); ///TODO: CHECK ERRORS //if (opResult.status == BaseDAL.Base.EnumCommandStatus.success) //reload (); } // Fill Controls BaseBLL.General.FormModelHelper <Common.BLL.Entity.GasStation.Base__PlateCity> .fillControl(dataGroupBox, model); }
/// <summary> /// Insert new record /// </summary> private void saveRecord() { CommandResult opResult = null; Common.BLL.Logic.GasStation.Base__PlateCity lPlateCity = new Common.BLL.Logic.GasStation.Base__PlateCity(Common.Enum.EDatabase.GasStation); // Set author data if (model.id == 0) { #region Insert model.insertedById = Common.GlobalData.UserManager.currentUser.id; model.insertDate = DateTime.Now; opResult = lPlateCity.create(model); #endregion } else { #region Modify model.updatedById = Common.GlobalData.UserManager.currentUser.id; model.updateDate = DateTime.Now; opResult = lPlateCity.update(model); #endregion } // Create/Modify data if (opResult.status == BaseDAL.Base.EnumCommandStatus.success) { CloseSuccess(); } else { Logger.logger.log(opResult); MessageBox.Show(this, "خطا در ذخیره اطلاعات", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } }