protected void btnLuu_Click(object sender, EventArgs e)
        {
            DTOKhachHang dtoKH = new DTOKhachHang();

            dtoKH.TenKH    = txtTenKH.Text;
            dtoKH.DiaChiKH = txtDiaChi.Text;
            dtoKH.SdtKH    = txtSdt.Text;

            DTOLoaiKH dtoLoaiKH = new DTOLoaiKH();

            dtoLoaiKH.MaLKH  = int.Parse(ddLoaiKH.SelectedValue);
            dtoLoaiKH.TenLKH = ddLoaiKH.SelectedItem.ToString();
            dtoKH.dtoLoaiKH  = dtoLoaiKH;

            XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();

            //        DAO_Entity daoKH = new DAO_Entity();
            if (KiemTraNhap() == "")
            {
                control.ThemKH(dtoKH);
                Response.Redirect("~/QLBoPhan_TiepXucKH/DSKhachHang.aspx");
            }
            else
            {
                ThemKH.Visible = true;
                lbLoi.Text     = KiemTraNhap();
            }
        }
Exemplo n.º 2
0
        public DTOKhachHang getKhachHangDetail(string mahanghoa)
        {
            DALDoiTac um = new DALDoiTac();

            DataTable    dt = um.getKhachHangDetail(mahanghoa);
            DTOKhachHang a  = new DTOKhachHang();

            a.MAKH        = dt.Rows[0]["MAKH"].ToString();
            a.MaKhuVuc    = dt.Rows[0]["MaKhuVuc"].ToString();
            a.HOTEN       = dt.Rows[0]["HOTEN"].ToString();
            a.DiaChi      = dt.Rows[0]["DiaChi"].ToString();
            a.MaSoThue    = dt.Rows[0]["MaSoThue"].ToString();
            a.Fax         = dt.Rows[0]["Fax"].ToString();
            a.SODT        = dt.Rows[0]["SODT"].ToString();
            a.Mobile      = dt.Rows[0]["Mobile"].ToString();
            a.Email       = dt.Rows[0]["Email"].ToString();
            a.Website     = dt.Rows[0]["Website"].ToString();
            a.TaiKhoan    = dt.Rows[0]["TaiKhoan"].ToString();
            a.NganHang    = dt.Rows[0]["NganHang"].ToString();
            a.GioiHanNo   = dt.Rows[0]["GioiHanNo"].ToString();
            a.NoHienTai   = dt.Rows[0]["NoHienTai"].ToString();
            a.ChietKhau   = dt.Rows[0]["ChietKhau"].ToString();
            a.NickYahoo   = dt.Rows[0]["NickYahoo"].ToString();
            a.NguoiLienHe = dt.Rows[0]["NguoiLienHe"].ToString();
            a.NickSkype   = dt.Rows[0]["NickSkype"].ToString();
            a.ConQuanLy   = Convert.ToBoolean(dt.Rows[0]["ConQuanLy"].ToString());
            a.DaiLy       = Convert.ToBoolean(dt.Rows[0]["DaiLy"].ToString());
            a.KhachLe     = Convert.ToBoolean(dt.Rows[0]["KhachLe"].ToString());
            return(a);
        }
