/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn(); LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile); dbname = dbFile; sqlString = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]"; dtGridKH.AllowUserToAddRows = true; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); return; } while(oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i =0; i < dtGridKH.Columns.Count; i++) { dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; else dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; rowColor = !rowColor; } dtGridBt.Text = "..."; dtGridBt.Name = "Capnhat"; dtGridBt.Width = 60; dtGridBt.HeaderText = "Cap nhat"; dtGridBt.UseColumnTextForButtonValue = true; dtGridKH.Columns.Add(dtGridBt); dtGridKH.AllowUserToAddRows = false; } catch (Exception ex) { MessageBox.Show(ex.Message); QlkhDb.close(); this.Close(); } }
private void cbxLoaiKH_SelectedIndexChanged(object sender, EventArgs e) { int index, i; string sqlString; string loaiKH; DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn(); if (initfrm == true) { initfrm = false; return; } loaiKH = cbxLoaiKH.Text; index = cbxLoaiKH.FindString(loaiKH); if (index >= LoaiKHList.Count) { sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; } else { sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; sqlString = sqlString + "WHERE [MaLoaiKH] = " + LoaiKHList[index].ToString(); } clear(); QlkhDb.fillDtGridView(sqlString, dtGridKH); if (dtGridKH.Columns.Count == 0) { return; } for (i = 0; i < dtGridKH.Columns.Count; i++) { dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) { dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; } else { dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; } rowColor = !rowColor; } dtGridBt.Text = "..."; dtGridBt.Name = "Capnhat"; dtGridBt.Width = 60; dtGridBt.HeaderText = "Cap nhat"; dtGridBt.UseColumnTextForButtonValue = true; dtGridKH.Columns.Add(dtGridBt); }
/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile, string dbuser, int dbport) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile, dbuser, dbport); sqlString = "SELECT [MaLoaiKH], [LoaiKH] FROM [LOAIKH]"; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); } while (oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) { dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; } else { dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; } rowColor = !rowColor; } } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }
/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile, string dbuser, int dbport) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile, dbuser, dbport); sqlString = "SELECT [MaLoaiKH], [LoaiKH] FROM [LOAIKH]"; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); } while(oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; else dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; rowColor = !rowColor; } } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }
private void cbxLoaiKH_SelectedIndexChanged(object sender, EventArgs e) { int index, i; string sqlString; string loaiKH; if (initfrm == true) { initfrm = false; return; } loaiKH = cbxLoaiKH.Text; index = cbxLoaiKH.FindString(loaiKH); if (index >= LoaiKHList.Count) { sqlString = "SELECT [MAKH], [TenKH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; } else { sqlString = "SELECT [MAKH], [TenKH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; sqlString = sqlString + "WHERE [MaLoaiKH] = " + LoaiKHList[index].ToString(); } QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) { dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; } else { dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; } rowColor = !rowColor; } }
/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn(); LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile); dbname = dbFile; sqlString = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]"; dtGridKH.AllowUserToAddRows = true; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); return; } while (oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i = 0; i < dtGridKH.Columns.Count; i++) { dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) { dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; } else { dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; } rowColor = !rowColor; } dtGridBt.Text = "..."; dtGridBt.Name = "Capnhat"; dtGridBt.Width = 60; dtGridBt.HeaderText = "Cap nhat"; dtGridBt.UseColumnTextForButtonValue = true; dtGridKH.Columns.Add(dtGridBt); dtGridKH.AllowUserToAddRows = false; } catch (Exception ex) { MessageBox.Show(ex.Message); QlkhDb.close(); this.Close(); } }