예제 #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            SanPhamBus    bussp = new SanPhamBus();
            SanPhamEntity sp    = new SanPhamEntity();
            KetNoiCSDL    con   = new KetNoiCSDL();

            try
            {
                sp.MaSP    = con.SinhMa("SANPHAM", "SP");
                sp.TenSP   = txtTenSP.Text;
                sp.SoLuong = int.Parse(txtSoLuong.Text);
                sp.GiaBan  = int.Parse(txtGiaBan.Text);
                sp.GiaNhap = int.Parse(txtGiaNhap.Text);
                sp.MaLH    = cboLoaiHang.SelectedValue.ToString();
                sp.NhaCC   = cboNhaCC.SelectedValue.ToString();
                sp.NSX     = dtNgaySX.Value.ToString();
                sp.MoTa    = rtbMoTa.Text;
                sp.HinhAnh = null;
                bussp.ThemSanPham(sp);
                MessageBox.Show("Nhập hàng thành công", "Thông báo");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     en_nv.TenNV       = txtTennv.Text;
     en_nv.GT          = cboGt.Text;
     en_nv.DiaChi      = txtDiachi.Text;
     en_nv.SDT         = txtSdt.Text;
     en_nv.TenDangNhap = txtTendn.Text;
     en_nv.MatKhau     = txtMk.Text;
     if (them == true)
     {
         if (txtManv.Text != "")
         {
             try
             {
                 en_nv.MaNV = con.SinhMa("NHANVIEN", "NV");
                 nv.ThemNhanVien(en_nv);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
         else
         {
             MessageBox.Show("ban chua nhap manv");
         }
     }
     else
     {
         try
         {
             en_nv.MaNV = txtManv.Text.ToString();
             nv.SuaNhanVien(en_nv);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     khoadk();
     dgvNhanvien.DataSource = nv.HienThiNhanVien("");
     gannull();
 }
예제 #3
0
        private void btnBanhang_Click(object sender, EventArgs e)
        {
            try
            {
                int i, tong = 0;
                if (sanpham.Rows.Count > 0)
                {
                    string mahd = con.SinhMa("HOADONBAN", "HDB");
                    en_hd.MaHDB   = mahd;
                    en_hd.MaKH    = cboKhachhang.SelectedValue.ToString();
                    en_hd.MaNV    = cboNhanvien.SelectedValue.ToString();
                    en_hd.NgayBan = DateTime.Today.AddDays(0).ToString();
                    for (i = 0; i < sanpham.Rows.Count - 1; i++)
                    {
                        tong = tong + int.Parse(sanpham.Rows[i]["ThanhTien"].ToString());
                    }
                    en_hd.TongTien = tong.ToString();
                    hd.ThemHoaDon(en_hd);

                    for (i = 0; i < sanpham.Rows.Count; i++)
                    {
                        en_cthd.MaHD      = mahd;
                        en_cthd.MaSP      = sanpham.Rows[i]["MaSP"].ToString();
                        en_cthd.DonGia    = sanpham.Rows[i]["GiaBan"].ToString();
                        en_cthd.SoLuong   = sanpham.Rows[i]["SoLuong"].ToString();
                        en_cthd.ThanhTien = sanpham.Rows[i]["ThanhTien"].ToString();
                        cthd.ThemChiTietHonDon(en_cthd);
                    }
                    MessageBox.Show("Đã bán hàng");
                    dem = 0;
                    //  khoadk();
                    sanpham.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        private void btnLuu_Click_1(object sender, EventArgs e)
        {
            khenti.TenKH  = txtTenkh.Text;
            khenti.GT     = cboGT.Text;
            khenti.DiaChi = txtDiachi.Text;
            khenti.SDT    = txtSDT.Text;
            khenti.LoaiKH = txtLoaikh.Text;
            khenti.GhiChu = txtGhichu.Text;

            if (them == true)
            {
                try
                {
                    khenti.MaKH = con.SinhMa("KHACHHANG", "KH");
                    khbus.ThemKhachHang(khenti);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    khenti.MaKH = txtMakh.Text.ToString();
                    khbus.SuaKhachHang(khenti);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            khoadk();
            dgvKhachhang.DataSource = khbus.HienThiKhachHang("");
            gannull();
        }