Exemplo n.º 3
0
        public int updateKhachHang(DTOKhachHang hanghoa)
        {
            var _cmd = new SqlCommand();

            _cmd.CommandText = "update KHACHHANG set MAKH=@MAKH,MaKhuVuc=@MaKhuVuc,HOTEN=@HOTEN,DiaChi=@DiaChi,MaSoThue=@MaSoThue,Fax=@Fax,SODT=@SODT,Mobile=@Mobile,Email=@Email,Website=@Website,TaiKhoan=@TaiKhoan,NganHang=@NganHang,GioiHanNo=@GioiHanNo,NoHienTai=@NoHienTai,ChietKhau=@ChietKhau,NickYahoo=@NickYahoo,NguoiLienHe=@NguoiLienHe,NickSkype=@NickSkype,ConQuanLy=@ConQuanLy,DaiLy=@DaiLy,KhachLe=@KhachLe where MAKH=@MAKH ";
            _cmd.CommandType = CommandType.Text;
            _cmd.Connection  = connection;
            _cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value        = hanghoa.MAKH;
            _cmd.Parameters.Add("@MaKhuVuc", SqlDbType.NVarChar).Value    = hanghoa.MaKhuVuc;
            _cmd.Parameters.Add("@HOTEN", SqlDbType.NVarChar).Value       = hanghoa.HOTEN;
            _cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value      = hanghoa.DiaChi;
            _cmd.Parameters.Add("@MaSoThue", SqlDbType.NVarChar).Value    = hanghoa.MaSoThue;
            _cmd.Parameters.Add("@Fax", SqlDbType.NVarChar).Value         = hanghoa.Fax;
            _cmd.Parameters.Add("@SODT", SqlDbType.NVarChar).Value        = hanghoa.SODT;
            _cmd.Parameters.Add("@Mobile", SqlDbType.NVarChar).Value      = hanghoa.Mobile;
            _cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value       = hanghoa.Email;
            _cmd.Parameters.Add("@TaiKhoan", SqlDbType.NVarChar).Value    = hanghoa.TaiKhoan;
            _cmd.Parameters.Add("@NganHang", SqlDbType.NVarChar).Value    = hanghoa.NganHang;
            _cmd.Parameters.Add("@GioiHanNo", SqlDbType.Money).Value      = Convert.ToDecimal(hanghoa.GioiHanNo);
            _cmd.Parameters.Add("@NoHienTai", SqlDbType.Money).Value      = Convert.ToDecimal(hanghoa.NoHienTai);
            _cmd.Parameters.Add("@ChietKhau", SqlDbType.Float).Value      = Convert.ToDouble(hanghoa.ChietKhau);
            _cmd.Parameters.Add("@NickYahoo", SqlDbType.NVarChar).Value   = hanghoa.NickYahoo;
            _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.NVarChar).Value = hanghoa.NguoiLienHe;
            _cmd.Parameters.Add("@NickSkype", SqlDbType.NVarChar).Value   = hanghoa.NickSkype;
            _cmd.Parameters.Add("@Website", SqlDbType.NVarChar).Value     = hanghoa.Website;
            _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value        = hanghoa.ConQuanLy;
            _cmd.Parameters.Add("@DaiLy", SqlDbType.Bit).Value            = hanghoa.DaiLy;
            _cmd.Parameters.Add("@KhachLe", SqlDbType.Bit).Value          = hanghoa.KhachLe;
            OpenConn();
            var i = _cmd.ExecuteNonQuery();

            CloseConn();
            return(i);
        }
