Esempio n. 1
0
        private void BindKTM()
        {
            if (this.IsPositionSelected())
            {
                string ktm                 = gridExProductsAndArticles.CurrentRow.Cells["KTM"].Value.ToString();
                string descriptor          = gridExProductsAndArticles.CurrentRow.Cells["Deskryptor"].Value.ToString();
                string positionKtm         = gridExAgreementsListGrouped.CurrentRow.Cells["KTM"].Value.ToString();
                string positionDescriptor  = gridExAgreementsListGrouped.CurrentRow.Cells["Deskryptor"].Value.ToString();
                int    agreementId         = (int)gridExAgreementsListGrouped.CurrentRow.Cells["IdUmowy"].Value;
                int    agreementPositionId = (int)gridExAgreementsListGrouped.CurrentRow.Cells["PozycjaId"].Value;

                if (MessageBox.Show(string.Format("W pozycji:\r\n\r\nKTM:\t\t{0}\r\nDeskryptor:\t{1}\r\n\r\nna umowie {2} zostanie zmieniony parametr:\r\n\r\nKTM:\t\t{3}",
                                                  positionKtm, positionDescriptor, agreementId.ToString(), ktm), "Przypisanie", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    try
                    {
                        AgreementPosition agreementPosition = AgreementPositionsRepo.GetByID(agreementPositionId);
                        agreementPosition.KTM = ktm;

                        AgreementPositionsRepo.InsertUpdate(agreementPosition);

                        MessageBox.Show("KTM został poprawnie zmieniony.", "Przypisanie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch
                    {
                        MessageBox.Show("Nie udało się wykonać powiązania.\r\nOdśwież listę i spróbuj ponownie.", "Przypisanie", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    this.LoadData();
                }
            }
            else
            {
                MessageBox.Show("Ta opcja wymaga zaznaczenia jednej pozycji umowy.", "Przypisanie", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        // GRIDS
        #region
        private void gridExPositions_SelectionChanged(object sender, EventArgs e)
        {
            // IF SELECTED ROW
            if (!this.isLoadingData && gridExPositions.CurrentRow != null && gridExPositions.CurrentRow.RowIndex > -1)
            {
                if (this.selectedPosition.Id != (int)gridExPositions.CurrentRow.Cells["id"].Value && !this.isCancellingSelection)
                {
                    if (this.isPositionSavePending && !this.isPositionAddPending)
                    {
                        if (MessageBox.Show("Masz niezapisane zmiany na pozycji, które utracisz przechodząc do innej.\r\nKliknij OK, aby przejść dalej lub Anuluj, aby wrócić i zapisać zmiany.", "Uwaga", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                        {
                            int positionId = (int)gridExPositions.CurrentRow.Cells["id"].Value;
                            this.selectedPosition = AgreementPositionsRepo.GetByID(positionId);
                            this.LoadPositionDetails();
                        }
                        else
                        {
                            this.isCancellingSelection = true;
                            this.SelectPositionById(this.selectedPosition.Id);
                            this.isCancellingSelection = false;
                        }
                    }
                    else
                    {
                        if (this.isPositionAddPending)
                        {
                            if (MessageBox.Show("Nowa pozycja nie została zapisana, utracisz ją jeśli przejdziesz dalej.\r\nKliknij OK, aby przejść dalej lub Anuluj, aby wrócić i zapisać zmiany.", "Uwaga", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                            {
                                this.gridPositionsRepo.DeleteLastRow();

                                int positionId = (int)gridExPositions.CurrentRow.Cells["id"].Value;
                                this.selectedPosition = AgreementPositionsRepo.GetByID(positionId);
                                this.LoadPositionDetails();
                                this.isPositionAddPending = false;
                            }
                            else
                            {
                                this.isCancellingSelection = true;
                                gridExPositions.MoveLast();
                                this.isCancellingSelection = false;
                            }
                        }
                        else
                        {
                            int positionId = (int)gridExPositions.CurrentRow.Cells["id"].Value;
                            this.selectedPosition = AgreementPositionsRepo.GetByID(positionId);
                            this.LoadPositionDetails();
                        }
                    }
                }
            }
            else
            {
                if (gridExPositions.CurrentRow != null && gridExPositions.CurrentRow.RowIndex > -1)
                {
                    int positionId = (int)gridExPositions.CurrentRow.Cells["id"].Value;
                    this.selectedPosition = AgreementPositionsRepo.GetByID(positionId);
                    this.LoadPositionDetails();
                }
            }
        }