Dim _Connection As DbConnection = Nothing
Dim _Transaction As DbTransaction = Nothing
Try
Dim _DB As Database = DatabaseFactory.CreateDatabase(BL_DBCONNECTION_STRING)
_Connection = _DB.CreateConnection
_Connection.Open()
_Transaction = _Connection.BeginTransaction()
gvPurchasings.PostEditor()
With BLPurchasings
.PurchasingID = Convert.ToInt64(IIf(lblID.Text = String.Empty, 0, lblID.Text))
.VendorID = leVendors.EditValue
.PurchaseDate = dePurchaseDate.EditValue
.VoucherNo = teVoucherNo.EditValue
.Note = meeNote.EditValue
.TotalAmount = Convert.ToDecimal(IIf(Not IsDBNull(gvPurchasings.Columns("Amount")), gvPurchasings.Columns("Amount").SummaryText, 0))
.Discount = seDiscount.EditValue
.TaxAmount = seTaxAmount.EditValue
.TotalPayable = seTotalPayable.EditValue
.CreatedBy = UserID
.UpdatedBy = UserID
.Insert(_DB, _Transaction)
End With
With BLPruchasingsDescription
For i As Integer = 0 To Me.gvPurchasings.RowCount
If Not gvPurchasings.GetRowCellDisplayText(i, gvPurchasings.Columns(0)) = "" Then
.PurchasingID = BLPurchasings.NewPurchasingID
.StockID = Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn1)
.Quantity = Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn4))
.PurchasePrice = Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn22))
.Discount = Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn5))
.Amount = Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn6))
.Insert(_DB, _Transaction)
.StockID = Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn1)
.Amount = Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn4)) * Val(Me.gvPurchasings.GetRowCellDisplayText(i, GridColumn22))
.UpdateStockByPurchasings(_DB, _Transaction)
End If
Next
End With
_Transaction.Commit()
Dim frm As New frmSavedOk
frm.Text = BL_SAVESUCCESS_CONFIRMATION_TITLE
frm.lblTitle.Text = BL_SAVESUCCESS_CONFIRMATION_TITLELABEL
frm.lblDescription.Text = BL_SAVESUCCESS_CONFIRMATION_DESCRIPTIONLABEL
frm.ShowDialog()
Me.ClearFormData()
Catch ex As Exception
_Transaction.Rollback()
MessageError(ex.ToString)
Finally
If _Connection.State = ConnectionState.Open Then
_Connection.Close()
End If
End Try
No comments:
Post a Comment