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(); } }
private void btnVeterinaryLicenceSelect_Click(object sender, EventArgs e) { // ранее введеные значения Good oGoodTemp = new Good(); if (chkInList.Checked && tGoodsVeterinaries.Rows.Count > 0) { // только по списку string sGoodsList = ""; foreach (DataRow g in tGoodsVeterinaries.Rows) { sGoodsList += g["GoodID"].ToString() + ","; } oGoodTemp.FillTableGoodsVeterinariesMapping(null, null, sGoodsList); } else { oGoodTemp.FillTableGoodsVeterinariesMapping(null, null, null); } if (oGoodTemp.ErrorNumber != 0 || oGoodTemp.TableGoodsVeterinariesMapping == null) { return; } if (oGoodTemp.TableGoodsVeterinariesMapping.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных о свидетельствах..."); return; } // уникальные значения DataView vGoodsVeterinariesMapping = new DataView(oGoodTemp.TableGoodsVeterinariesMapping); DataTable tTable1 = vGoodsVeterinariesMapping.ToTable(true, "VeterinaryLicence", "VeterinaryProducer", "VeterinaryName", "VeterinaryNote", "VeterinaryMark", "VeterinaryLaboratory", "VeterinaryDateOfProducing"); DataTable tTable2 = CopyTable(tTable1, "tTable2", "1 = 2", ""); tTable2.Columns.Add("ID", System.Type.GetType("System.Int32")); tTable2.Columns["ID"].AutoIncrement = true; tTable2.Merge(tTable1); DataTable tdLicence = CopyTable(tTable2, "tdLicence", "", "VeterinaryLicence"); if (StartForm(new frmSelectID(this, tdLicence, "VeterinaryLicence, VeterinaryProducer, VeterinaryName, VeterinaryNote, " + "VeterinaryMark, VeterinaryLaboratory, VeterinaryDateOfProducing, VeterinaryDateBeg", "Сертификат №, Производитель, Наименование, Разрешение, " + "Маркировка, Лаборатория, Дата выработки, Дата нач.", false)) == DialogResult.Yes) { if (_SelectedID == null) { return; } int nGoodVeterinaryID_Old = (int)_SelectedID; tdLicence.PrimaryKey = new DataColumn[] { tdLicence.Columns["ID"] }; DataRow r = tdLicence.Rows.Find(nGoodVeterinaryID_Old); if (r != null) { 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(); } } _SelectedID = null; return; }