Пример #1
0
        public int AddNew(MachineDTO dtoMachine)
        {
            MachineValidator validator = new MachineValidator();

            validator.ValidateBeforeSaveNew(dtoMachine);

            Database db = CommonLib.Common.CurrentDatabase;

            db.KeepConnection = true;
            db.BeginTransaction();
            try {
                MachineDAO daoMachine = new MachineDAO(CommonLib.Common.CurrentDatabase);
                daoMachine.AddNew(null, dtoMachine);

                db.Commit();
                return(1);
            }
            catch (Exception err) {
                db.Rollback();
                throw err;
            }
            finally {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
Пример #2
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string MACHINE_CD = shtView.GetValue(shtView.ActiveRowIndex, (int)eColView.MACHINE_CD).ToString();

                MachineValidator validator = new MachineValidator();
                ErrorItem        errorItem = null;
                errorItem = validator.ValidateBeforeDelete(MACHINE_CD.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo);
                if (dr == MessageDialogResult.No)
                {
                    return;
                }


                m_machineController.DeleteMachine(MACHINE_CD.ToNZString());
                LoadData(false);

                MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
Пример #3
0
        public int SaveUpdate(MachineDTO data)
        {
            MachineValidator validator = new MachineValidator();

            validator.ValidateBeforeSaveUpdate(data);

            MachineDAO dao = new MachineDAO(CommonLib.Common.CurrentDatabase);

            return(dao.UpdateWithoutPK(null, data));
        }
Пример #4
0
        public override void OnSaveAndClose()
        {
            MachineUIDM model = dmcMachine.SaveData(new MachineUIDM());

            try
            {
                #region
                MachineValidator validator = new MachineValidator();

                ErrorItem errorItem = null;
                errorItem = validator.CheckEmptyMachineNo(new NZString(txtMachineNo, txtMachineNo.Text));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyMachineType(new NZString(cboMachineType, cboMachineType.Text));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyProcess(new NZString(cboProcess, cboProcess.SelectedValue));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyMachineGroup(new NZString(cboMachineGroup, cboMachineGroup.Text));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyProject(new NZString(cboProject, cboProject.SelectedValue));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                #endregion

                // Confirm to save.
                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new EVOFramework.Message(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel || dr == MessageDialogResult.No)
                {
                    return;
                }

                if (eMode.ADD == m_screenMode)
                {
                    m_MachineController.SaveNew(model);
                }
                else
                {
                    m_MachineController.SaveUpdate(model);
                }

                MessageDialog.ShowInformation(this, null, new EVOFramework.Message(Messages.eInformation.INF9003.ToString()).MessageDescription);

                m_dummyDialogResult = DialogResult.OK;
                DialogResult        = m_dummyDialogResult;
                this.Close();
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }