Exemple #1
0
        // Заполняем список услуг
        private bool GetContractListServices(int indexRow, int NameOfServiceCol, int SummCol)
        {
            Service sv;
            decimal OldSumm   = contract.Summ;
            int     countRows = dt.Rows.Count;

            // Функция, сбрасывающая результат чтения данных в случае ошибки.
            bool ErrorLoadRow()
            {
                contract.ClearServices();
                contract.Summ = OldSumm;    // Возвращаем старое значение суммы
                return(false);
            }

            if (indexRow >= countRows)
            {
                return(ErrorLoadRow());
            }

            contract.Summ = 0;
            while ((sv = GetContractService(contract.Client, dt.Rows[indexRow++], NameOfServiceCol, SummCol)) != null)
            {
                contract.AddService(sv);   // добавляем услугу в список услуг договора

                if (indexRow >= countRows) // Проверяем, полностью ли прочитан файл
                {
                    return(ErrorLoadRow());
                }
            }
            return(true);
        }
Exemple #2
0
        private void btnAddServiceToContract_Click(object sender, EventArgs e)
        {
            Service service = (Service)cbxContractService.SelectedItem;
            int     quantity;

            if (rbUnlimited.Checked)
            {
                quantity = -1;
            }
            else
            {
                quantity = (int)Math.Round(nudSpecificQuanity.Value);
            }

            currentContract?.AddService(service, rtbAgreement.Text, quantity);
            currentContract.Save();

            LoadCurentServices();
            MessageBox.Show("Added Service Agreement to Contract!", "Success!");
        }