Click here to Skip to main content
15,178,370 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i want to add the total payments of the whole month...

how can i do it??
Posted
Comments
Tejas Vaishnav 6-Oct-11 0:26am
   
Just Calculate it and add...
its so simple...
Tejas Vaishnav 6-Oct-11 0:27am
   
Please Write a question with proper detail..
give data and if it is needed then give some code also...
Xeshan Ahmed 6-Oct-11 1:37am
   
insufficient information.......
Xeshan Ahmed 6-Oct-11 1:37am
   
provide some details about your database structure
Madhana Kumar 6-Oct-11 1:43am
   
Pls little more precise.
Then only we can help you.
codegeekalpha 6-Oct-11 4:23am
   
i just simple want to add customers payments of the for the whole year
Morgs Morgan 6-Oct-11 10:29am
   
But you said you want to add payments for whole month!

Without any information where that information you want is stored in your application and exact details about that, we'll be unable to help you. The following is a collection of tables that one could assume to be present in a system that deals with customers that pay for stuff:


  1. Customer
    Constains data about your customer base.
  2. Product
    Your products would be stored here
  3. Order
    Every time a customer purchases something an order will be placed. General information about which customer (FK) did this and the delivery adress (FK) and the billing address (FK) are stored there. Maybe you'd also want the total amount.
  4. OrderItem
    Every order consists of several positions as customers want to order more than one thing in one order. This table will have information about the product, the amount, the unit (pcs, kg, pounds, etc) and the price.
  5. Payment
    If the customer pays online this information will be automatically filled by your website with information about that payment. If the customer pays after receiving the bill this information will be filled from you ERP system.
  6. PaymentDetail
    Will contain information about when the payment history. Like when the bill is sent, when the amount due was payed etc.
  7. Adress
    This just a table that contains addresses that are linked to some of the other tables as needed


Without knowing anything about how your data is stored how can you even think we could give you concrete help.

Regards,

—MRB
   
Comments
Reiss 6-Oct-11 11:02am
   
+5 but, do you expect the OP to come up with a data model as sensible as this
Manfred Rudolf Bihy 6-Oct-11 11:06am
   
I had hoped there already was a data model.
Thanks for the five :)
You can try something like this:
suppose you have the following table columns in your database
1. Payment (of type interger)
1. PaymentDate (of type DateTime)
Now that i don't know how you are accessing your database, i will assume you are using Linq-Sql!
C#
// suppose startDate=2011/10/01 and endDate=2011/10/31
public Int32 CalculateMonthlyPayment( DateTime startDate, DateTime endDate )
{ 
    //Linq-SQL query
    Int32 totalPayments = DataContext.TableName.Where( t => t.PaymentDate >= startDate && t.PaymentDate <= endDate ).Sum( t => t.Payment );
    return totalPayments;

    //or, T-SQL query
    /*
    String query = @"SELECT SUM(t.Payments) AS [Total Payments] FROM TableName t WHERE PaymentDate >= '" + startDate + "' AND PaymentDate <= '" + endDate + "';";
    */
}
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900