Esempio n. 1
0
        private void frmGoodsQualitiesEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            if (nGoodQualityID.HasValue)
            {
                oGood.FillTableGoodsQualitiesMapping(nGoodQualityID, null, null);
                if (oGood.ErrorNumber != 0 || oGood.TableGoodsQualitiesMapping == null || oGood.TableGoodsQualitiesMapping.Rows.Count == 0)
                {
                    RFMMessage.MessageBoxError("Ошибка при получении данных о декларации соответствия...");
                    bResult = false;
                }
                if (bResult)
                {
                    tGoodsQualities = oGood.TableGoodsQualitiesMapping;

                    DataRow r = tGoodsQualities.Rows[0];
                    txtQualityLicence.Text = r["QualityLicence"].ToString();
                    txtQualityIssuer.Text  = r["QualityIssuer"].ToString();
                    txtQualityHolder.Text  = r["QualityHolder"].ToString();
                    if (!Convert.IsDBNull(r["QualityDateBeg"]))
                    {
                        dtrDates.dtpBegDate.Value = (DateTime)r["QualityDateBeg"];
                    }
                    else
                    {
                        dtrDates.dtpBegDate.HideControl(false);
                    }
                    if (!Convert.IsDBNull(r["QualityDateEnd"]))
                    {
                        dtrDates.dtpEndDate.Value = (DateTime)r["QualityDateEnd"];
                    }
                    else
                    {
                        dtrDates.dtpEndDate.HideControl(false);
                    }
                }
            }
            else
            {
                oGood.FillTableGoodsQualitiesMapping(-1, -1, null);
                tGoodsQualities = oGood.TableGoodsQualitiesMapping;

                dtrDates.dtpBegDate.Value = DateTime.Now.Date;
                dtrDates.dtpEndDate.Value = DateTime.Now.Date;
                // список товаров пуст
            }

            try
            {
                tGoodsQualities.PrimaryKey = new DataColumn[] { tGoodsQualities.Columns["GoodID"] };
            }
            catch
            {
                tGoodsQualities.PrimaryKey = null;
            }

            if (_SelectedInputDocumentID.HasValue)
            {
                InputDocument oInputDocument = new InputDocument();
                if (oInputDocument.ErrorNumber != 0)
                {
                    bResult = false;
                }
                else
                {
                    oInputDocument.ReFillOne((int)_SelectedInputDocumentID);
                    txtInputDocument.Text = oInputDocument.MainTable.Rows[0]["ID"].ToString() + " [" +
                                            ((DateTime)oInputDocument.MainTable.Rows[0]["DateInput"]).ToShortDateString() + "] " +
                                            oInputDocument.MainTable.Rows[0]["PartnerSourceName"].ToString();
                    btnInputSelect.Enabled = btnInputClear.Enabled = false;
                }
            }

            if (_SelectedInputID.HasValue)
            {
                Input oInput = new Input();
                if (oInput.ErrorNumber != 0)
                {
                    bResult = false;
                }
                else
                {
                    oInput.ReFillOne((int)_SelectedInputID);
                    txtInput.Text = oInput.MainTable.Rows[0]["ID"].ToString() + " [" +
                                    ((DateTime)oInput.MainTable.Rows[0]["DateInput"]).ToShortDateString() + "] " +
                                    oInput.MainTable.Rows[0]["PartnerName"].ToString();
                    btnInputDocumentSelect.Enabled = btnInputDocumentClear.Enabled = false;
                }
            }


            if (bResult)
            {
                grdData_Restore();
            }

            if (!bResult)
            {
                Dispose();
            }
        }