Ejemplo n.º 1
0
        private void cbbLoai_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var MaLoai = cbbLoai.SelectedValue.ToString();

            using (MyEStoreDataContext _Database = new MyEStoreDataContext()) {
                _Database.DeferredLoadingEnabled = false;
                var danhSachHangHoaTheoLoai =
                    _Database.HangHoas.Where(hh => hh.MaLoai.Equals(MaLoai)).ToList();

                dgvHangHoa.DataSource = danhSachHangHoaTheoLoai;
            }
        }
Ejemplo n.º 2
0
        private void FormThemHangHoa_Load(object sender, EventArgs e)
        {
            using (MyEStoreDataContext _Database = new MyEStoreDataContext()) {
                cbbLoaiHangHoa.DataSource    = _Database.Loais.ToList();
                cbbLoaiHangHoa.DisplayMember = "TenLoai";
                cbbLoaiHangHoa.ValueMember   = "MaLoai";

                cbbNhaCungCap.DataSource    = _Database.NhaCungCaps.ToList();
                cbbNhaCungCap.DisplayMember = "TenCongTy";
                cbbNhaCungCap.ValueMember   = "MaNCC";
            }
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form         fThemHangHoa = new FormThemHangHoa();
            DialogResult formThem     = fThemHangHoa.ShowDialog();

            if (formThem == DialogResult.OK)
            {
                using (MyEStoreDataContext _Database = new MyEStoreDataContext())
                {
                    _Database.DeferredLoadingEnabled = false;
                    dgvHangHoa.DataSource            = _Database.HangHoas.ToList();
                }
            }
        }
Ejemplo n.º 4
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            string tuKhoa = txtTuKhoa.Text;

            using (MyEStoreDataContext _Database = new MyEStoreDataContext()) {
                _Database.DeferredLoadingEnabled = false;
                var danhSachHHTimKiem =
                    _Database.HangHoas.Where(
                        hh => hh.TenHH.Contains(tuKhoa) ||
                        hh.MaHH.ToString().Contains(tuKhoa)
                        ).ToList();
                dgvHangHoa.DataSource = danhSachHHTimKiem;
            }
        }
Ejemplo n.º 5
0
        private void dgvHangHoa_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var MaHH = dgvHangHoa.Rows[e.RowIndex].Cells[0].Value.ToString();

            Form         formSuaHangHoa = new FormSuaHangHoa(MaHH);
            DialogResult kt             = formSuaHangHoa.ShowDialog();

            if (kt == DialogResult.OK)
            {
                using (MyEStoreDataContext _Database = new MyEStoreDataContext())
                {
                    _Database.DeferredLoadingEnabled = false;
                    dgvHangHoa.DataSource            = _Database.HangHoas.ToList();
                }
            }
        }
Ejemplo n.º 6
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         HangHoa hh = GetInputForm();
         using (MyEStoreDataContext _Database = new MyEStoreDataContext())
         {
             _Database.HangHoas.InsertOnSubmit(hh);
             _Database.SubmitChanges();
             DialogResult = DialogResult.OK;
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            using (MyEStoreDataContext _Database = new MyEStoreDataContext()) {
                _Database.DeferredLoadingEnabled = false;
                //Load datagreaView
                dgvHangHoa.DataSource = _Database.HangHoas.ToList();
                //Load cbbLoai
                List <Loai> danhSachLoai = _Database.Loais.ToList();
                danhSachLoai.Insert(0, new Loai()
                {
                    MaLoai  = 0,
                    TenLoai = "Chọn Loại Sản Phẩm"
                });
                cbbLoai.DataSource = danhSachLoai;

                cbbLoai.SelectedIndex = 0;
                cbbLoai.ValueMember   = "MaLoai";
                cbbLoai.DisplayMember = "TenLoai";
            }
        }