Esempio 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__CarSystem model = new Common.BLL.Entity.GasStation.Base__CarSystem()
                {
                    id = id
                };

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

                if (opResult.status == BaseDAL.Base.EnumCommandStatus.success)
                {
                    reload();
                }
            }
            else
            {
                MessageBox.Show("رکوردی انتخاب نشده است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reload data
        /// </summary>
        void reload()
        {
            Common.BLL.Logic.GasStation.Base__CarSystem lCarModel = new Common.BLL.Logic.GasStation.Base__CarSystem(Common.Enum.EDatabase.GasStation);

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

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

                ///TODO: CHECK ERRORS
            }

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

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

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