private void frmGoodsCustomsEdit_Load(object sender, EventArgs e) { bool bResult = true; if (sCustomNumber != null && sCustomNumber.Trim().Length > 0) { oGood.FillTableGoodsCustoms(sCustomNumber, null, null, false); if (oGood.ErrorNumber != 0 || oGood.TableGoodsCustoms == null) { RFMMessage.MessageBoxError("Ошибка при получении данных о товарах в ГТД..."); bResult = false; } if (bResult) { tGoodsCustoms = oGood.TableGoodsCustoms; txtCustomNumber.Text = sCustomNumber; if (!Convert.IsDBNull(dDateBeg)) { dtpDateBeg.Value = (DateTime)dDateBeg; } else { dtpDateBeg.HideControl(false); } } } else { oGood.FillTableGoodsCustoms("", null, null, false); tGoodsCustoms = oGood.TableGoodsCustoms; dtpDateBeg.Value = DateTime.Now.Date; // список товаров первоначально пуст } if (bResult) { dgvData_Restore(); } if (!bResult) { Dispose(); } }
private void btnCustomNumberSelect_Click(object sender, EventArgs e) { // ранее введеные значения Good oGoodTemp = new Good(); oGoodTemp.FillTableGoodsCustoms(null, null, null, true); if (oGoodTemp.ErrorNumber != 0 || oGoodTemp.TableGoodsCustoms == null) { return; } if (oGoodTemp.TableGoodsCustoms.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных о ГТД..."); return; } DataTable tdСustoms = CopyTable(oGoodTemp.TableGoodsCustoms, "tdСustoms", "1 = 2", "CustomNumber"); tdСustoms.Columns.Add("ID", System.Type.GetType("System.Int32")); tdСustoms.Columns["ID"].AutoIncrement = true; DataTable tdCustomsX = CopyTable(oGoodTemp.TableGoodsCustoms, "tdСustomsX", "", "CustomNumber"); tdСustoms.Merge(tdCustomsX); if (StartForm(new frmSelectID(this, tdСustoms, "CustomNumber, DateBeg", "№ ГТД, Дата начала", false)) == DialogResult.Yes) { if (_SelectedID == null) { return; } int nGoodCustomID_Old = (int)_SelectedID; tdСustoms.PrimaryKey = new DataColumn[] { tdСustoms.Columns["ID"] }; DataRow r = tdСustoms.Rows.Find(nGoodCustomID_Old); if (r != null) { txtCustomNumber.Text = r["CustomNumber"].ToString(); } } _SelectedID = null; return; }