Пример #1
0
        public ReceiptDetailByRef(MDataSet.ReceiptMasterRow source, DataTable tableProduct, MainForm mainform)
        {
            InitializeComponent();

            _mainForm = mainform;

            _productTable = tableProduct;


            _isNds = source.StockRowByFK_ReceiptMaster_Stock.IsNDS;

            this.mDataSet = source.Table.DataSet as MDataSet;



            this.productBindingSource.DataSource = new DataView(_productTable, "IsNds=" + _isNds.ToString(), "Name", DataViewRowState.OriginalRows);

            this.productBindingSource.ResetBindings(true);
            //      this.productBindingSource.DataSource = this.mDataSet.Product.Select("IsNds=" + source.StockRowByFK_ReceiptMaster_Stock.IsNDS.ToString() );

            this.receiptMasterBindingSource.DataSource = source;
            this.receiptMasterBindingSource.ResetBindings(true);

            this.receiptMasterBindingSourceView.DataSource = source.Table;

            this.receiptMasterBindingSourceView.ResetBindings(true);
            this.receiptMasterBindingSourceView.CurrencyManager.Position = this.receiptMasterBindingSourceView.Find("ID", source.ID);

            this.receiptDetailBindingSource.DataSource = this.receiptMasterBindingSourceView;
            this.receiptDetailBindingSource.DataMember = "ReceiptMaster_ReceiptDetail";
            this.receiptDetailBindingSource.ResetBindings(true);
        }
Пример #2
0
        public ReceiptRowOrganization(MDataSet.ReceiptMasterRow source, int currentID)
        {
            //** receiptMasterBindingSource - таблица  *//

            InitializeComponent();

            _curentReceiptMasterRow = source;

            this.mDataSet = source.Table.DataSet as MDataSet;

            this.receiptMasterBindingSource.DataSource = new DataView(source.Table, "ID=" + _curentReceiptMasterRow.ID.ToString(), null, DataViewRowState.CurrentRows);


            this.receiptMasterBindingSource.ResetBindings(false);

            this.tradePutletBindingSource.DataSource = this.mDataSet.TradePutlet;
            this.tradePutletBindingSource.ResetBindings(false);


            _viewModifedOriginal              = new DataView(source.Table, "ID=" + _curentReceiptMasterRow.ID.ToString(), null, DataViewRowState.ModifiedOriginal);
            _viewModifedOriginal.ListChanged += new ListChangedEventHandler(_viewModifedOriginal_ListChanged);

            _viewChangesReceiptDetail = new DataView(this.mDataSet.ReceiptDetail, "ReceiptMasterRef=" + _curentReceiptMasterRow.ID.ToString(), null, DataViewRowState.Added | DataViewRowState.Deleted | DataViewRowState.ModifiedCurrent);

            _viewChangesReceiptDetail.ListChanged += new ListChangedEventHandler(_viewChangesReceiptDetail_ListChanged);


            (this.receiptMasterBindingSource.DataSource as DataView).ListChanged += new ListChangedEventHandler(_viewChangesReceiptDetail_ListChanged);


            this.organizationBindingSource.DataSource = this.mDataSet.Organization;
            this.organizationBindingSource.ResetBindings(false);

            this.stockBindingSource.DataSource = this.mDataSet.Stock;

            this.productBindingSource.DataSource = this.mDataSet.Product;

            this.receiptDetailBindingSource.DataSource = this.receiptMasterBindingSource;
            this.receiptDetailBindingSource.DataMember = "ReceiptMaster_ReceiptDetail";
            this.receiptDetailBindingSource.ResetBindings(true);



            if (source.ID < 0)
            {
                this.panelNumber.Enabled = false;
                this.btMove.Visible      = false;
            }
            if (_curentReceiptMasterRow.GetReceiptDetailRows().Length == 0)
            {
                this.btMove.Visible = false;
                //    this.btPrintAkt.Visible = false;
            }

            this.AuthorLabel.Text = "Автор :" + _curentReceiptMasterRow.AuthorCreate.ToString();
        }
