Ejemplo n.º 1
0
        /// <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__PlateType model = new Common.BLL.Entity.GasStation.Base__PlateType()
                {
                    id = id
                };

                Common.BLL.Logic.GasStation.Base__PlateType lPlateType = new Common.BLL.Logic.GasStation.Base__PlateType(Common.Enum.EDatabase.GasStation);
                CommandResult opResult = lPlateType.delete(model);

                if (opResult.status == BaseDAL.Base.EnumCommandStatus.success)
                {
                    reload();
                }
            }
            else
            {
                MessageBox.Show("رکوردی انتخاب نشده است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        private void reloadCombo()
        {
            //Plate type
            Common.BLL.Logic.GasStation.Base__PlateType lPlateType = new Common.BLL.Logic.GasStation.Base__PlateType(Common.Enum.EDatabase.GasStation);
            DataTable resultPlateType = lPlateType.allData("", "", false).model as DataTable;

            plateTypeComboBox.fillByTable(resultPlateType, "id", "type");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reload data
        /// </summary>
        void reload()
        {
            Common.BLL.Logic.GasStation.Base__PlateType lPlateType = new Common.BLL.Logic.GasStation.Base__PlateType(Common.Enum.EDatabase.GasStation);

            CommandResult opResult = lPlateType.allData("", "", false);

            resultGrid.DataSource = opResult.model;
            resultGrid.loadHeader(this.GetType().Name);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Prepare
        /// </summary>
        private void prepare()
        {
            if (null == model)
            {
                model = new Common.BLL.Entity.GasStation.Base__PlateType();
            }
            else
            {
                // Load model data from db
                Common.BLL.Logic.GasStation.Base__PlateType lPlateType = new Common.BLL.Logic.GasStation.Base__PlateType(Common.Enum.EDatabase.GasStation);
                CommandResult opResult = lPlateType.read(model);

                ///TODO: CHECK ERRORS
            }

            // Fill Controls
            BaseBLL.General.FormModelHelper <Common.BLL.Entity.GasStation.Base__PlateType> .fillControl(dataGroupBox, model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Insert new record
        /// </summary>
        private void saveRecord()
        {
            CommandResult opResult = null;

            Common.BLL.Logic.GasStation.Base__PlateType lPlateType = new Common.BLL.Logic.GasStation.Base__PlateType(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 = lPlateType.create(model);
                #endregion
            }
            else
            {
                #region Modify
                model.updatedById = Common.GlobalData.UserManager.currentUser.id;
                model.updateDate  = DateTime.Now;

                opResult = lPlateType.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);
            }
        }