//Load lại thông tin của khách hàng public void reloadInfoUser() { infoUser = bal.GetInfoFromUsername(userName); // gán dữ liệu của Hàm GetInfoFromUserName vào InfoUser lbInfo.Text = "Tên KH: " + infoUser.TenKH;//nhớ thay như vậy trong setupUI //nhớ gọi hàm này trong formload }
//hàm lấy thông tin thông qua AccID public InfoAccDTO GetInfoFromUsername(string username) { InfoAccDTO kq = new InfoAccDTO(); try { string sql = "select b.AccID,b.TenKH,b.DiaChi,b.Tuoi,b.GioiTinh,b.SDT from Account a, AccInfo b where a.Username=@id and a.AccID = b.AccID"; SqlParameter user = new SqlParameter("@id", SqlDbType.NVarChar); user.Value = username; SqlDataReader reader = ReadDataPars(sql, new[] { user }); if (reader.Read()) { kq.AccID = reader.GetString(0); kq.TenKH = reader.GetString(1); kq.Diachi = reader.GetString(2); kq.Tuoi = reader.GetInt32(3); kq.Gioitinh = reader.GetString(4); kq.Sdt = reader.GetString(5); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { closeConnection(); } return(kq); }
//hàm lấy thông tin Account public List <InfoAccDTO> GetInfoAccs() { List <InfoAccDTO> list = new List <InfoAccDTO>(); try { string sql = "select b.* from Account a, AccInfo b where a.AccID = b.AccID and a.Acctype = 2"; SqlDataReader reader = ReadData(sql); while (reader.Read()) { InfoAccDTO i = new InfoAccDTO(); i.AccID = reader.GetString(0); i.TenKH = reader.GetString(1); i.Diachi = reader.GetString(2); i.Tuoi = reader.GetInt32(3); i.Gioitinh = reader.GetString(4); i.Sdt = reader.GetString(5); list.Add(i); } }catch (Exception ex) { ex.ToString(); } finally { closeConnection(); } return(list); }
public InfoUser(InfoAccDTO info) { InitializeComponent(); this.info = info; }