Exemplo n.º 4
0
        private void btThem_Click(object sender, EventArgs e)
        {
            string ma, ho, ten, cmnd, dc, sdt; DateTime ngaysinh;

            ma       = txtMaKH.Text.Trim();
            ho       = txtHoKH.Text.Trim();
            ten      = txtTenKH.Text.Trim();
            ngaysinh = Convert.ToDateTime(dtpNgaySinh.Text);
            cmnd     = txtCMND.Text.Trim();
            dc       = txtDiaChi.Text.Trim();
            sdt      = txtSDT.Text.Trim();

            DTOKhachHang kh = new DTOKhachHang(ma, ho, ten, ngaysinh, cmnd, dc, sdt);

            try
            {
                int i = new BUSKhachHang().Add(kh);
                dgvThemKH.DataSource = GetKH();
                load();
                dgvXoaKH.DataSource = GetKH();
                xoatrangKH();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
 public List <DTOKhachHang> GetKH(string sql)
 {
     dp.connect();
     List <DTOKhachHang> list = new List <DTOKhachHang>();
     {
         string   ma, ho, ten, cmnd, dc, sdt;
         DateTime ngaysinh;
         try
         {
             SqlDataReader dr = dp.ExecuteReader(sql);
             while (dr.Read())
             {
                 ma       = dr.GetString(0);
                 ho       = dr.GetString(1);
                 ten      = dr.GetString(2);
                 ngaysinh = dr.GetDateTime(3);
                 cmnd     = dr.GetString(4);
                 dc       = dr.GetString(5);
                 sdt      = dr.GetString(6);
                 //fax = dr.GetString(7);
                 DTOKhachHang kh = new DTOKhachHang(ma, ho, ten, ngaysinh, cmnd, dc, sdt);
                 list.Add(kh);
             }
             dr.Close();
             return(list);
         }
         catch (SqlException ex)
         {
             throw ex;
         }
         finally { dp.disconnect(); }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DTOKhachHang dto   = new DTOKhachHang();
                DAO_Entity   daokh = new DAO_Entity();

                XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();
                control.LayDSKhachHang();

                List <DTOKhachHang> Dskh = daokh.TaoDSKH();
                GridDSKH.DataSource = Dskh;
                GridDSKH.DataBind();
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Loi tai du lieu!')</script>");
            }
            ThemKH.Visible = false;


            if (IsPostBack == false)
            {
                List <DTOLoaiKH> dsLKH = new List <DTOLoaiKH>();
                DAO_Entity       daoKH = new DAO_Entity();
                dsLKH = daoKH.LayDSLKH();
                //hien thi ten loai KH ra dropdownlist
                ddLoaiKH.DataTextField = "TenLKH"; //TenLKH la thuoc tinh trong DTOLoaiKH
                //truyen dl theo ma loai
                ddLoaiKH.DataValueField = "MaLKH"; //MaLKH la thuoc tinh trong DTOLoaiKH
                ddLoaiKH.DataSource     = dsLKH;
                ddLoaiKH.DataBind();
            }
        }
Exemplo n.º 7
0
        public bool insertKhachHang(DTOKhachHang KhachHang)
        {
            DALDoiTac um = new DALDoiTac();

            bool dt = um.insertKhachHang(KhachHang);

            return(dt);
        }
Exemplo n.º 8
0
        public int updateKhachHang(DTOKhachHang KhachHang)
        {
            DALDoiTac um = new DALDoiTac();

            int dt = um.updateKhachHang(KhachHang);

            return(dt);
        }
 public bool Edit(DTOKhachHang kh)
 {
     SqlParameter[] sqlP = new SqlParameter[4];
     sqlP[0] = new SqlParameter("@MaKH", kh.MaKH);
     sqlP[1] = new SqlParameter("@TenKH", kh.TenKH);
     sqlP[2] = new SqlParameter("@DiaChi", kh.DiaChi);
     sqlP[3] = new SqlParameter("@DienThoai", kh.DienThoai);
     return(dalGeneric.execNonQuery("updateKhachHang", sqlP));
 }
Exemplo n.º 10
0
        public List <DTOKhachHang> SearchData(string keyword)
        {
            List <DTOKhachHang> tableList = new List <DTOKhachHang>();
            DataTable           data      = DataProvider.Instance.ExcuteQuery("EXEC USP_SearchCustomerByName @keyword", new object[] { keyword }); //Procedure in sql, also can use select *...

            foreach (DataRow item in data.Rows)
            {
                DTOKhachHang table = new DTOKhachHang(item);
                tableList.Add(table);
            }
            return(tableList);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hienThanhPhamChon();

                if (Session["dsThanhPhamChon"] == null)
                {
                    lbDSChon.Visible       = false;
                    lbTextTongTien.Visible = false;
                    lbTongTien.Visible     = false;
                    lbDSSanpham.Visible    = false;
                    grDSSanPham.Visible    = false;
                    gridDSChon.Visible     = false;
                }
                else
                {
                    lbDSChon.Visible       = true;
                    lbTextTongTien.Visible = true;
                    lbTongTien.Visible     = true;
                    lbDSSanpham.Visible    = true;
                    grDSSanPham.Visible    = true;
                    gridDSChon.Visible     = true;
                }
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Loi tai du lieu!')</script>");
            }

            if (IsPostBack == false)//postback=false: chưa có sự kiện click trên web
            {
                // request: yeu cau. QueryString: lay gia tri cua chuoi tren duong dan
                string       makh        = Request.QueryString["MaKH"].ToString();
                DAO_Entity   daoEntities = new DAO_Entity();
                DTOKhachHang dtoKH       = daoEntities.LayTTKHTheoMa(makh);

                XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();
                control.LayttKH(makh);

                lbMaKH.Text       = dtoKH.MaKH.ToString();
                txtTen.Text       = dtoKH.TenKH;
                txtNgayTaoDH.Text = DateTime.Now.ToShortDateString();


                List <DTODonDatHang> dsdh = daoEntities.LayDSDHTheoMa(makh);
                GridViewDH.DataSource = dsdh;
                GridViewDH.DataBind();
                grDSSanPham.DataSource = daoEntities.TaoDSSP();
                grDSSanPham.DataBind();
            }
        }
Exemplo n.º 12
0
        DTOKhachHang GetCustomerById(int id)
        {
            List <DTOKhachHang> table = DAOKhachHang.Instance.LoadData();
            DTOKhachHang        temp  = null;

            foreach (DTOKhachHang item in table)
            {
                if (item.ID == id)
                {
                    temp = item;
                }
            }
            return(temp);
        }
Exemplo n.º 13
0
 private void txtbPhone_TextChanged(object sender, EventArgs e)
 {
     khachHang = DAOKhachHang.Instance.GetKhachHangBySDT(txtbPhone.Text);
     if (khachHang != null)
     {
         btnNext.Enabled            = true;
         txtbName.Text              = khachHang.HoTen;
         txtbAccumulatedPoints.Text = khachHang.DiemTichLuy.ToString();
     }
     else
     {
         btnNext.Enabled            = false;
         txtbName.Text              = "";
         txtbAccumulatedPoints.Text = "";
     }
 }
Exemplo n.º 14
0
        public List <DTOKhachHang> LoadData()
        {
            List <DTOKhachHang> tableList = new List <DTOKhachHang>();
            DataTable           data      = DataProvider.Instance.ExcuteQuery("USP_GetListCustomer");

            foreach (DataRow item in data.Rows)
            {
                DTOKhachHang table = new DTOKhachHang(item);
                //if (item["NgaySinh"].ToString().Length != 0)
                //{
                //    Console.WriteLine(Convert.ToDateTime(item["NgaySinh"].ToString()));
                //}
                tableList.Add(table);  //ngay sinh null se in ra 1/1/0001
            }
            return(tableList);
        }
Exemplo n.º 15
0
        private void frmKhachHang_Add_Load(object sender, EventArgs e)
        {
            DataTable dt2 = new DataTable();
            BUSDoiTac bus = new BUSDoiTac();

            dt2 = bus.getKhuVuc();
            if (dt2.Rows.Count > 0)
            {
                foreach (DataRow row in dt2.Rows)
                {
                    comboBoxEdit1.Properties.Items.Add(row["MaKhuVuc"]);
                }
            }

            if (!isAddForm)
            {
                BUSDoiTac    b          = new BUSDoiTac();
                DTOKhachHang dtoHangHoa = b.getKhachHangDetail(gotID);
                textEdit1.Text       = dtoHangHoa.MAKH;
                textEdit2.Text       = dtoHangHoa.HOTEN;
                textEdit3.Text       = dtoHangHoa.DiaChi;
                textEdit4.Text       = dtoHangHoa.MaSoThue;
                textEdit5.Text       = dtoHangHoa.Fax;
                textEdit6.Text       = dtoHangHoa.SODT;
                textEdit7.Text       = dtoHangHoa.Mobile;
                textEdit8.Text       = dtoHangHoa.Email;
                textEdit9.Text       = dtoHangHoa.Website;
                textEdit10.Text      = dtoHangHoa.TaiKhoan;
                textEdit11.Text      = dtoHangHoa.NganHang;
                textEdit12.Text      = dtoHangHoa.NickYahoo;
                textEdit13.Text      = dtoHangHoa.NguoiLienHe;
                textEdit14.Text      = dtoHangHoa.NickSkype;
                comboBoxEdit1.Text   = dtoHangHoa.MaKhuVuc;
                comboBoxEdit2.Text   = dtoHangHoa.GioiHanNo;
                comboBoxEdit3.Text   = dtoHangHoa.NoHienTai;
                comboBoxEdit4.Text   = dtoHangHoa.ChietKhau;
                radioButton1.Checked = dtoHangHoa.DaiLy;
                radioButton2.Checked = dtoHangHoa.KhachLe;
                checkEdit1.Checked   = dtoHangHoa.ConQuanLy;
            }
            else
            {
                textEdit1.ReadOnly = false;
            }
        }
Exemplo n.º 16
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BUSDoiTac    b = new BUSDoiTac();
            DTOKhachHang d = new DTOKhachHang();

            d.MAKH        = textEdit1.Text;
            d.HOTEN       = textEdit2.Text;
            d.DiaChi      = textEdit3.Text;
            d.MaSoThue    = textEdit4.Text;
            d.Fax         = textEdit5.Text;
            d.SODT        = textEdit6.Text;
            d.Mobile      = textEdit7.Text;
            d.Email       = textEdit8.Text;
            d.Website     = textEdit9.Text;
            d.TaiKhoan    = textEdit10.Text;
            d.NganHang    = textEdit11.Text;
            d.NickYahoo   = textEdit12.Text;
            d.NguoiLienHe = textEdit13.Text;
            d.NickSkype   = textEdit14.Text;
            d.MaKhuVuc    = comboBoxEdit1.Text;
            d.GioiHanNo   = comboBoxEdit2.Text;
            d.NoHienTai   = comboBoxEdit3.Text;
            d.ChietKhau   = comboBoxEdit4.Text;
            d.ConQuanLy   = checkEdit1.Checked;
            d.DaiLy       = radioButton1.Checked;
            d.KhachLe     = radioButton2.Checked;
            if (isAddForm)
            {
                if (b.insertKhachHang(d))
                {
                    MessageBox.Show("Thao tác thành công");
                }
                else
                {
                    MessageBox.Show("Thao tác không thành công");
                }
            }
            else
            {
                b.updateKhachHang(d);
                MessageBox.Show("Thao tác hóa thành công");
            }
        }
