Click here to Skip to main content
16,009,640 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a record on date 7th March. But when I'm trying to retrieve the record, it is being displayed as 4th of March. What can be the problem???

What I have tried:

private void FillList()
{
if (listView1.Items.Count > 0)
listView1.Items.Clear();


using (PetaPoco.Database db = new Database(new Db().Connection))
{

IEnumerable<reportinvoiceitems> items;

Doctor doctor = db.Single<doctor>(this._doctorId);

//Following is the Query I've written
string query = String.Format("select invoiceitem._ROWID_ as sr, strftime('%d-%m-%Y', invoice.date) as date,doctor.name as DoctorName ,product.name as productname,invoiceitem.range, invoiceitem.id ,invoiceitem.quantity, invoiceitem.price, invoiceitem.vat, ((invoiceitem.quantity * invoiceitem.price) + ((invoiceitem.price * invoiceitem.quantity) * (invoiceitem.vat / 100))) as amount, invoiceitem.remark from invoiceitem inner join invoice on invoiceitem.invoice_id = invoice.id inner join doctor on invoice.doctor_id = doctor.id inner join product on invoiceitem.product_id = product.id where invoice.doctor_id = {0} and invoice.date between '{1}' and '{2}'", _doctorId, _from.ToString("yyyy-MM-dd HH:mm:00"), _to.AddMinutes(1439).ToString("yyyy-MM-dd HH:mm:00"));

items = db.Query<reportinvoiceitems>(query);

decimal total = 0;
int v = this._vat;
foreach (var item in items)
{
decimal amount = Convert.ToDecimal(item.Quantity) * Convert.ToDecimal(item.Price);
amount = amount + (amount * v / 100);
total += amount;
ListViewItem listViewItem = new ListViewItem(new string[] { item.Sr.ToString(), item.Date, item.ProductName, item.DoctorName, item.Remark, item.Range, item.Quantity, item.Price, item.VAT, item.Amount });
listViewItem.Tag = item;
listView1.Items.Add(listViewItem);
}
label1.Text = doctor.name;
label2.Text = total.ToString();
}

}
Posted
Updated 16-Mar-16 20:26pm

1 solution

Try to display that query in a label or somewhere inputs, so you can check the date filter on your query if it's correct.
Possibly it's all about the query since you are retrieving data from table.
 
Share this answer
 

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