Ejemplo 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();
            }
        }
        private void frmGoodsVeterinariesEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            if (nGoodVeterinaryID.HasValue)
            {
                oGood.FillTableGoodsVeterinariesMapping(nGoodVeterinaryID, null, null);
                if (oGood.ErrorNumber != 0 || oGood.TableGoodsVeterinariesMapping == null || oGood.TableGoodsVeterinariesMapping.Rows.Count == 0)
                {
                    RFMMessage.MessageBoxError("Ошибка при получении данных о ветеринарном свидетельстве...");
                    bResult = false;
                }
                if (bResult)
                {
                    tGoodsVeterinaries = oGood.TableGoodsVeterinariesMapping;

                    DataRow r = tGoodsVeterinaries.Rows[0];
                    txtVeterinaryLicence.Text         = r["VeterinaryLicence"].ToString();
                    txtVeterinaryProducer.Text        = r["VeterinaryProducer"].ToString();
                    txtVeterinaryName.Text            = r["VeterinaryName"].ToString();
                    txtVeterinaryNote.Text            = r["VeterinaryNote"].ToString();
                    txtVeterinaryMark.Text            = r["VeterinaryMark"].ToString();
                    txtVeterinaryLaboratory.Text      = r["VeterinaryLaboratory"].ToString();
                    txtVeterinaryDateOfProducing.Text = r["VeterinaryDateOfProducing"].ToString();
                    sExportXML = r["VeterinaryExportXML"].ToString();

                    if (!Convert.IsDBNull(r["VeterinaryDateBeg"]))
                    {
                        dtpVeterinaryDateBeg.Value = (DateTime)r["VeterinaryDateBeg"];
                    }
                    else
                    {
                        dtpVeterinaryDateBeg.HideControl(false);
                    }
                }
            }
            else
            {
                oGood.FillTableGoodsVeterinariesMapping(-1, -1, null);
                tGoodsVeterinaries = oGood.TableGoodsVeterinariesMapping;

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

            try
            {
                tGoodsVeterinaries.PrimaryKey = new DataColumn[] { tGoodsVeterinaries.Columns["GoodID"] };
            }
            catch
            {
                tGoodsVeterinaries.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();
            }
        }
Ejemplo n.º 3
0
        private void frmInputsDocumentsEdit_Load(object sender, EventArgs e)
        {
            bool bResult = cboCurrency_Restore();

            if (bResult)
            {
                if (nInputDocumentID != 0)
                {
                    oInputDocument.ReFillOne(nInputDocumentID);
                    if (oInputDocument.ErrorNumber != 0 || oInputDocument.MainTable.Rows.Count == 0)
                    {
                        RFMMessage.MessageBoxError("Ошибка при получении данных о приходном документе...");
                        bResult = false;
                    }

                    if (nUserHostID.HasValue && (int)nUserHostID != (int)oInputDocument.HostID)
                    {
                        RFMMessage.MessageBoxError("Несовпадение прав доступа к данным хоста...");
                        Dispose();
                    }

                    if (bResult)
                    {
                        Text += " (" + nInputDocumentID.ToString() + ")";

                        nHostID = (int)oInputDocument.HostID;

                        txtPartnerSourceName.Text = oInputDocument.PartnerSourceName;
                        txtManagerName.Text       = oInputDocument.ManagerName + " " + oInputDocument.ManagerPhone;
                        txtNote.Text      = oInputDocument.Note;
                        txtOwnerName.Text = oInputDocument.OwnerName;

                        if (oInputDocument.DateBill.HasValue)
                        {
                            dtpDateBill.Value = Convert.ToDateTime(oInputDocument.DateBill);
                        }
                        txtBillNumber.Text    = oInputDocument.BillNumber;
                        txtFactureNumber.Text = oInputDocument.FactureNumber;

                        numAmountBill.Value = oInputDocument.AmountBill;
                        if (oInputDocument.CurrencyID != 0)
                        {
                            cboCurrency.SelectedValue = oInputDocument.CurrencyID;
                        }
                        else
                        {
                            cboCurrency.SelectedIndex = 0;
                        }
                        numVatAmountBill.Value = oInputDocument.VatAmountBill;

                        nOwnerID = oInputDocument.OwnerID;
                    }
                }
                else
                {
                    Text += " (создание) ";

                    oInput.ReFillOne((int)nInputID);

                    if (nUserHostID.HasValue && (int)nUserHostID != (int)oInput.HostID)
                    {
                        RFMMessage.MessageBoxError("Несовпадение прав доступа к данным хоста...");
                        Dispose();
                    }

                    nHostID = (int)oInput.HostID;
                    oInputDocument.HostID = oInput.HostID;

                    oInputDocument.DateInput = oInput.DateInput;

                    txtPartnerSourceName.Text = oInput.PartnerName;
                    txtManagerName.Text       = "";
                    txtNote.Text      = "созд.по заданию " + nInputID.ToString().Trim();
                    txtOwnerName.Text = oInput.OwnerName;

                    if (!Convert.IsDBNull(oInput.DateInput))
                    {
                        dtpDateBill.Value = Convert.ToDateTime(oInput.DateInput);
                    }
                    txtBillNumber.Text    = "";
                    txtFactureNumber.Text = "";

                    numAmountBill.Value = oInput.Amount;

                    cboCurrency.SelectedIndex = 0;

                    numVatAmountBill.Value = 0;

                    nOwnerID = oInput.OwnerID;
                }
                if (!dgvInputDocumentGoods_Restore())
                {
                    RFMMessage.MessageBoxError("Ошибка получения данных о товарах в приходном документе...");
                    Dispose();
                }

                string cColumnName = "";
                dgvInputDocumentGoods.ReadOnly = false;
                foreach (DataGridViewColumn c in dgvInputDocumentGoods.Columns)
                {
                    cColumnName = c.Name.ToUpper();
                    c.ReadOnly  = !(cColumnName.Contains("CHECK") ||
                                    cColumnName.Contains("BROUGHT") ||
                                    cColumnName.Contains("PRICE") ||
                                    cColumnName.Contains("VAT") ||
                                    cColumnName.Contains("CUSTOM") ||
                                    cColumnName.Contains("BYORDER"));
                }
                if (dgvInputDocumentGoods.Rows.Count > 0)
                {
                    // встать на первую строку, в ячейку "Коробок док."
                    dgvInputDocumentGoods.CurrentCell = dgvInputDocumentGoods.Rows[0].Cells["dgrcBoxBrought"];
                }
            }

            if (!bResult)
            {
                Dispose();
            }

            Host oHost = new Host();

            if (oHost.Count() > 1)
            {
                oHost.ReFillOne((int)oInputDocument.HostID);
                Text += " [" + oHost.Name + "]";
            }
        }