Пример #3
0
        private bool SaveChanges()
        {
            if (this._changesMaster.Count > 0)
            {
                foreach (DataRowView _drMaster in _changesMaster)
                {
                    string _tag = "";

                    if (_drMaster.Row.HasVersion(DataRowVersion.Current))
                    {
                        _tag = "ReceiptRowOrganization" + (_drMaster.Row as MDataSet.ReceiptMasterRow)["ID", DataRowVersion.Current].ToString();
                    }
                    else
                    if (_drMaster.Row.HasVersion(DataRowVersion.Original))
                    {
                        _tag = "ReceiptRowOrganization" + (_drMaster.Row as MDataSet.ReceiptMasterRow)["ID", DataRowVersion.Original].ToString();
                    }

                    if (!(this.ParentForm as MainForm).FindOpenedTabs(_tag))
                    {
                        (this.ParentForm as MainForm).SaveToBase(_drMaster.Row as RetailTrade.MDataSet.ReceiptMasterRow);
                    }
                    else
                    {
                        MessageBox.Show("Завершите работу с документом", "Сохранение изменений", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return(false);
                    }
                }
            }


            if (_changesDetail.Count > 0)
            {
                foreach (DataRowView _drDetail in _changesDetail)
                {
                    string _tag = "ReceiptRowOrganization" + (_drDetail.Row as MDataSet.ReceiptDetailRow).ReceiptMasterRef.ToString();

                    if (!(this.ParentForm as MainForm).FindOpenedTabs(_tag))
                    {
                        MDataSet.ReceiptMasterRow _rwMaster = (_drDetail.Row as RetailTrade.MDataSet.ReceiptDetailRow).ReceiptMasterRow;
                        (this.ParentForm as MainForm).SaveToBase(_rwMaster);
                    }
                    else
                    {
                        MessageBox.Show("Завершите работу с документом ", "Сохранение изменений", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return(false);
                    }
                }
            }


            return(true);
        }
Пример #4
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            MDataSet.ReceiptMasterRow row = (this.receiptMasterBindingSource.Current as DataRowView).Row as MDataSet.ReceiptMasterRow;


            FormPrintDialog fromDialog = new FormPrintDialog("/ReportRetailTrade/ReceiptMasterByID");

            ReportParameter ReceiptMasterRef = new ReportParameter("ReceiptMasterRef", row.ID.ToString());

            fromDialog.reportViewer.ServerReport.SetParameters(new ReportParameter[] { ReceiptMasterRef });


            fromDialog.ShowDialog(this);
        }
Пример #5
0
        private void gridViewMasterStock_MasterRowCollapsing(object sender, MasterRowCanExpandEventArgs e)
        {
            MDataSet.ReceiptMasterRow _ReceiptMasterRow = this.gridViewMasterStock.GetDataRow(e.RowHandle) as MDataSet.ReceiptMasterRow;

            if (_ReceiptMasterRow == null)
            {
                return;
            }

            (this.ParentForm as MainForm).RefreshData(_ReceiptMasterRow);


            //
        }
Пример #6
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            if ((this.ParentForm as MainForm) != null)
            {
                this.receiptMasterBindingSource.CurrencyManager.EndCurrentEdit();

                MDataSet.ReceiptMasterRow sourceRow = (this.receiptMasterBindingSource.AddNew() as DataRowView).Row as MDataSet.ReceiptMasterRow;
                this.receiptMasterBindingSource.CurrencyManager.EndCurrentEdit();

                Object[] paramtrs = new Object[1] {
                    (this.receiptMasterBindingSource.CurrencyManager.Current as DataRowView).Row
                };

                (this.ParentForm as MainForm).ShowNewDataTab("ReceiptRowOrganization", "ReceiptRowOrganization.cs", paramtrs);
            }
        }
