コード例 #1
0
        public static string manageCustomerLedger(NameValueCollection strQuerystring)
        {
            int      intParser;
            decimal  decimalParser;
            DateTime dateTimeParser;


            var customerLedgerReconstruct = new CustomerLedgerReconstruct {
                CustomerLedgerID = int.TryParse(strQuerystring.Get("CustomerLedgerID"), out intParser) ? intParser : 0,
                ID             = int.TryParse(strQuerystring.Get("ID"), out intParser) ? intParser : 0,
                Type           = strQuerystring.Get("CustType"),
                Date           = DateTime.TryParse(strQuerystring.Get("Date"), out dateTimeParser) ? dateTimeParser.ToShortDateString() : "",
                Number         = strQuerystring.Get("RefDocNo"),
                Debit          = decimal.TryParse(strQuerystring.Get("Debit"), out decimalParser) ? decimalParser : 0,
                Credit         = decimal.TryParse(strQuerystring.Get("Credit"), out decimalParser) ? decimalParser : 0,
                PPR            = decimal.TryParse(strQuerystring.Get("Rebates"), out decimalParser) ? decimalParser : 0,
                Charges        = decimal.TryParse(strQuerystring.Get("Penalty"), out decimalParser) ? decimalParser : 0,
                RunningBalance = 0
            };

            string isInsert = strQuerystring.Get("TransType");
            string param    = WebCommon.ToXML(customerLedgerReconstruct);

            return(ReconstructDAL.ManageCustomerLedger(param, isInsert));
        }
コード例 #2
0
        public static List <CustomerLedgerReconstruct> GetCustomerLedger(string referenceNumber, int branchID)
        {
            var dbUtil = new DatabaseManager();
            var customerLedgersReconstruct = new List <CustomerLedgerReconstruct>();

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = "spCommonGetCustEntryLedgerReconstruct";
                    cmd.CommandTimeout = 180;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@strACcountCode", referenceNumber);
                    cmd.Parameters.AddWithValue("@intIDMasLocation", branchID);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        int recordCounter = 0;

                        decimal runningBalance = 0;

                        while (reader.Read())
                        {
                            recordCounter += 1;

                            var customerLedger = new CustomerLedgerReconstruct
                            {
                                CustomerLedgerID = recordCounter,
                                ID      = ReferenceEquals(reader["ID"], DBNull.Value) ? 0 : Convert.ToInt32(reader["ID"]),
                                Type    = ReferenceEquals(reader["DocType"], DBNull.Value) ? String.Empty : Convert.ToString(reader["DocType"]),
                                Date    = ReferenceEquals(reader["DocDate"], DBNull.Value) ? String.Empty : Convert.ToDateTime(reader["DocDate"]).ToShortDateString(),
                                Number  = ReferenceEquals(reader["RefDoc"], DBNull.Value) ? String.Empty : Convert.ToString(reader["RefDoc"]),
                                Debit   = ReferenceEquals(reader["curDebit"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curDebit"]),
                                Credit  = ReferenceEquals(reader["curCredit"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curCredit"]),
                                PPR     = ReferenceEquals(reader["curRebateDiscount"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curRebateDiscount"]),
                                Charges = ReferenceEquals(reader["curPenaltyCharges"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curPenaltyCharges"])
                            };

                            runningBalance += (customerLedger.Debit - customerLedger.Credit);
                            customerLedger.RunningBalance = runningBalance;

                            customerLedgersReconstruct.Add(customerLedger);
                        }
                        return(customerLedgersReconstruct);
                    }
                }
            }
        }