Example #1
0
        private void storageGroupsEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            switch (e.Button.Index)
            {
            case 1:     //Add
            {
                using (StorageGroupEditFm storageGroupEditFm = new StorageGroupEditFm(Utils.Operation.Add, new StorageGroupsDTO()))
                {
                    if (storageGroupEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        int return_StorageGroupId = storageGroupEditFm.Return();

                        storageGroupsService = Program.kernel.Get <IStorageGroupsService>();
                        storageGroupsEdit.Properties.DataSource = storageGroupsService.GetStorageGroups();
                        storageGroupsEdit.EditValue             = return_StorageGroupId;
                    }
                }
                break;
            }

            case 2:     //Edit
            {
                using (StorageGroupEditFm storageGroupEditFm = new StorageGroupEditFm(Utils.Operation.Add, (StorageGroupsDTO)storageGroupsEdit.GetSelectedDataRow()))
                {
                    if (storageGroupEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        int return_StorageGroupId = storageGroupEditFm.Return();

                        storageGroupsService = Program.kernel.Get <IStorageGroupsService>();
                        storageGroupsEdit.Properties.DataSource = storageGroupsService.GetStorageGroups();
                        storageGroupsEdit.EditValue             = return_StorageGroupId;
                    }
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }
Example #2
0
        private void editSpravochItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            switch (gridName)
            {
            case Utils.GridName.Units:

                if (unitsBS.Count != 0)
                {
                    using (UnitEditFm unitEditFm = new UnitEditFm(Utils.Operation.Update, (UnitsDTO)unitsBS.Current))
                    {
                        if (unitEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_UnitId = unitEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            unitsService            = Program.kernel.Get <IUnitsService>();
                            unitsBS.DataSource      = unitsService.GetUnits();
                            spravochGrid.DataSource = unitsBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("UnitId", return_UnitId);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                }
                break;

            case Utils.GridName.Users:

                if (usersBS.Count != 0)
                {
                    using (UserEditFm userEditFm = new UserEditFm(Utils.Operation.Update, (UsersDTO)usersBS.Current))
                    {
                        if (userEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_UserId = userEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            usersService            = Program.kernel.Get <IUsersService>();
                            usersBS.DataSource      = usersService.GetUsers();
                            spravochGrid.DataSource = usersBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("UserId", return_UserId);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                }
                break;

            case Utils.GridName.Contractors:

                if (contractorsBS.Count != 0)
                {
                    using (ContractorEditFm contractorEditFm = new ContractorEditFm(Utils.Operation.Update, (ContractorsDTO)contractorsBS.Current))
                    {
                        if (contractorEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_ContractorId = contractorEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            contractorsService       = Program.kernel.Get <IContractorsService>();
                            contractorsBS.DataSource = contractorsService.GetContractors();
                            spravochGrid.DataSource  = contractorsBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("ContractorId", return_ContractorId);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                    break;
                }
                break;

            case Utils.GridName.StorageGroups:

                if (storageGroupsBS.Count != 0)
                {
                    using (StorageGroupEditFm storageGroupEditFm = new StorageGroupEditFm(Utils.Operation.Update, (StorageGroupsDTO)storageGroupsBS.Current))
                    {
                        if (storageGroupEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_StorageGroupId = storageGroupEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            storageGroupsService       = Program.kernel.Get <IStorageGroupsService>();
                            storageGroupsBS.DataSource = storageGroupsService.GetStorageGroups();
                            spravochGrid.DataSource    = storageGroupsBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("StorageGroupId", return_StorageGroupId);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                    break;
                }
                break;

            case Utils.GridName.Measures:

                if (measuresBS.Count != 0)
                {
                    new MeasureEditFm(Utils.Operation.Update, (MeasuresDTO)measuresBS.Current, (obj) => { }).ShowDialog();
                    measuresService       = Program.kernel.Get <IMeasuresService>();
                    measuresBS.DataSource = measuresService.GetMeasures();

                    this.spravochGrid.DataSource = null;
                    this.spravochGrid.DataSource = this.measuresBS;
                }
                break;

            case Utils.GridName.Currency:

                if (currencyBS.Count != 0)
                {
                    //new CurrencyEditFm(Utils.Operation.Update, (CurrencyDTO)currencyBS.Current, (obj) => { }).ShowDialog();
                    currencyService              = Program.kernel.Get <ICurrencyService>();
                    currencyBS.DataSource        = currencyService.GetCurrency();
                    this.spravochGrid.DataSource = null;
                    this.spravochGrid.DataSource = this.currencyBS;
                }
                break;

            case Utils.GridName.ZoneNames:

                if (zoneNamesBS.Count != 0)
                {
                    new ZoneNameEditFm(Utils.Operation.Update, (ZoneNamesDTO)zoneNamesBS.Current).ShowDialog();
                    zoneNamesService             = Program.kernel.Get <IZoneNamesService>();
                    zoneNamesBS.DataSource       = zoneNamesService.GetZones();
                    this.spravochGrid.DataSource = null;
                    this.spravochGrid.DataSource = this.zoneNamesBS;
                }
                break;

            case Utils.GridName.Persons:

                if (personsBS.Count != 0)
                {
                    using (PersonEditFm personEditFm = new PersonEditFm(Utils.Operation.Update, (PersonsDTO)personsBS.Current))
                    {
                        if (personEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_PersonId = personEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            personsService          = Program.kernel.Get <IPersonsService>();
                            personsBS.DataSource    = personsService.GetPersons();
                            spravochGrid.DataSource = personsBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("PersonId", return_PersonId);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                }
                break;

            case Utils.GridName.Profession:

                if (professionBS.Count != 0)
                {
                    using (ProfessionEditFm professionEditFm = new ProfessionEditFm(Utils.Operation.Update, (ProfessionsDTO)professionBS.Current))
                    {
                        if (professionEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_Id = professionEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            professionService       = Program.kernel.Get <IProfessionService>();
                            personsBS.DataSource    = professionService.GetProfession();
                            spravochGrid.DataSource = professionBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("Id", return_Id);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                }
                break;

            case Utils.GridName.Alarms:

                if (alarmsBS.Count != 0)
                {
                    using (AlarmEditFm alarmEditFm = new AlarmEditFm(Utils.Operation.Update, (AlarmsDTO)alarmsBS.Current))
                    {
                        if (alarmEditFm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            int return_Id = alarmEditFm.Return();
                            spravochGridView.BeginDataUpdate();

                            settingsService         = Program.kernel.Get <ISettingsService>();
                            alarmsBS.DataSource     = settingsService.GetAlarms();
                            spravochGrid.DataSource = alarmsBS;

                            spravochGridView.EndDataUpdate();
                            int rowHandle = spravochGridView.LocateByValue("Id", return_Id);
                            spravochGridView.FocusedRowHandle = rowHandle;
                        }
                    }
                }
                break;

            default:

                break;
            }
        }