Esempio n. 1
0
        public bool SaveToBase(MDataSet.InvoiceDetailRow sourceRow)
        {

            if (sourceRow.HasErrors) 
                return false;
            if ((sourceRow.RowState == DataRowState.Detached)|(sourceRow.RowState==DataRowState.Unchanged))
                return true;
            if (_changesInvoiceDetail.Count == 0)
                return true;

            MDataSet.InvoiceMasterRow _invoiceMasterRow;
            _invoiceMasterRow = sourceRow.InvoiceMasterRow;
            /*если  после Update полей на сервере*/
           
            if ((sourceRow.RowState == DataRowState.Modified)&sourceRow.HasVersion(DataRowVersion.Current))
            {
               if (Convert.ToInt32(sourceRow["ID", DataRowVersion.Original]) != Convert.ToInt32(sourceRow["ID", DataRowVersion.Current]))
                    return true;
            }
            //*Если удаление *//
            if (sourceRow.RowState==DataRowState.Deleted)
              _invoiceMasterRow = this.mDataSet.InvoiceMaster.FindByID(Convert.ToInt32((sourceRow as MDataSet.InvoiceDetailRow)["InvoiceMasterRef", DataRowVersion.Original]));

          try
          {

              int res = this.invoiceDetailTableAdapter.Update(sourceRow);
              this.LabelUser.Text = "Успешно обновлена строка";

          }

          catch (DBConcurrencyException dbcx)
          {
              this.onInvoiceDetailDBCError(dbcx);
              this.LabelUser.Text = "Ошибка совмесного доступа";
              return false;
          }

          catch (SqlException sqlerr)
          {

             if (sqlerr.Class < 17)
             {
                 OnInvoiceDetailSQLError(sqlerr,sourceRow);
             }
             else
                caughtGlobalError(sqlerr);

            Log("SaveToBase(MDataSet.InvoiceDetailRow sourceRow) ERROR" + sqlerr.Message + " " + sqlerr.Source + sqlerr.InnerException.Message);  
            
               return false;

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

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

              return false;
          }
            finally
            {
                this.RemainsTableAdapter.Fill(this.mDataSet.Remains);
                RefreshData(_invoiceMasterRow);
            }

            return true;

        }
Esempio n. 2
0
        public bool SaveToBase(MDataSet.InvoiceMasterRow sourceRow)
        {

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

            try
            {
                int res = this.invoiceMasterTableAdapter.Update(sourceRow);
             
                
                int res1 = this.invoiceDetailTableAdapter.Update(this.mDataSet.InvoiceDetail);

                if (sourceRow.HasVersion(DataRowVersion.Current))
                {

                    this.RemainsTableAdapter.FillByInvoiceMasterID(_rem, sourceRow.ID);

                    this.mDataSet.Remains.Merge(_rem);
                }
               }
              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);
            }
            return true;
        }