public bool RefreshData(MDataSet.InvoiceMasterRow sourceRow) { if (sourceRow == null) { return(false); } MDataSet.InvoiceMasterDataTable _invoiceMasterDataTable = new MDataSet.InvoiceMasterDataTable(); MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); MDataSet.RemainsDataTable _remainsDataTable = new MDataSet.RemainsDataTable(); try { this.RemainsTableAdapter.FillByInvoiceMasterID(_remainsDataTable, sourceRow.ID); this.invoiceMasterTableAdapter.FillNew(_invoiceMasterDataTable); this.invoiceDetailTableAdapter.FillByInvoiceMasterRef(_invoiceDetailDataTable, sourceRow.ID); } catch (Exception err) { MessageBox.Show(err.Message); Log("RefreshData(MDataSet.InvoiceMasterRow sourceRow) " + err.Message + " " + err.Source); return(false); } finally { this.mDataSet.Remains.Merge(_remainsDataTable); this.mDataSet.InvoiceMaster.Merge(_invoiceMasterDataTable); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable); } return(true); }
private void onInvoiceDetailDBCError(DBConcurrencyException dbcx) { MDataSet.InvoiceDetailRow _invoiceDetailRow = dbcx.Row as MDataSet.InvoiceDetailRow; MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, (dbcx.Row as MDataSet.InvoiceDetailRow).ID); MDataSet.InvoiceDetailRow rowInDB = (_invoiceDetailDataTable.Rows[0] as MDataSet.InvoiceDetailRow); /*Сравнить изменения*/ if ((Convert.ToDecimal(_invoiceDetailRow["Quantity", DataRowVersion.Original]) != rowInDB.Quantity) | (Convert.ToDecimal(_invoiceDetailRow["PriceRetailNDS", DataRowVersion.Original]) != rowInDB.PriceRetailNDS)) { /*** Отменить **/ string strInDB = "Запись была изменена пользователем: \n"; string strMessage; strInDB += rowInDB.AuthorLastModif.ToString() + "\n"; strMessage = strInDB + "\n"; MessageBox.Show(strMessage + "Изменения отменены ", "Ошибка совмесного доступа", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable); } else { _invoiceDetailRow.ClearErrors(); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable, true); } }
public bool FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source, int numPeriods) { MDataSet.InvoiceMasterDataTable _tmpMaster = new MDataSet.InvoiceMasterDataTable(); MDataSet.InvoiceDetailDataTable _tmpDetail = new MDataSet.InvoiceDetailDataTable(); MDataSet.RemainsDataTable _rem = new MDataSet.RemainsDataTable(); MDataSet.ProductDataTable _prod = new MDataSet.ProductDataTable(); try { this.invoiceMasterTableAdapter.FillByPeriodNum(_tmpMaster, numPeriods); this.mDataSet.InvoiceMaster.Merge(_tmpMaster); foreach (MDataSet.InvoiceMasterRow mr in _tmpMaster) { this.invoiceDetailTableAdapter.FillByInvoiceMasterRef(_tmpDetail, mr.ID); this.RemainsTableAdapter.FillByInvoiceMasterID(_rem, mr.ID); foreach (MDataSet.RemainsRow _remrow in _rem) { if (_remrow.ProductRow == null) { this.productTableAdapter.FillById(_prod, _remrow.ProductRef); this.mDataSet.Product.Merge(_prod); } } this.mDataSet.Remains.Merge(_rem); this.mDataSet.InvoiceDetail.Merge(_tmpDetail); } } catch (SqlException sqlerr) { if (sqlerr.Class < 17) { MessageBox.Show(sqlerr.Message); } else { caughtGlobalError(sqlerr); } Log("FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message); return(false); } catch (Exception err) { MessageBox.Show(err.Message); Log("FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source) ERROR" + err.Message + " " + err.Source); return(false); } finally { } return(true); }
public bool RefreshData(MDataSet.InvoiceMasterRow sourceRow) { if (sourceRow == null) { return(false); } MDataSet.InvoiceMasterDataTable _invoiceMasterDataTable = new MDataSet.InvoiceMasterDataTable(); MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); MDataSet.RemainsDataTable _remainsDataTable = new MDataSet.RemainsDataTable(); try { this.invoiceDetailTableAdapter.Update(this.mDataSet.InvoiceDetail); this.RemainsTableAdapter.FillByInvoiceMasterID(_remainsDataTable, sourceRow.ID); this.invoiceMasterTableAdapter.FillNew(_invoiceMasterDataTable); this.invoiceDetailTableAdapter.FillNew(_invoiceDetailDataTable); } catch (DBConcurrencyException dbcx) { this.onInvoiceDetailDBCError(dbcx); this.LabelUser.Text = "Ошибка совмесного доступа"; MainForm.Log(dbcx.Message); RefreshData(sourceRow); return(false); } catch (Exception err) { MessageBox.Show(err.Message); Log("RefreshData(MDataSet.InvoiceMasterRow sourceRow) " + err.Message + " " + err.Source); return(false); } finally { MergeRemains(_remainsDataTable); this.mDataSet.InvoiceMaster.Merge(_invoiceMasterDataTable); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable); } return(true); }
public bool FillTableNewDocuments(MDataSet.InvoiceMasterDataTable source) { MDataSet.InvoiceMasterDataTable _tmpMaster = new MDataSet.InvoiceMasterDataTable(); MDataSet.InvoiceDetailDataTable _tmpDetail = new MDataSet.InvoiceDetailDataTable(); MDataSet.RemainsDataTable _tmpRemains = new MDataSet.RemainsDataTable(); try { this.RemainsTableAdapter.Fill(_tmpRemains); this.invoiceMasterTableAdapter.Fill(_tmpMaster); this.invoiceDetailTableAdapter.Fill(_tmpDetail); } catch (SqlException sqlerr) { if (sqlerr.Class < 17) { MessageBox.Show(sqlerr.Message); } else { caughtGlobalError(sqlerr); } Log("FillTableNewDocuments(MDataSet.ReceiptMasterDataTable source) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message); return(false); } catch (Exception err) { MessageBox.Show(err.Message); Log("FillTableNewDocuments(MDataSet.ReceiptMasterDataTable source) ERROR" + err.Message + " " + err.Source); return(false); } finally { this.mDataSet.Remains.Merge(_tmpRemains); this.mDataSet.InvoiceMaster.Merge(_tmpMaster); this.mDataSet.InvoiceDetail.Merge(_tmpDetail); } return(true); }
public bool FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source, DateTime begin) { MDataSet.InvoiceMasterDataTable _tmpMaster = new MDataSet.InvoiceMasterDataTable(); MDataSet.InvoiceDetailDataTable _tmpDetail = new MDataSet.InvoiceDetailDataTable(); try { this.invoiceMasterTableAdapter.FillByPeriod(_tmpMaster, begin); this.invoiceDetailTableAdapter.FillByPeriod(_tmpDetail, begin); } catch (SqlException sqlerr) { if (sqlerr.Class < 17) { MessageBox.Show(sqlerr.Message); } else { caughtGlobalError(sqlerr); } Log("FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message); return(false); } catch (Exception err) { MessageBox.Show(err.Message); Log("FillTableStockDocuments(MDataSet.InvoiceMasterDataTable source) ERROR" + err.Message + " " + err.Source + err.InnerException.Message); return(false); } finally { this.mDataSet.InvoiceMaster.Merge(_tmpMaster); this.mDataSet.InvoiceDetail.Merge(_tmpDetail); } return(true); }
public bool RefreshData(MDataSet.InvoiceDetailRow sourceRow) { MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); try { this.invoiceDetailTableAdapter.FillNew(_invoiceDetailDataTable); } catch (Exception err) { MessageBox.Show(err.Message); Log("RefreshData (MDataSet.InvoiceDetailRow sourceRow) " + err.Message + " " + err.Source + err.InnerException.Message); return(false); } finally { this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable, true); } return(true); }
private void onInvoiceDetailDBCError(DBConcurrencyException dbcx) { MDataSet.InvoiceDetailRow _invoiceDetailRow = dbcx.Row as MDataSet.InvoiceDetailRow; MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); if (_invoiceDetailRow.RowState == DataRowState.Deleted) { int _id = Convert.ToInt32(_invoiceDetailRow["ID", DataRowVersion.Original].ToString()); this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, _id); } else { this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, (dbcx.Row as MDataSet.InvoiceDetailRow).ID); } { _invoiceDetailRow.ClearErrors(); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable, true); } MainForm.Log(" onInvoiceDetailDBCError " + "успешно"); }
public virtual MDataSet.InvoiceDetailDataTable GetDataNew() { this.Adapter.SelectCommand = this.CommandCollection[4]; MDataSet.InvoiceDetailDataTable dataTable = new MDataSet.InvoiceDetailDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual MDataSet.InvoiceDetailDataTable GetDataByPeriod(System.Nullable<System.DateTime> begin) { this.Adapter.SelectCommand = this.CommandCollection[3]; if ((begin.HasValue == true)) { this.Adapter.SelectCommand.Parameters[1].Value = ((System.DateTime)(begin.Value)); } else { this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value; } MDataSet.InvoiceDetailDataTable dataTable = new MDataSet.InvoiceDetailDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual MDataSet.InvoiceDetailDataTable GetDataByInvoiceMasterRef(System.Nullable<int> InvoiceMasterRef) { this.Adapter.SelectCommand = this.CommandCollection[2]; if ((InvoiceMasterRef.HasValue == true)) { this.Adapter.SelectCommand.Parameters[1].Value = ((int)(InvoiceMasterRef.Value)); } else { this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value; } MDataSet.InvoiceDetailDataTable dataTable = new MDataSet.InvoiceDetailDataTable(); this.Adapter.Fill(dataTable); return dataTable; }