Пример #1
0
    public AllAccountsJournalRecord get_OneEntryFromGJE(int tran_no, int item_no, string tran_type)
    {
        DataTable dt = new DataTable();

        SQL = "select * FROM all_accounts_journal WHERE elt_account_number = " + elt_account_number + " AND tran_num = " + tran_no + " AND tran_type = '" + tran_type + "'  order by tran_seq_num";
        SqlDataAdapter adp = new SqlDataAdapter(SQL, Con);

        adp.Fill(dt);
        GeneralUtility util = new GeneralUtility();

        util.removeNull(ref dt);
        AllAccountsJournalRecord aaj = new AllAccountsJournalRecord();

        aaj.elt_account_number  = Int32.Parse(dt.Rows[item_no - 1]["elt_account_number"].ToString());
        aaj.gl_account_number   = Int32.Parse(dt.Rows[item_no - 1]["gl_account_number"].ToString());
        aaj.gl_account_name     = dt.Rows[item_no - 1]["gl_account_name"].ToString();
        aaj.tran_seq_num        = Int32.Parse(dt.Rows[item_no - 1]["tran_seq_num"].ToString());
        aaj.tran_type           = dt.Rows[item_no - 1]["tran_type"].ToString();
        aaj.tran_date           = dt.Rows[item_no - 1]["tran_date"].ToString();
        aaj.customer_number     = Int32.Parse(dt.Rows[item_no - 1]["Customer_Number"].ToString());
        aaj.customer_name       = dt.Rows[item_no - 1]["Customer_Name"].ToString();
        aaj.debit_amount        = Decimal.Parse(dt.Rows[item_no - 1]["debit_amount"].ToString());
        aaj.credit_amount       = Decimal.Parse(dt.Rows[item_no - 1]["credit_amount"].ToString());
        aaj.balance             = Decimal.Parse(dt.Rows[item_no - 1]["balance"].ToString());
        aaj.previous_balance    = Decimal.Parse(dt.Rows[item_no - 1]["previous_balance"].ToString());
        aaj.gl_balance          = Decimal.Parse(dt.Rows[item_no - 1]["gl_balance"].ToString());
        aaj.gl_previous_balance = Decimal.Parse(dt.Rows[item_no - 1]["gl_previous_balance"].ToString());
        return(aaj);
    }
Пример #2
0
    public bool insert_Entries(ArrayList gjeList, int tran_no)
    {
        bool return_val = false;

        for (int i = 0; i < gjeList.Count; i++)
        {
            AllAccountsJournalRecord AAJEntry = ((GeneralJournalRecord)gjeList[i]).All_Accounts_Journal_Entry;
            aajMgr.checkInitial_Acct_Record(AAJEntry);
        }
        Cmd            = new SqlCommand();
        Cmd.Connection = Con;
        Con.Open();
        SqlTransaction trans = Con.BeginTransaction();

        Cmd.Transaction = trans;

        try
        {
            int next_tran_seq_no = aajMgr.getNextTranSeqNumber();


            for (int i = 0; i < gjeList.Count; i++)
            {
                AllAccountsJournalRecord AAJEntry = ((GeneralJournalRecord)gjeList[i]).All_Accounts_Journal_Entry;
                ((GeneralJournalRecord)gjeList[i]).entry_no = tran_no;
                ((GeneralJournalRecord)gjeList[i]).replaceQuote();
                AAJEntry.replaceQuote();
                AAJEntry.tran_type = "GJE";
                AAJEntry.tran_num  = tran_no;

                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 += "','" + AAJEntry.tran_num;
                SQL += "','" + AAJEntry.gl_account_number;
                SQL += "','" + AAJEntry.gl_account_name;
                SQL += "','" + next_tran_seq_no++;
                SQL += "','" + AAJEntry.tran_type;
                SQL += "','" + AAJEntry.tran_date;
                SQL += "','" + AAJEntry.customer_number;
                SQL += "','" + AAJEntry.customer_name;
                SQL += "','" + AAJEntry.debit_amount;
                SQL += "','" + AAJEntry.credit_amount;
                SQL += "','" + AAJEntry.balance;
                SQL += "','" + AAJEntry.previous_balance;
                SQL += "','" + AAJEntry.gl_balance;
                SQL += "','" + AAJEntry.gl_previous_balance;
                SQL += "')";

                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();

                SQL             = "INSERT INTO [general_journal_entry] ";
                SQL            += "(credit, ";
                SQL            += "debit,";
                SQL            += "dt,";
                SQL            += "elt_account_number,";
                SQL            += "entry_no,";
                SQL            += "gl_account_number,";
                SQL            += "item_no,";
                SQL            += "memo,";
                SQL            += "org_acct)";
                SQL            += "VALUES";
                SQL            += "('" + ((GeneralJournalRecord)gjeList[i]).credit;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).debit;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).dt;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).elt_account_number;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).entry_no;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).gl_account_number;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).item_no;
                SQL            += "','" + ((GeneralJournalRecord)gjeList[i]).memo;
                SQL            += "'," + ((GeneralJournalRecord)gjeList[i]).org_acct;
                SQL            += ")";
                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
            }

            trans.Commit();
            return_val = true;
        }
        catch (Exception ex)
        {
            trans.Rollback();
            throw ex;
        }
        finally
        {
            Con.Close();
        }
        return(return_val);
    }
Пример #3
0
    public bool checkInitial_Acct_Record(AllAccountsJournalRecord rec)
    {
        rec.replaceQuote();

        SQL = "select count(tran_type) from all_accounts_journal where elt_account_number = "
              + elt_account_number + " and gl_account_number="
              + rec.gl_account_number + " and tran_type='INIT' and customer_number=" + rec.customer_number;

        Cmd = new SqlCommand(SQL, Con);
        int rowCount;

        try
        {
            Con.Open();
            rowCount = Int32.Parse(Cmd.ExecuteScalar().ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            Con.Close();
        }
        if (rowCount == 1)
        {
            return(true);
        }
        else if (rowCount >= 0)
        {
            SQL  = "INSERT INTO [all_accounts_journal] ";
            SQL += "( elt_account_number, ";
            SQL += "memo,";
            SQL += "gl_account_number,";
            SQL += "air_ocean,";
            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 += "','" + rec.memo;
            SQL += "','" + rec.gl_account_number;
            SQL += "','" + rec.air_ocean;
            SQL += "','" + rec.gl_account_name;
            SQL += "','" + getNextTranSeqNumber();
            SQL += "','" + "INIT";
            SQL += "','" + DateTime.Today.ToShortDateString();
            SQL += "','" + rec.customer_number;
            SQL += "','" + rec.customer_name;
            SQL += "','" + 0;
            SQL += "','" + 0;
            SQL += "','" + 0;
            SQL += "','" + 0;
            SQL += "','" + 0;
            SQL += "','" + 0;
            SQL += "')";
            Cmd  = new SqlCommand(SQL, Con);
            try
            {
                Con.Open();
                Cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Con.Close();
            }
        }
        else
        {
        }

        return(false);
    }