Exemple #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (tbCode.Text.Length < 4 & btnSearch.Visible)
            {
                searchResult = new FrmSearchResult(tbNames.Text, SearchBy.Name);
            }
            else
            {
                searchResult = new FrmSearchResult(tbCode.Text, SearchBy.Code);
            }

            if (searchResult.ShowDialog() == DialogResult.Yes)
            {
                tbCode.Text       = searchResult.SelectedCode;
                tbNames.Text      = searchResult.SelectedName;
                tbPriceDC.Text    = searchResult.SelectedPriceDC;
                tbPricePC.Text    = searchResult.SelectedPricePC;
                cbDiscont.Checked = searchResult.SelectedDiscont;

                // Устанавливаем в ComboBox с периодами каталога выбранное значение. Если такового нет в БД - добавляем
                if (CatalogPeriod.SearchSuchCatalog(searchResult.SelectedPeriodText))
                {
                    cbCatalog.Text = searchResult.SelectedPeriodText;
                }
                else
                {
                    // добавляем каталожный период в БД (без проверки на его существование)
                    SkladBase.AddCatalogPeriod(searchResult.selectedPeriod, searchResult.selectedYear);

                    cbCatalog.DataSource = CatalogPeriod.catalogPeriod;
                    cbCatalog.Text       = searchResult.SelectedPeriodText;
                }
            }
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbmPeriod.Text) || tbmPeriod.Text == " " || tbmPeriod.Text == "  ")
            {
                lblErrorPeriodExist.Visible = false;
                lblError.Visible            = true;
                return;
            }

            Period = Int32.Parse(tbmPeriod.Text);
            Year   = (int)nudYear.Value;

            if (CatalogPeriod.SearchSuchCatalog(InputedPeriodText))
            {
                lblErrorPeriodExist.Text    = string.Format($"Период \"{InputedPeriodText}\" существует !");
                lblError.Visible            = false;
                lblErrorPeriodExist.Visible = true;
                return;
            }

            this.DialogResult = DialogResult.OK;
        }
Exemple #3
0
        public FrmAdd(string code, string name, string priceDC, string pricePC, bool discont, string periodText, int period, int year) : this()
        {
            tbCode.Text       = code;
            tbNames.Text      = name;
            tbPriceDC.Text    = priceDC;
            tbPricePC.Text    = pricePC;
            cbDiscont.Checked = discont;

            // Устанавливаем в ComboBox с периодами каталога выбранное значение. Если такового нет в БД - добавляем
            if (CatalogPeriod.SearchSuchCatalog(periodText))
            {
                cbCatalog.Text = periodText;
            }
            else
            {
                // добавляем каталожный период в БД (без проверки на его существование)
                SkladBase.AddCatalogPeriod(period, year);

                cbCatalog.DataSource = CatalogPeriod.catalogPeriod;
                cbCatalog.Text       = periodText;
            }
        }