Exemplo n.º 1
0
 private void btnSuaLoaiSP_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (a == null)
         {
             MessageBox.Show("Vui lòng chọn Loại sản phẩm cần sửa");
         }
         else
         {
             LoaiSanPham b = new LoaiSanPham();
             b.maLoaiSanPham = txtmaLoai.Text;
             b.tenLoai       = txttenLoai.Text;
             b.trangThai     = 0;
             if (CLoaiSanPham_BUS.KTRong(b))
             {
                 if (CLoaiSanPham_BUS.edit(b))
                 {
                     MessageBox.Show("Sửa thành công");
                     HienThiDSLoaiSanPham();
                     load();
                 }
             }
             else
             {
                 MessageBox.Show("Yêu cầu nhập đầy đủ thông tin sản phẩm");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi: " + ex.Message);
     }
     HienThiDSLoaiSanPham();
 }
Exemplo n.º 2
0
        private void LstBoxLoaisanpham_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            int dongthu = LstBoxLoaisanpham.SelectedIndex;

            if (dongthu < 0)
            {
                MessageBox.Show("Chưa có loại sản phẩm nào được cập nhập");
                return;
            }
            string maLoai = CLoaiSanPham_BUS.layMaloaitheoSo(dongthu);

            hienthitheoListBOX(maLoai);
        }
Exemplo n.º 3
0
        public void HienThiDSLoaiSanPham()
        {
            List <LoaiSanPham> list = CLoaiSanPham_BUS.toList();

            if (list.Count > 0)
            {
                dgLoaisanpham.ItemsSource = list.Select(x => new
                {
                    maLoaiSanPham = x.maLoaiSanPham,
                    tenLoai       = x.tenLoai,
                    trangThai     = x.trangThai == 0 ? "Mở" : "Khóa"
                });
            }
            else
            {
                MessageBox.Show("Danh sách loại sản phẩm rỗng, chưa có loại sản phẩm nào");
            }
            txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.toList());
        }
Exemplo n.º 4
0
 private void dgLoaisanpham_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (dgLoaisanpham.SelectedItem != null)
         {
             a = CLoaiSanPham_BUS.find(dgLoaisanpham.SelectedValue.ToString());
             txtmaLoai.Text  = a.maLoaiSanPham;
             txttenLoai.Text = a.tenLoai;
         }
         else
         {
             txtmaLoai.Text  = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP());
             txttenLoai.Text = "";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi: " + ex.Message);
     }
 }
Exemplo n.º 5
0
 private void btnXoaLoaiSP_Click(object sender, RoutedEventArgs e)
 {
     if (a != null)
     {
         try
         {
             //string maloai = dgLoaisanpham.SelectedValue.ToString();
             string maloai = a.maLoaiSanPham.ToString();
             if (maloai == null)
             {
                 MessageBox.Show("Không tìm thấy");
             }
             else
             {
                 a = CLoaiSanPham_BUS.find(maloai);
                 if (CLoaiSanPham_BUS.remove(a))
                 {
                     if (CSanPham_BUS.thaydoiLoai(a))
                     {
                         MessageBox.Show("Đã thay đổi trạng thái " + maloai + " thành công.");
                         HienThiDSLoaiSanPham();
                         load();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Có lỗi: " + ex.Message);
         }
         HienThiDSLoaiSanPham();
         load();
     }
     else
     {
         MessageBox.Show("Vui lòng chọn sản phẩm cần thay đổi trạng thái");
     }
     HienThiDSLoaiSanPham();
     load();
 }
Exemplo n.º 6
0
 private void btnThemLoaiSP_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         LoaiSanPham a = new LoaiSanPham();
         a.maLoaiSanPham = txtmaLoai.Text;
         a.tenLoai       = txttenLoai.Text;
         a.trangThai     = 0;
         string makt = txtmaLoai.Text;
         if (CLoaiSanPham_BUS.KTRong(a))
         {
             if (CLoaiSanPham_BUS.find(makt) == null)
             {
                 CLoaiSanPham_BUS.add(a);
                 MessageBox.Show("Thêm thành công");
                 txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP());
             }
             else
             {
                 MessageBox.Show("Mã Loại bị trùng!");
             }
         }
         else
         {
             MessageBox.Show("Vui lòng nhập tên loại");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi: " + ex.Message);
     }
     HienThiDSLoaiSanPham();
     load();
     txttenLoai.Text = "";
     //btnBoChon_Click(sender, e);
 }
Exemplo n.º 7
0
 private void LstBoxLoaisanpham_Loaded(object sender, RoutedEventArgs e)
 {
     LstBoxLoaisanpham.ItemsSource = CLoaiSanPham_BUS.DSLoaiSPtheoTen();//hien thi ra list ten do uong
 }
Exemplo n.º 8
0
 public void load()
 {
     txtmaLoai.Text = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP());
     a = null;
 }
Exemplo n.º 9
0
 private void btnBoChon_Click(object sender, RoutedEventArgs e)
 {
     txtmaLoai.Text  = CServices.taoMa <LoaiSanPham>(CLoaiSanPham_BUS.DSLoaiSP());
     txttenLoai.Text = "";
     a = null;
 }