Пример #7
0
        public bool SaveToBaseDeletedDetails(MDataSet.ReceiptMasterRow sourceRow)
        {
            //   DataView _receiptDeleted = new DataView(this.mDataSet.ReceiptDetail, "ReceiptMasterRef=" + sourceRow.ID.ToString(), DataViewRowState.Deleted);

            DataRow[] _rows = this.mDataSet.ReceiptDetail.GetChanges(DataRowState.Deleted).Select("ReceiptMasterRef=" + sourceRow.ID.ToString());

            try
            {
                this.receiptDetailTableAdapter.Update(_rows);
            }

            catch (DBConcurrencyException dbcx)
            {
                this.onReceiptDetailDBCError(dbcx);
                return(false);
            }

            catch (SqlException sqlerr)
            {
                if (sqlerr.Class < 17)
                {
                    OnReceiptDetailSQLError(sqlerr, sourceRow);
                }
                else
                {
                    caughtGlobalError(sqlerr);
                }

                Log("SaveToBaseDeletedDetails ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message);

                return(false);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                Log("SaveToBaseDeletedDetails ERROR" + err.Message + " " + err.Source + err.InnerException.Message);


                return(false);
            }

            finally
            {
            }
            return(true);
        }
Пример #8
0
 private void gridViewRecMast_MasterRowExpanding(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowCanExpandEventArgs e)
 {
     MDataSet.ReceiptMasterRow _mastRow = this.gridViewRecMast.GetDataRow(e.RowHandle) as MDataSet.ReceiptMasterRow;
     if (_mastRow != null)
     {
         foreach (MDataSet.ReceiptDetailRow _detRow in _mastRow.GetReceiptDetailRows())
         {
             if (_detRow.ProductRow == null)
             {
                 if (!(this.ParentForm as MainForm).RefreshData(mDataSet.Product, _detRow.ProductRef))
                 {
                     _mastRow.RowError = "Выполните синхронизацию!";
                 }
             }
         }
     }
 }
Пример #9
0
        private void btMove_Click(object sender, EventArgs e)
        {
            MDataSet.ReceiptMasterRow _mastRow = this.gridViewRecMast.GetDataRow(this.gridViewRecMast.FocusedRowHandle) as MDataSet.ReceiptMasterRow;



            if (_mastRow != null)
            {
                foreach (MDataSet.ReceiptDetailRow _detRow in _mastRow.GetReceiptDetailRows())
                {
                    if (_detRow.ProductRow == null)
                    {
                        if (!(this.ParentForm as MainForm).RefreshData(mDataSet.Product, _detRow.ProductRef))
                        {
                            _mastRow.RowError = "Выполните синхронизацию!";
                        }
                    }
                }


                if (_mastRow.RowError != "")
                {
                    MessageBox.Show(_mastRow.RowError);
                    return;
                }


                if (DialogResult.OK == MessageBox.Show("Переместить выбранный документ?", "Приходные документы", MessageBoxButtons.OKCancel))
                {
                    try
                    {
                        (this.ParentForm as MainForm).receiptMasterTableAdapter.ReceiptMasterMove(_mastRow.ID);

                        (this.ParentForm as MainForm).RefreshData(this.mDataSet.ReceiptMaster as DataTable);
                        (this.ParentForm as MainForm).RefreshData(this.mDataSet.Remains as DataTable);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("Ошибка внутреннего перемещения!  " + err.Message);
                    }

                    (this.ParentForm as MainForm).FillTableNewDocuments(_table);
                }
            }
        }
Пример #10
0
        private void btDel_Click(object sender, EventArgs e)
        {
            MDataSet.ReceiptMasterRow row = this.gridViewMain.GetDataRow(this.gridViewMain.FocusedRowHandle) as MDataSet.ReceiptMasterRow;

            if (row == null)
            {
                return;
            }

            if (row.GetReceiptDetailRows().Length > 0)
            {
                MessageBox.Show("Документ не пустой!");
                return;
            }

            row.Delete();

            this.SaveChanges();
        }
Пример #11
0
        private bool SaveChanges()
        {
            if (this._changesReceiptMaster.Count > 0)
            {
                foreach (DataRowView _drMaster in _changesReceiptMaster)
                {
                    (this.ParentForm as MainForm).SaveToBase(_drMaster.Row as RetailTrade.MDataSet.ReceiptMasterRow);
                }
            }


            if (_changesReceiptDetail.Count > 0)
            {
                foreach (DataRowView _drDetail in _changesReceiptDetail)
                {
                    MDataSet.ReceiptMasterRow _rwMaster = (_drDetail.Row as RetailTrade.MDataSet.ReceiptDetailRow).ReceiptMasterRow;
                    (this.ParentForm as MainForm).SaveToBase(_rwMaster);
                }
            }

            return(true);
        }
Пример #12
0
        /*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();



            try
            { this.receiptMasterTableAdapter.FillNew(_ReceiptMasterDataTable);

              this.receiptDetailTableAdapter.FillByReceiptMasterRef(_ReceiptDetailDataTable, sourceRow.ID);
              foreach (MDataSet.ReceiptDetailRow detrow in _ReceiptDetailDataTable)
              {
                  if (detrow.ProductRow == null)
                  {
                      this.productTableAdapter.FillById(_productDataTable, detrow.ProductRef);
                  }

                  this.mDataSet.Product.Merge(_productDataTable);
              }
            }
            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.ReceiptMaster.Merge(_ReceiptMasterDataTable);
                this.mDataSet.ReceiptDetail.Merge(_ReceiptDetailDataTable);
                this.mDataSet.ReceiptMaster.AcceptChanges();
                this.mDataSet.ReceiptDetail.AcceptChanges();
            }
            return(true);
        }
Пример #13
0
        private void btMakeNew_Click(object sender, EventArgs e)
        {
            MDataSet.ReceiptMasterRow _dr = (this.grid.FocusedView as GridView).GetDataRow((this.grid.FocusedView as GridView).FocusedRowHandle) as MDataSet.ReceiptMasterRow;

            if ((_dr as MDataSet.ReceiptMasterRow) != null)
            {
                if (_dr.DocumentTypeRef != 1)
                {
                    return;
                }

                try
                {
                    (this.ParentForm as MainForm).receiptMasterTableAdapter.ReceiptMasterMakeToNew((_dr as MDataSet.ReceiptMasterRow).ID);
                    (this.ParentForm as MainForm).RefreshData((_dr as MDataSet.ReceiptMasterRow));
                    (this.ParentForm as MainForm).FillTableNewDocuments(this.mDataSet.ReceiptMaster);
                    (this.ParentForm as MainForm).RefreshData(this.mDataSet.Remains);
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
Пример #14
0
 private void OnReceiptMasterSQLError(SqlException sqlerr, MDataSet.ReceiptMasterRow sourceRow)
 {
     MessageBox.Show(sqlerr.Message, "SqlException");
 }
Пример #15
0
        public bool SaveToBase(MDataSet.ReceiptMasterRow sourceRow)
        {
            try
            {
                int res = this.receiptMasterTableAdapter.Update(sourceRow);
            }

            catch (DBConcurrencyException dbcx)
            {
                this.onReceiptMasterDBCError(dbcx);
            }

            catch (SqlException sqlerr)
            {
                if (sqlerr.Class < 17)
                {
                    OnReceiptMasterSQLError(sqlerr, sourceRow);
                }
                else
                {
                    caughtGlobalError(sqlerr);
                }


                Log("SaveToBase(MDataSet.ReceiptMasterRow sourceRow) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message);


                return(false);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                Log("SaveToBase(MDataSet.ReceiptMasterRow sourceRow) ERROR" + err.Message + " " + err.Source + err.InnerException.Message);


                return(false);
            }

            finally
            {
            }

            if (sourceRow.RowState == DataRowState.Detached)
            {
                return(true);
            }


            /*Сохранить дочерние*/
            try
            {
                int res = this.receiptDetailTableAdapter.Update(this.mDataSet.ReceiptDetail);
            }
            catch (DBConcurrencyException dbcx)
            {
                this.onReceiptDetailDBCError(dbcx);
                return(false);
            }

            catch (SqlException sqlerr)
            {
                if (sqlerr.Class < 17)
                {
                    OnReceiptDetailSQLError(sqlerr, sourceRow);
                }
                else
                {
                    caughtGlobalError(sqlerr);
                }

                Log("SaveToBase(MDataSet.ReceiptMasterRow sourceRow) ERROR" + sqlerr.Message + " " + sqlerr.Source);


                return(false);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);

                Log("SaveToBase(MDataSet.ReceiptMasterRow sourceRow) ERROR" + err.Message + " " + err.Source + err.InnerException.Message);


                return(false);
            }

            finally
            {
                //  RefreshData(sourceRow);
            }


            return(true);
        }