private void Load_L1(TapF tapF, TapL tapL) { for (int i = 0; i < Program.listMahoa.Count; i++) { int count = 0; foreach (List <string> ls in tapF.Values) { for (int j = 0; j < ls.Count; j++) { string t = Program.listMahoa[i].maHoa.ToString(); if (t.Equals(ls[j])) { count++; // Console.WriteLine(count + "ca"); } } } Console.WriteLine(Program.listMahoa[i].maHoa + " có : " + count); ListViewItem lv_Item = new ListViewItem(); lv_Item.Text = Program.listMahoa[i].maHoa.ToString(); lv_Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = count.ToString() }); lv_tapL.Items.Add(lv_Item); // Console.WriteLine(F.Keys.Count + "ssssw"); List <string> lisTemp = new List <string>(); lisTemp.Add(Program.listMahoa[i].maHoa.ToString()); tapL.Add(lisTemp, count); Program.listTapL.Add(tapL); } }
private void button1_Click(object sender, EventArgs e) { LoadForm2(); lv_tapF.Columns.Add("Ngay"); lv_tapF.Columns.Add("Ung vien"); TapF tapF = Program.listTapF[0]; Load_F1(tapF); TapL tapL = new TapL(); lv_tapL.Columns.Add("Ung vien"); lv_tapL.Columns.Add("Support"); Load_L1(tapF, tapL); }
private void Load_F1(TapF tapF) { foreach (var l in tapF) { ListViewItem lv_Item = new ListViewItem(); lv_Item.Text = l.Key.ToString(); string temp = ""; foreach (string s in l.Value) { temp = temp + " " + s; } lv_Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = temp }); lv_tapF.Items.Add(lv_Item); } }
private void LoadForm2() { TapF F = Program.listTapF[0]; //TapL FA = new TapL(); for (int i = 0; i < Program.listTapF.Count; i++) { // int count = 0; foreach (List <string> ls in F.Values) { for (int j = 0; j < ls.Count; j++) { Console.WriteLine(ls[j] + "ss"); } } } }
private void LoadData(int minsup) { Program.KetNoi(); // kết nối tới DB SqlDataReader sqlDataReader; string strCommand = "DECLARE @return_value int EXEC @return_value = [dbo].[SP_GIAOTAC] @minsup = '"+ minsup + "', @isinc = 1 SELECT 'Return Value' = @return_value"; sqlDataReader = Program.ExecSqlDataReader(strCommand); try { Program.listTapF.Clear(); Program.listMahoa.Clear(); TapF tapF = new TapF(); tapF.Lable = "F1"; // if (sqlDataReader.HasRows) { return; }// het dong thi return while (sqlDataReader.Read()) { ListViewItem lv_Item = new ListViewItem(); lv_Item.Text = sqlDataReader.GetDateTime(0).ToString(); int colum = 1; List <string> listtemp = new List <string>(); while (colum < sqlDataReader.FieldCount) { if (checkmahoa) // chkec de ko lap lai { Program.listMahoa.Add(new MaHoa(sqlDataReader.GetName(colum), colum)); // add ma cp vs mahoa } if (sqlDataReader.GetInt32(colum) == 1) { listtemp.Add(colum.ToString()); // vi sao add colum ? vi colum tuong voi ma ma hoa } lv_Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = sqlDataReader.GetInt32(colum).ToString() }); colum++; } checkmahoa = false; if (listtemp.Any()) // kiem tra xem cai list co gia tri ko { tapF.Add(sqlDataReader.GetDateTime(0).ToString(), listtemp); } // Console.WriteLine(sqlDataReader.GetDateTime(0)+""); lv_tapD.Items.Add(lv_Item); } foreach (var l in tapF) { Console.WriteLine(l.Key + " " + l.Value.Count + " fdfdfd"); } Program.listTapF.Add(tapF); for (int i = 0; i < sqlDataReader.FieldCount; i++) { lv_tapD.Columns.Add(sqlDataReader.GetName(i)); } lv_tapD.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); lv_tapD.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }catch (Exception e) { } }