Example #1
0
        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;

        }
Example #2
0
        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);
                        }

                       
                    } 

                    MergeRemains(_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;



        }
Example #3
0
        public bool SaveToBase(MDataSet.InvoiceMasterRow sourceRow)
        {

            MDataSet.RemainsDataTable _rem = new MDataSet.RemainsDataTable();

            try
            {
                int res = this.invoiceMasterTableAdapter.Update(sourceRow);

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

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

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

               return false;
         
         
              }
          catch (Exception err)
         
            {
              MessageBox.Show(err.Message);
              Log("SaveToBase(MDataSet.InvoiceMasterRow sourceRow) ERROR" + err.Message + " " + err.Source );  
            
              return false;
            }
            finally
            {
              /* RefreshData(sourceRow.Table as MDataSet.InvoiceMasterDataTable);*/
            }


            try
            {
               
                int res1 = this.invoiceDetailTableAdapter.Update(this.mDataSet.InvoiceDetail);
            }
            catch (DBConcurrencyException dbcx)
            {
                this.onInvoiceDetailDBCError(dbcx);

                this.SaveToBase(sourceRow);

                return false;
            }

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

                    caughtGlobalError(sqlerr);

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


                return false;


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

                return false;
            }
            finally
            {
                /* RefreshData(sourceRow.Table as MDataSet.InvoiceMasterDataTable);*/
            }



            return true;
        }
Example #4
0
        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
            {
                MergeRemains(_tmpRemains);
                this.mDataSet.InvoiceMaster.Merge(_tmpMaster);
                this.mDataSet.InvoiceDetail.Merge(_tmpDetail);

            }
            return true;
       

        
        }
Example #5
0
        //При удалении вызвать

        public bool RefreshData(MDataSet.RemainsRow sourceRow)
        {
            MDataSet.RemainsDataTable _RemainsDataTable = new MDataSet.RemainsDataTable();

            try
            {
                this.RemainsTableAdapter.FillByReceiptDetailRef(_RemainsDataTable, sourceRow.ReceiptDetailRef);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);

                Log("(MDataSet.RemainsRow sourceRow) " + err.Message + " " + err.Source + err.InnerException.Message);  
  
                return false;
            }
            finally
            {
                MergeRemains(_RemainsDataTable);
            }

            return true;
        }