public bool updateCheck(CheckQueueRecord Check, string tran_type) { bool return_val = false; Check.replaceQuote(); BillManager bMgr = new BillManager(elt_account_number); ArrayList AAJEntryList = Check.All_accounts_journal_entry_list; int printID = Check.print_id; BillRecord bRec = (BillRecord)Check.BillList[0]; if (bMgr.updateBillRecord(ref bRec, "CHK")) { for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { this.aajMgr.checkInitial_Acct_Record((AllAccountsJournalRecord)AAJEntryList[i]); } } int tran_seq_id = this.aajMgr.getNextTranSeqNumber(); Cmd = new SqlCommand(); Cmd.Connection = Con; Con.Open(); SqlTransaction trans = Con.BeginTransaction(); Cmd.Transaction = trans; try { //DELETE PREVIOUS CHECK_DETAIL LIST SQL = "DELETE FROM check_detail where elt_account_number =" + elt_account_number + " and print_id=" + printID; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); //DELETE ALL_ACCOUNTS_JOURNAL ENTRY SQL = "DELETE FROM all_accounts_journal where elt_account_number =" + elt_account_number + " and tran_num=" + printID + " and tran_type='" + tran_type + "'"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); //INSERT CHECK_DETAL LIST ArrayList chkList = Check.CheckDetailList; for (int i = 0; i < chkList.Count; i++) { CheckDetailRecord cdRec = (CheckDetailRecord)chkList[i]; cdRec.replaceQuote(); cdRec.print_id = printID; SQL = "INSERT INTO [check_detail] "; SQL += "( elt_account_number, "; SQL += "amt_due,"; SQL += "amt_paid,"; SQL += "bill_amt,"; SQL += "bill_number,"; SQL += "due_date,"; SQL += "invoice_no,"; SQL += "memo,"; SQL += "pmt_method,"; SQL += "print_id,"; SQL += "tran_id)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + cdRec.amt_due; SQL += "','" + cdRec.amt_paid; SQL += "','" + cdRec.bill_amt; SQL += "','" + cdRec.bill_number; SQL += "','" + cdRec.due_date; SQL += "','" + cdRec.invoice_no; SQL += "','" + cdRec.memo; SQL += "','" + cdRec.pmt_method; SQL += "','" + printID; SQL += "','" + cdRec.tran_id; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } //INSERT AAJ ENTRIES for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote(); ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = printID; SQL = "INSERT INTO [all_accounts_journal] "; SQL += "( elt_account_number, "; SQL += "tran_num,"; SQL += "gl_account_number,"; SQL += "gl_account_name,"; SQL += "tran_seq_num,"; SQL += "tran_type,"; SQL += "tran_date,"; SQL += "Customer_Number,"; SQL += "Customer_Name,"; SQL += "debit_amount,"; SQL += "credit_amount,"; SQL += "balance,"; SQL += "previous_balance,"; SQL += "gl_balance,"; SQL += "gl_previous_balance)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name; SQL += "','" + tran_seq_id++; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_type; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } } //UPDATE THE CHECK string check_type = ""; if (tran_type == "CHK" || tran_type == "CSH" || tran_type == "CRC" || tran_type == "BTB") { check_type = "C"; } else { check_type = "BP"; } SQL = "UPDATE [check_queue] "; SQL += "Set elt_account_number='" + elt_account_number + "',"; SQL += "ap='" + Check.ap + "',"; SQL += "bank='" + Check.bank + "',"; SQL += "bill_date='" + Check.bill_date + "',"; SQL += "bill_due_date='" + Check.bill_due_date + "',"; SQL += "check_amt='" + Check.check_amt + "',"; SQL += "check_type='" + check_type + "',"; SQL += "memo='" + Check.memo + "',"; SQL += "pmt_method='" + Check.pmt_method + "',"; SQL += "print_check_as='" + Check.print_check_as + "',"; SQL += "print_date='" + Check.print_date + "',"; SQL += "print_id='" + Check.print_id + "',"; SQL += "print_status='" + Check.print_status + "',"; SQL += "vendor_info='" + Check.vendor_info + "',"; SQL += "vendor_name='" + Check.vendor_name + "',"; SQL += "vendor_number='" + Check.vendor_number + "'"; SQL += "where elt_account_number =" + elt_account_number + " and print_id=" + printID; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); trans.Commit(); return_val = true; } catch (Exception ex) { trans.Rollback(); throw ex; } finally { Con.Close(); } } return(return_val); }