Exemplo n.º 17
0
        public int Add(DTOKhachHang kh)
        {
            List <SqlParameter> paras = new List <SqlParameter>();

            paras.Add(new SqlParameter("@ma", kh.MaKH));
            paras.Add(new SqlParameter("@ho", kh.Ho));
            paras.Add(new SqlParameter("@ten", kh.Ten));
            paras.Add(new SqlParameter("@ngaysinh", kh.NgaySinh));
            paras.Add(new SqlParameter("@cmnd", kh.CMND));
            paras.Add(new SqlParameter("@dc", kh.DiaChi));
            paras.Add(new SqlParameter("@sdt", kh.SDT));
            try
            {
                return(dp.ExcuteNonQuery("ThemKH", System.Data.CommandType.StoredProcedure, paras));
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 18
0
        public bool insertKhachHang(DTOKhachHang hanghoa)
        {
            string query = string.Format($"select * from KHACHHANG where MAKH='{hanghoa.MAKH}'");

            if (ExecSelectedCount(query) == 0)
            {
                var _cmd = new SqlCommand();
                _cmd.CommandText = "insert into KHACHHANG values (@MAKH,@MaKhuVuc,@HOTEN,@DiaChi,@MaSoThue,@Fax,@SODT,@Mobile,@Email,@Website,@TaiKhoan,@NganHang,@GioiHanNo,@NoHienTai,@ChietKhau,@NickYahoo,@NguoiLienHe,@NickSkype,@ConQuanLy,@DaiLy,@KhachLe)";
                _cmd.CommandType = CommandType.Text;
                _cmd.Connection  = connection;
                _cmd.Parameters.Add("@MAKH", SqlDbType.Text).Value        = hanghoa.MAKH;
                _cmd.Parameters.Add("@MaKhuVuc", SqlDbType.Text).Value    = hanghoa.MaKhuVuc;
                _cmd.Parameters.Add("@HOTEN", SqlDbType.Text).Value       = hanghoa.HOTEN;
                _cmd.Parameters.Add("@DiaChi", SqlDbType.Text).Value      = hanghoa.DiaChi;
                _cmd.Parameters.Add("@MaSoThue", SqlDbType.Text).Value    = hanghoa.MaSoThue;
                _cmd.Parameters.Add("@Fax", SqlDbType.Text).Value         = hanghoa.Fax;
                _cmd.Parameters.Add("@SODT", SqlDbType.Text).Value        = hanghoa.SODT;
                _cmd.Parameters.Add("@Mobile", SqlDbType.Text).Value      = hanghoa.Mobile;
                _cmd.Parameters.Add("@Email", SqlDbType.Text).Value       = hanghoa.Email;
                _cmd.Parameters.Add("@TaiKhoan", SqlDbType.Text).Value    = hanghoa.TaiKhoan;
                _cmd.Parameters.Add("@NganHang", SqlDbType.Text).Value    = hanghoa.NganHang;
                _cmd.Parameters.Add("@GioiHanNo", SqlDbType.Money).Value  = Convert.ToDecimal(hanghoa.GioiHanNo);
                _cmd.Parameters.Add("@NoHienTai", SqlDbType.Money).Value  = Convert.ToDecimal(hanghoa.NoHienTai);
                _cmd.Parameters.Add("@ChietKhau", SqlDbType.Float).Value  = Convert.ToDouble(hanghoa.ChietKhau);
                _cmd.Parameters.Add("@NickYahoo", SqlDbType.Text).Value   = hanghoa.NickYahoo;
                _cmd.Parameters.Add("@NguoiLienHe", SqlDbType.Text).Value = hanghoa.NguoiLienHe;
                _cmd.Parameters.Add("@Website", SqlDbType.Text).Value     = hanghoa.Website;
                _cmd.Parameters.Add("@NickSkype", SqlDbType.Text).Value   = hanghoa.NickSkype;
                _cmd.Parameters.Add("@ConQuanLy", SqlDbType.Bit).Value    = hanghoa.ConQuanLy;
                _cmd.Parameters.Add("@DaiLy", SqlDbType.Bit).Value        = hanghoa.DaiLy;
                _cmd.Parameters.Add("@KhachLe", SqlDbType.Bit).Value      = hanghoa.KhachLe;
                OpenConn();
                var i = _cmd.ExecuteNonQuery();
                CloseConn();
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public static bool Add(DTOKhachHang kh)
 {
     return(dalKhachHang.Add(kh));
 }
Exemplo n.º 20
0
 public int Add(DTOKhachHang kh)
 {
     return(new DAOKhachHang().Add(kh));
 }
        public void ThemKH(DTOKhachHang dtoKH)
        {
            DAO_Entity dao = new DAO_Entity();

            dao.ThemKhachHang(dtoKH);
        }
 public static bool Edit(DTOKhachHang kh)
 {
     return(dalKhachHang.Edit(kh));
 }