public void ReadDB(DateTime startTime, DateTime endTime) { winprizes.Clear(); SQLiteConnection cn = new SQLiteConnection("data source=" + connStr); cn.Open(); SQLiteCommand cmd = new SQLiteCommand(); cmd.Connection = cn; cmd.CommandText = string.Format("select * from winprize where drawTime>=\"{0}\" and drawTime<=\"{1}\"", startTime.ToString("yyyy-MM-dd HH:mm:ss:ffff"), endTime.ToString("yyyy-MM-dd HH:mm:ss:ffff")); SQLiteDataReader sr = cmd.ExecuteReader(); while (sr.Read()) { Prize prize = new Prize(sr.GetString(1), 0, sr.GetString(2)); WinPrize wp = GetWinPrizeFromPrize(prize); string tk = sr.GetString(0); wp.DrawTime = DateTime.ParseExact(tk, "yyyy-MM-dd HH:mm:ss:ffff", null); Person item = new Person(sr.GetString(3), sr.GetString(4), sr.GetString(5)); wp.Persons.Add(item); } sr.Close(); cn.Close(); }
private List <Person> GetWinPerson() { List <Person> pers = new List <Person>(); for (int i = 0; i < wps.Count; i++) { WinPrize wp = wps.GetWinPrize(i); foreach (var per in wp.Persons) { pers.Add(per); } } return(pers); }
private void SaveWinDB() { WinPrizeCollection twps = new WinPrizeCollection(config.Connstr); WinPrize pr = new WinPrize(prizes.GetPrize(prizeCB.SelectedIndex)); pr.DrawTime = DateTime.Now; foreach (var item in winList) { pr.Persons.Add(item); } twps.Add(pr); twps.SaveDB(); wps.ReadDB(openTime); RefreshDrawPerson(); }
public void test() { DateTime tt = DateTime.Now; for (int i = 0; i < 3; i++) { Prize pr = new Prize(i.ToString(), 0, ""); WinPrize wp = new WinPrize(pr); wp.DrawTime = tt; for (int j = 0; j < 10; j++) { Person per = new Person(j.ToString()); wp.Persons.Add(per); } winprizes.Add(wp); } }
private WinPrize GetWinPrizeFromPrize(Prize prize) { WinPrize winprize = null; foreach (var wit in winprizes) { if (wit.Prize.Name == prize.Name) { winprize = wit; break; } } if (winprize == null) { winprize = new WinPrize(prize); winprizes.Add(winprize); } return(winprize); }
private void RefreshPerson(int prizeIndex) { personLv.Items.Clear(); personLv.BeginUpdate(); WinPrize wp = winPrizes.GetWinPrize(prizeIndex); List <Person> persons = wp.Persons; foreach (var pr in persons) { ListViewItem item = new ListViewItem(); item.Text = pr.Name; // item.SubItems.Add(wp.DrawTime.ToString("yyyy-MM-dd HH:mm:ss")); item.SubItems.Add(pr.Text); item.SubItems.Add(pr.Picpath); personLv.Items.Add(item); } personLv.EndUpdate(); }
public void ReadDB(DateTime filterTime) { winprizes.Clear(); SQLiteConnection cn = new SQLiteConnection("data source=" + connStr); cn.Open(); SQLiteCommand cmd = new SQLiteCommand(); cmd.Connection = cn; cmd.CommandText = "select * from winprize where drawTime>=\"" + filterTime.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "\""; SQLiteDataReader sr = cmd.ExecuteReader(); while (sr.Read()) { Prize prize = new Prize(sr.GetString(1), 0, sr.GetString(2)); WinPrize wp = GetWinPrizeFromPrize(prize); Person item = new Person(sr.GetString(3), sr.GetString(4), sr.GetString(5)); wp.Persons.Add(item); } sr.Close(); cn.Close(); }
private void exportBt_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = ""; sfd.Filter = "文本文件| *.txt"; if (sfd.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(sfd.FileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs, Encoding.Default); for (int i = 0; i < winPrizes.Count; i++) { WinPrize wp = winPrizes.GetWinPrize(i); sw.Write(wp.Prize.Name + "\r\n"); foreach (var per in wp.Persons) { sw.Write(per.Name + ","); } sw.Write("\r\n"); } sw.Close(); fs.Close(); } }
public void Add(WinPrize prize) { winprizes.Add(prize); }