//����Customerid��ʱ�䷶Χ����ѯ���ʼ�¼ public List<Account> SelectAccountByTimeToList(int customerId, DateTime startdate, DateTime enddate) { string querysql = ""; querysql += " where day >= '" + startdate.ToString("s") + "'"; querysql += " and day <= '" + enddate.ToString("s") + "'"; if (customerId != 0) { querysql += " and CustomerId = " + customerId; } command.CommandText = "SELECT * FROM Account" + querysql; SQLiteDataAdapter da = new SQLiteDataAdapter(command); DataTable dt = new DataTable("Account"); da.Fill(dt); List<Account> listAccount = new List<Account>(); for (int i = 0; i < dt.Rows.Count; i++) { Account account = new Account(); account.Id = Convert.ToInt16(dt.Rows[i][0].ToString()); account.CustomerId = Convert.ToInt16(dt.Rows[i][1].ToString()); account.Day = Convert.ToDateTime(dt.Rows[i][2].ToString()); account.InMoney = Convert.ToDecimal(dt.Rows[i][3]); listAccount.Add(account); } return listAccount; }
//ͳ��Ӧ���ʿ� public List<Account> SumRequestInMoney() { command.CommandText = "select CustomerId,sum(Price*Counts) from Inventory group by CustomerId"; SQLiteDataAdapter da = new SQLiteDataAdapter(command); DataTable dt = new DataTable(); da.Fill(dt); List<Account> listAccount = new List<Account>(); for (int i = 0; i < dt.Rows.Count; i++) { Account account = new Account(); account.CustomerId = Convert.ToInt16(dt.Rows[i][0].ToString()); account.InMoney = Convert.ToDecimal(dt.Rows[i][1]); listAccount.Add(account); } return listAccount; }
//select account private void button26_Click(object sender, EventArgs e) { textBox1.Text = "Account"; List<Account> listiaccount = new List<Account>(); int i = 1; while (i < 20) { Account account = new Account(); account.Id = i; account.CustomerId = i; account.Day = System.DateTime.Now; account.InMoney = 20000; listiaccount.Add(account); i++; } dba.SelectAccount(listiaccount); }