Walaa wrote:
I can't produce that either. If I run it multiple times, it succeeds every time.
Well, do you see any issues in this complete code what i have written. I mean the way i have used UOW and adapters
private void ReverseData()
{
var adapterdebitnote = new DataAccessAdapter();
adapterdebitnote.StartTransaction(IsolationLevel.ReadCommitted, "DebitNote");
var BulkInsertDebitnote = new UnitOfWork2();
decimal Total = 0;
string TransactionMonth =
string.Format("{0:MMMM-yyyy}", datenotedate.Value.Date).ToUpper();
try
{
var debitnote =
new CreditdebitnoteEntity(Convert.ToInt32(GlobalVariable.searchDebitNoteid));
adapterdebitnote.FetchEntity(debitnote);
int MonthBillID = MonthlyBill.returnmonthlybillid(TransactionMonth,
ValidateUI.GetComboboxNullable(
debitnote.EmployeeId),
ValidateUI.GetComboboxNullable(
debitnote.AffiliateclubId),
ValidateUI.GetComboboxNullable(
debitnote.MemberId),
ValidateUI.GetComboboxNullable(
debitnote.CorporateId),
ValidateUI.GetComboboxNullable(
debitnote.AffiliatememberId));
#region CreditDebitNote Entity
debitnote.IsNew = false;
debitnote.Flag = StandardFlag.recorddeleteflag;
debitnote.ReasonId = Convert.ToInt32(cmbreasonid.SelectedValue);
debitnote.Modifieddate = ServerDateTime.getcurrentserverdatewithtime();
debitnote.ModifieduserId = StandardMessage.loginuserid;
BulkInsertDebitnote.AddForSave(debitnote);
#endregion CreditDebitNote Entity
for (int i = 0; i < dgriddebitnote.Rows.Count - 1; i++)
{
Total = Total +
Convert.ToDecimal(dgriddebitnote.Rows[i].Cells["DEBITAMOUNT"].Value);
}
#region Monthlybill Entity
var monthlybill = new MonthlybillEntity(Convert.ToInt32(MonthBillID));
monthlybill.IsNew = false;
monthlybill.Fields[(int) MonthlybillFieldIndex.Debitamount].
ExpressionToApply =
(MonthlybillFields.Debitamount - Convert.ToDecimal(Total));
monthlybill.Fields[(int) MonthlybillFieldIndex.Balanceamount].
ExpressionToApply =
(MonthlybillFields.Balanceamount - Convert.ToDecimal(Total));
monthlybill.Modifieddate = ServerDateTime.getcurrentserverdatewithtime();
monthlybill.ModifieduserId = StandardMessage.loginuserid;
BulkInsertDebitnote.AddForSave(monthlybill);
#endregion Monthlybill Entity
#region Monthlybilldetail Entity
for (int i = 0; i < dgriddebitnote.Rows.Count - 1; i++)
{
int MonthlybillDetailid =
Ledger.MonthlyBillDetailId(
Convert.ToInt32(dgriddebitnote.Rows[i].Cells["LEDGER_ID"].Value),
GlobalVariable.optionNo, MonthBillID);
if (MonthlybillDetailid <= 0) continue;
var monthlybilldetail =
new MonthlybilldetailEntity(MonthlybillDetailid);
monthlybilldetail.IsNew = false;
monthlybilldetail.Fields[(int) MonthlybilldetailFieldIndex.Debitamount]
.ExpressionToApply =
(MonthlybilldetailFields.Debitamount -
Convert.ToDecimal(dgriddebitnote.Rows[i].Cells["DEBITAMOUNT"].Value));
monthlybilldetail.Modifieddate =
ServerDateTime.getcurrentserverdatewithtime();
monthlybilldetail.ModifieduserId = StandardMessage.loginuserid;
BulkInsertDebitnote.AddForSave(monthlybilldetail);
#endregion Monthlybilldetail Entity
}
BulkInsertDebitnote.Commit(adapterdebitnote,true);
{
MessageBox.Show(StandardMessage.datasavesuccess);
DoRefresh();
}
}
catch (Exception ex)
{
GlobalErrorHandler.LogMessage(ex.Message + ex.StackTrace);
return;
}
finally
{
adapterdebitnote.CloseConnection();
adapterdebitnote.Dispose();
}
}
I hope it is not issue with MSORALCE of LLBLGEN