Exemplo n.º 1
0
        /// <summary>
        /// Lấy ds đại lý
        /// </summary>
        /// <returns></returns>
        public static List<DaiLy> LayDSDaiLy()
        {
            List<DaiLy> lstDaiLy = new List<DaiLy>();
            try
            {
                DataTable dt = new DataTable();
                dt = SqlDataAccessHelper.ExecuteQuery("spLayDanhSachDaiLy");

                foreach (DataRow dr in dt.Rows)
                {
                    DaiLy daiLy = new DaiLy();
                    daiLy._maDaiLy = int.Parse(dr["MaDaiLy"].ToString());
                    daiLy._tenDaiLy = dr["TenDaiLy"].ToString();
                    daiLy._diaChi = dr["DiaChi"].ToString();
                    daiLy._email = dr["Email"].ToString();
                    daiLy._nguoiDaiDien = dr["NguoiDaiDien"].ToString();
                    daiLy._soDienThoai = dr["SoDienThoai"].ToString();

                    lstDaiLy.Add(daiLy);
                }
            }

            catch (Exception e)
            {
                lstDaiLy = null;
                throw (e);
            }

            return lstDaiLy;
        }
        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;
                }

            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///  Lấy thông tin đại lý theo tên đại lý  
        /// </summary>
        /// <param name="strTenDaiLy"></param>
        /// <returns></returns>
        public static List<DaiLy> LayThongTinDaiLyTheoTen(string strTenDaiLy)
        {
            List<DaiLy> lstDaiLy = new List<DaiLy>();
            try
            {
                DataTable dt = new DataTable();
                List<SqlParameter> lstParam = new List<SqlParameter>();
                lstParam.Add(new SqlParameter("@madaily", strTenDaiLy));
                dt = SqlDataAccessHelper.ExecuteQuery("spLayThongTinDaiLyTheoTen", lstParam);

                foreach (DataRow dr in dt.Rows)
                {
                    DaiLy daiLy = new DaiLy();
                    daiLy._maDaiLy = int.Parse(dr["MaDaiLy"].ToString());
                    daiLy._tenDaiLy = dr["TenDaiLy"].ToString();
                    daiLy._diaChi = dr["DiaChi"].ToString();
                    daiLy._email = dr["Email"].ToString();
                    daiLy._nguoiDaiDien = dr["NguoiDaiDien"].ToString();
                    daiLy._soDienThoai = dr["SoDienThoai"].ToString();

                    lstDaiLy.Add(daiLy);
                }
            }

            catch (Exception e)
            {

                throw (e);
            }

            return lstDaiLy;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lấy thông tin đại lý theo mã đại lý   
        /// </summary>
        /// <param name="intMaDaiLy"></param>
        /// <returns></returns>
        public static DaiLy LayThongTinDaiLyTheoMa(int intMaDaiLy)
        {
            DaiLy daiLy = new DaiLy();
            try
            {
                DataTable dt = new DataTable();
                List<SqlParameter> lstParam = new List<SqlParameter>();
                lstParam.Add(new SqlParameter("@madaily", intMaDaiLy));
                dt = SqlDataAccessHelper.ExecuteQuery("spLayThongTinDaiLyTheoMa", lstParam);

                DataRow dr = dt.Rows[0];
                daiLy._maDaiLy = int.Parse(dr["MaDaiLy"].ToString());
                daiLy._tenDaiLy = dr["TenDaiLy"].ToString();
                daiLy._diaChi = dr["DiaChi"].ToString();
                daiLy._email = dr["Email"].ToString();
                daiLy._nguoiDaiDien = dr["NguoiDaiDien"].ToString();
                daiLy._soDienThoai = dr["SoDienThoai"].ToString();
            }

            catch (Exception e)
            {
                daiLy = null;
                throw (e);
            }

            return daiLy;
        }