protected void btnDangKy_Click(object sender, EventArgs e) { TaiKhoan taiKhoan = new TaiKhoan(); taiKhoan.TenTaiKhoan = txtTenTaiKhoan.Text; taiKhoan.MatKhau = txtMatKhau1.Text; taiKhoan.LoaiTK = 3; // thêm tài khoản vào csdl if (TaiKhoan.ThemTaiKhoan(taiKhoan) == 0) { // nếu thất bại pnlThongBaoLoi.Visible = true; pnlDangKy.Visible = true; pnlKetQuaDangKy.Visible = false; lblThongBaoLoi.Text = "Đăng ký bị lỗi. Bạn có thể thử lại."; } else { // avartar if (fileUpload.PostedFile != null) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath("Path.xml")); XmlElement xmlPath = (XmlElement)xmlDoc.SelectSingleNode("/PATH"); string savePath = MapPath(xmlPath.InnerText.Trim() + txtTenTaiKhoan.Text + Path.GetExtension(fileUpload.PostedFile.FileName)); fileUpload.PostedFile.SaveAs(savePath); } // thông tin cá nhân KhachHang khachHang = new KhachHang(); khachHang.HoTen = txtHoTen.Text; khachHang.DiaChi = txtDiaChi.Text; khachHang.Email = txtEmail.Text; khachHang.SoDienThoai = txtEmail.Text; khachHang.MaKhachHang = TaiKhoan.LayThongTinTaiKhoanTheoTenTaiKhoan(txtTenTaiKhoan.Text).MaTaiKhoan; KhachHang.ThemKhachHang(khachHang); pnlThongBaoLoi.Visible = false; pnlDangKy.Visible = false; pnlKetQuaDangKy.Visible = true; lblTenNguoiDung.Text = txtTenTaiKhoan.Text; Session["IsLogin"] = 1; Session["Username"] = txtTenTaiKhoan.Text; // quyền truy xuất Session["Authentication"] = "KhachHang"; } }
/// <summary> /// Lấy thông tin khách hàng theo mã /// </summary> /// <param name="intMaKhachHang"></param> /// <returns></returns> public static KhachHang LayThongTinKhachHangTheoMa(int intMaKhachHang) { KhachHang khachHang = new KhachHang(); try { DataTable dt = new DataTable(); List<SqlParameter> lstParam = new List<SqlParameter>(); lstParam.Add(new SqlParameter("@makhachhang", intMaKhachHang)); dt = SqlDataAccessHelper.ExecuteQuery("spLayThongTinKhachHangTheoMa", lstParam); foreach (DataRow dr in dt.Rows) { khachHang._maKhachHang = int.Parse(dr["MaKhachHang"].ToString()); khachHang._hoTen = dr["HoTen"].ToString(); khachHang._diaChi = dr["DiaChi"].ToString(); khachHang._email = dr["Email"].ToString(); khachHang._soDienThoai = dr["SoDienThoai"].ToString(); } } catch (Exception e) { khachHang = null; } return khachHang; }
protected void btnThayDoi_Click(object sender, EventArgs e) { List<TaiKhoan> lstTaiKhoan = new List<TaiKhoan>(); lstTaiKhoan = TaiKhoan.LayThongTinTaiKhoanTheoLoaiTaiKhoan(3); dlDanhSachTaiKhoan.DataSource = lstTaiKhoan; dlDanhSachTaiKhoan.DataBind(); if (!Page.IsPostBack) { dropListTaiKhoan.DataSource = lstTaiKhoan; //dropListTaiKhoan.DataMember = "MaTaiKhoan"; dropListTaiKhoan.DataValueField = "MaTaiKhoan"; dropListTaiKhoan.DataTextField = "TenTaiKhoan"; dropListTaiKhoan.DataBind(); } //ListItem lstMaTaiKhoan = new ListItem(); //lstMaTaiKhoan = dropListTaiKhoan.SelectedItem; //int a = int.Parse(dropListLoaiTaiKhoan.); int maTaiKhoan = int.Parse(dropListTaiKhoan.SelectedValue.ToString()); KhachHang khachHang = new KhachHang(); khachHang = KhachHang.LayThongTinKhachHangTheoMa(maTaiKhoan); List<DonDatHang> lstDonDatHang = new List<DonDatHang>(); lstDonDatHang = DonDatHang.LayDSDonDatHangTheoMaKhachHang(maTaiKhoan); int countDDH = lstDonDatHang.Count; if (countDDH != 0) { lblTenTK.Text = khachHang.HoTen; lblThongBaoCapLaiQuyen.Text = " đã mua sản phẩm nên không thể chuyển thành đại lý!"; } else { int res = 0; DaiLy daiLy = new DaiLy(); daiLy.MaDaiLy = khachHang.MaKhachHang; daiLy.TenDaiLy = khachHang.HoTen; daiLy.Email = khachHang.Email; daiLy.SoDienThoai = khachHang.SoDienThoai; daiLy.NguoiDaiDien = khachHang.HoTen; res = daiLy.ThemDaiLy(); if (res != 0) { res = khachHang.XoaKhachHang(); lblThongBaoCapLaiQuyen.Text = " đã được chuyển thành đại lý!"; lblTenTK.Text = khachHang.HoTen; } } }
public static void InsertKH(KhachHang kh) { DAO_KHACHHANG.insertKH(kh); }
public int SuaKhacHang(KhachHang kh) { return(khdal.SuaKhachHang(kh)); }
public void DeleteData(KhachHang ex) { bus.DeleteData(ex); }
public static void updateKhachHang(KhachHang kh) { KhachHang_DAO.SuaKhachHang(kh); }
public void AddKH(KhachHang kh) { khtemp.AddKH(kh); }
public void UpdateKHBUS(KhachHang khToUpdate) { khDAO.UpdateKHDAO(khToUpdate); }
public int Update(KhachHang kh) { return(KHDAO.Update(kh)); }
public void AddKH(KhachHang ex) { bus.AddKH(ex); }
public static int AddKhachHang(KhachHang kh) { return(KhachHangDAO.AddKhachHang(kh)); }
public void Delete(KhachHang monhoc) { mon.Delete(monhoc); }
public static bool GhiNhanDatPhong(KhachHang khachHang, string maPhong, string maNV) { return(DAO.PhongDAO.GhiNhanDatPhong(khachHang, maPhong, maNV)); }
public void Update(KhachHang monhoc) { mon.Update(monhoc); }
public void Insert(KhachHang monhoc) { mon.Insert(monhoc); }
public void EditKH(KhachHang kh) { khtemp.EditKH(kh); }
public static void UpdateKH(string maKH, KhachHang kh) { DAO_KHACHHANG.updateKH(maKH, kh); }
public static int EditKhachHang(KhachHang kh) { return(KhachHangDAO.EditKhachHang(kh)); }
public void AddKHBUS(KhachHang kh) { khDAO.AddKHDAO(kh); }
public int Insert(KhachHang obj) { return(dal.Insert(obj)); }
public int Add(KhachHang c) { return(KHDAO.Add(c)); }
public Boolean insert(KhachHang khachHang) { return(this.khachHangDAO.insert(khachHang)); }
public static void addKhachHang(KhachHang kh) { KhachHang_DAO.ThemKhachHang(kh); }
public Boolean update(KhachHang khachHang) { return(this.khachHangDAO.update(khachHang)); }
protected void Page_Load(object sender, EventArgs e) { int iDaDangNhap = (Int32)Session["IsLogin"]; if (iDaDangNhap == 0) { Response.Redirect("DangNhap.aspx"); } else { int IDUser = (Int32)Session["Id"]; TaiKhoan taiKhoan = new TaiKhoan(); taiKhoan = TaiKhoan.LayThongTinTaiKhoanTheoMaTaiKhoan(IDUser); lblTenTaiKhoan.Text = taiKhoan.TenTaiKhoan; //kiểm tra user có up avatar lên server haykho6ng // nếu có thì sử dụng ảnh user, ngược lại dùng ảnh mặc định XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath("Path.xml")); XmlElement xmlPath = (XmlElement)xmlDoc.SelectSingleNode("/PATH"); string fileAvatar = MapPath(xmlPath.InnerText.Trim() + taiKhoan.TenTaiKhoan + ".gif"); if (File.Exists(fileAvatar)) { imgAvatar.ImageUrl = fileAvatar; } else { imgAvatar.ImageUrl = "../image-user/default.gif"; } if (taiKhoan.LoaiTK == 1) { BUS.QuanLy quanLy = BUS.QuanLy.LayThongTinQuanLyTheoMa(IDUser); lblLoaiTaiKhoan.Text = "Quản lý"; lblTen.Text = quanLy.HoTen; lblSoDienThoai.Text = quanLy.SoDienThoai; lblDiaChi.Text = quanLy.DiaChi; lblEmail.Text = quanLy.Email; } if (taiKhoan.LoaiTK == 2) { BUS.DaiLy daiLy = BUS.DaiLy.LayThongTinDaiLyTheoMa(IDUser); lblLoaiTaiKhoan.Text = "Đại lý"; lblTen.Text = daiLy.TenDaiLy; lblSoDienThoai.Text = daiLy.SoDienThoai; lblDiaChi.Text = daiLy.DiaChi; lblEmail.Text = daiLy.Email; lblNguoiDaiDien.Visible = true; lblNguoiDaiDien.Text = daiLy.NguoiDaiDien; lblNhanHoTen.Text = "Tên đại lý: "; lblDaiDien.Visible = true; lblDaiDien.Text = "Người đại diện: "; } if (taiKhoan.LoaiTK == 3) { BUS.KhachHang khachHang = new KhachHang(); khachHang = BUS.KhachHang.LayThongTinKhachHangTheoMa(IDUser); lblLoaiTaiKhoan.Text = "Khách hàng"; lblTen.Text = khachHang.HoTen; lblSoDienThoai.Text = khachHang.SoDienThoai; lblDiaChi.Text = khachHang.DiaChi; lblEmail.Text = khachHang.Email; } if (taiKhoan.LoaiTK == 1 || taiKhoan.LoaiTK == 3) { lblNguoiDaiDien.Visible = false; lblNhanHoTen.Text = "Họ tên: "; lblDaiDien.Visible = false; } } }
public bool insertKH(KhachHang kh) { return(dal_khachhang.insertKH(kh)); }
public int Update(KhachHang obj) { return(dal.Update(obj)); }
/// <summary> /// Thêm thông tin khách hàng /// Thu Hà : 29/5/2011 /// </summary> /// <returns></returns> public static int ThemKhachHang(KhachHang kh) { int res; try { List<SqlParameter> lstParam = new List<SqlParameter>(); lstParam.Add(new SqlParameter("@makhachhang", kh.MaKhachHang)); lstParam.Add(new SqlParameter("@hoten", kh.HoTen)); lstParam.Add(new SqlParameter("@diachi", kh.DiaChi)); lstParam.Add(new SqlParameter("@email", kh.Email)); lstParam.Add(new SqlParameter("@sodienthoai", kh.SoDienThoai)); res = SqlDataAccessHelper.ExecuteNoneQuery("spThemTaiKhoanKhachHang", lstParam); } catch (Exception e) { throw e; } return res; }
public Boolean delete(KhachHang khachHang) { return(this.khachHangDAO.delete(khachHang)); }
public bool ThemKhachHang(KhachHang kh) { KhachHangDAL khDAL = new KhachHangDAL(); return(khDAL.ThemKhachHang(kh)); }
public int ThemKhachHang(KhachHang kh) { return(khdal.ThemKhachHang(kh)); }
public void KhachHang_ThemKH(KhachHang kh) { DAO.DAO_KhachHang.Instance.ThemKhachHang(kh); }
public void KhachHang_SuaKH(KhachHang kh) { DAO.DAO_KhachHang.Instance.SuaKhachHang(kh); }
public void EditData(KhachHang ex) { bus.EditData(ex); }