public DonViQuanLi LayDonVi() { QuanLyDanCuModelADO db = Form1.db; string sqlString = "select * from DonViQuanLis "; DataSet ds = db.ExecuteQueryDataSet(sqlString, CommandType.Text); DataTable dt = ds.Tables[0]; List <DonViQuanLi> thuongtrus = new List <DonViQuanLi>(); foreach (DataRow dr in dt.Rows) { DonViQuanLi tt = findById((string)dr.ItemArray[0]); thuongtrus.Add(tt); } return(thuongtrus[0]); }
private void Form8_Load(object sender, EventArgs e) { Lab1.TextAlign = ContentAlignment.MiddleCenter; Lab1.Left = (this.ClientSize.Width - Lab1.Size.Width) / 2; label1.TextAlign = ContentAlignment.MiddleCenter; label1.Left = (this.ClientSize.Width - label1.Size.Width) / 2; pictureBox1.Location = new Point(Lab1.Location.X - 50 - pictureBox1.Width, pictureBox1.Location.Y); pictureBox2.Location = new Point(Lab1.Location.X + Lab1.Width + 50, pictureBox2.Location.Y); panel2.Location = new Point(this.Width / 2 - panel2.Width / 2, this.Height / 2 - (panel2.Height / 2) - 100); panel3.Location = new Point(this.Width / 2 - panel3.Width / 2, panel2.Location.Y + panel2.Height + 30); QuanLyKhuVuc QLKV = new QuanLyKhuVuc(); DonViQuanLi DV = QLKV.LayDonVi(); lbXa.Text = DV.Phuong; lbPhuong.Text = DV.Quan; lbThanhPho.Text = DV.ThanhPho; }
public DonViQuanLi findById(string id) { try { QuanLyDanCuModelADO db = Form1.db; string sqlString = "select * from DonViQuanLis where So = " + id + ""; DataSet ds = db.ExecuteQueryDataSet(sqlString, CommandType.Text); DonViQuanLi gks = new DonViQuanLi() { id = (int)ds.Tables[0].Rows[0].ItemArray[0], Phuong = (string)ds.Tables[0].Rows[0].ItemArray[1], Quan = (string)ds.Tables[0].Rows[0].ItemArray[2], ThanhPho = (string)ds.Tables[0].Rows[0].ItemArray[3], }; return(gks); } catch (Exception e) { MessageBox.Show("Lỗi FindById TamVang!!! + " + e.Message); return(null); } }