/*MDataset, документы на складе, из открытого периода, новые, X дней*/ public bool FillTableStockDocuments(MDataSet.ReceiptMasterDataTable source,DateTime begin) { MDataSet.ReceiptMasterDataTable _tmpMaster = new MDataSet.ReceiptMasterDataTable(); MDataSet.ReceiptDetailDataTable _tmpDetail = new MDataSet.ReceiptDetailDataTable(); MDataSet.ProductDataTable _prod = new MDataSet.ProductDataTable(); try { this.receiptMasterTableAdapter.FillByPeriod(_tmpMaster,begin); /* foreach(DataRow masRow in _tmpMaster ) { MDataSet.ManufacturerDataTable _man = new MDataSet.ManufacturerDataTable(); this.manufacturerTableAdapter.FillByReceiptMasterRef(_man, (masRow as MDataSet.ReceiptMasterRow).ID); this.productTableAdapter.FillByReceiptId(_prod, (masRow as MDataSet.ReceiptMasterRow).ID); // this.manufacturerTableAdapter.FillByReceiptMasterRef(_man , (masRow as MDataSet.ReceiptMasterRow).ID); this.mDataSet.Product.Merge(_prod); this.mDataSet.Manufacturer.Merge(_man); } this.receiptDetailTableAdapter.FillByPeriod(_tmpDetail, begin); this.mDataSet.ReceiptDetail.Merge(_tmpDetail);*/ this.mDataSet.ReceiptMaster.Merge(_tmpMaster); } catch (SqlException sqlerr) { if (sqlerr.Class < 17) { MessageBox.Show(sqlerr.Message); } else caughtGlobalError(sqlerr); Log("FillTableStockDocuments(MDataSet.ReceiptMasterDataTable source) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message); return false; } catch (Exception err) { DataRow[] dr = this.mDataSet.Manufacturer.GetErrors(); DataColumn[] dc = dr[0].GetColumnsInError(); MessageBox.Show(err.Message); Log("FillTableStockDocuments(MDataSet.ReceiptMasterDataTable source) ERROR" + err.Message + " " + err.Source ); return false; } finally { } return true; }
/*FillNew + Merge + FillDetailsById*/ public bool RefreshData(MDataSet.ReceiptMasterRow sourceRow) { MDataSet.ReceiptMasterDataTable _ReceiptMasterDataTable = new MDataSet.ReceiptMasterDataTable(); MDataSet.ReceiptDetailDataTable _ReceiptDetailDataTable = new MDataSet.ReceiptDetailDataTable(); MDataSet.ProductDataTable _productDataTable = new MDataSet.ProductDataTable(); // MDataSet.ReceiptRemainsDataTable _ReceiptRemainsDataTable = new MDataSet.ReceiptRemainsDataTable(); try { this.productTableAdapter.FillByReceiptId(_productDataTable, sourceRow.ID); this.receiptMasterTableAdapter.FillNew(_ReceiptMasterDataTable); this.receiptDetailTableAdapter.FillByReceiptMasterRef(_ReceiptDetailDataTable, sourceRow.ID); } catch (Exception err) { MessageBox.Show(err.Message); Log("RefreshData(MDataSet.ReceiptMasterRow sourceRow) ERROR" + err.Message + " " + err.Source + err.InnerException.Message); return false; } finally { this.mDataSet.Product.Merge(_productDataTable); this.mDataSet.ReceiptMaster.Merge(_ReceiptMasterDataTable); this.mDataSet.ReceiptDetail.Merge(_ReceiptDetailDataTable); this.mDataSet.ReceiptMaster.AcceptChanges(); this.mDataSet.ReceiptDetail.AcceptChanges(); this.mDataSet.ReceiptMaster.AcceptChanges(); } return true; }