コード例 #1
0
 bool kiemTraSoLuong()
 {
     using (DataBanHang data = new DataBanHang())
     {
         try
         {
             var a = data.HangHoas.Where(d => d.MaHH.Equals(maHH)).Select(d => d.SoLuong);
             if (Convert.ToInt32(txtSl.Text) > Convert.ToInt32(a.FirstOrDefault()))
             {
                 lblSl.ForeColor  = Color.Red;
                 lblThongbao.Text = "Vượt quá SL trong kho !";
                 return(false);
             }
             if (Convert.ToInt32(txtSl.Text) == 0)
             {
                 lblSl.ForeColor  = Color.Red;
                 lblThongbao.Text = "SL ít nhất phải là 1 !";
                 return(false);
             }
             if (Convert.ToInt32(txtSl.Text) <= Convert.ToInt32(a.FirstOrDefault()) && Convert.ToInt32(txtSl.Text) > 0)
             {
                 lblSl.ForeColor  = Color.Black;
                 lblThongbao.Text = "";
                 return(true);
             }
         }
         catch
         {
             lblSl.ForeColor  = Color.Red;
             lblThongbao.Text = "SL đang trống !";
             return(false);
         }
     }
     return(true);
 }
コード例 #2
0
 void thongTinKH()
 {
     using (DataBanHang dt = new DataBanHang())
     {
         cbTenkh.DataSource    = dt.KhachHangs.Where(d => d.TinhTrang.Equals("True")).Select(d => d);
         cbTenkh.DisplayMember = "TenKH";
     }
     valueMember();
 }
コード例 #3
0
 private void frmCR_BanHang_Load(object sender, EventArgs e)
 {
     using (DataBanHang data = new DataBanHang())
     {
         CR_BanHang       cR_BanHang = new CR_BanHang();
         var              result     = data.sp_BillBanHang().ToList();
         CollectionHelper ch         = new CollectionHelper();
         DataTable        dt         = ch.ConvertTo(result);
         cR_BanHang.SetDataSource(dt);
         crBanHang.ReportSource = cR_BanHang;
     }
 }
コード例 #4
0
 void luuHoaDon()
 {
     if (lblTenKH.Text == "Khách lẻ" && Convert.ToInt32(txtNolai.Text) > 0)
     {
         MessageBox.Show("Khách lẻ không cho nợ !");
     }
     else
     {
         using (DataBanHang data = new DataBanHang())
         {
             HoaDonBanHang hdbh = new HoaDonBanHang();
             var           a    = data.HoaDonBanHangs.Max(d => d.MaHDB);
             hdbh.MaHDB       = a + 1;
             hdbh.KhachHang   = Convert.ToInt32(lblMakh.Text);
             hdbh.NhanVienLap = 9;
             hdbh.NgayLap     = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"));
             hdbh.CK          = Convert.ToInt32(txtCk.Text);
             hdbh.NoCu        = Convert.ToInt32(txtNocu.Text);
             hdbh.TienTra     = Convert.ToInt32(txtKhachtra.Text);
             hdbh.GhiChu      = txtGhichu.Text;
             hdbh.TinhTrang   = true;
             data.HoaDonBanHangs.InsertOnSubmit(hdbh);
             foreach (CTHDBanHangDTO item in mangCTHD)
             {
                 CTHDBanHang cthdbh = new CTHDBanHang();
                 cthdbh.MaHDB     = hdbh.MaHDB;
                 cthdbh.SanPham   = item.SanPham;
                 cthdbh.SL        = item.Sl;
                 cthdbh.TinhTrang = true;
                 cthdbh.DonGia    = Convert.ToDouble(item.DonGia);
                 data.CTHDBanHangs.InsertOnSubmit(cthdbh);
                 data.SubmitChanges();
             }
             foreach (CTHDBanHangDTO item in mangCTHD)
             {
                 CTHDBanHang cthdbh = new CTHDBanHang();
                 HangHoa     hh     = data.HangHoas.Where(d => d.MaHH.Equals(item.SanPham)).FirstOrDefault();
                 hh.SoLuong = hh.SoLuong - item.Sl;
                 //sau khi thanh toán thành công thì phải xét lại sl trong bảng hóa đơn hoặc reset bảng hóa đơn
                 data.SubmitChanges();
             }
             KhachHang kh = data.KhachHangs.Where(d => d.MaKH.Equals(lblMakh.Text)).SingleOrDefault();
             kh.SoNo = Convert.ToInt32(txtNolai.Text);
             data.SubmitChanges();
             MessageBox.Show("Lưu Thành Công !");
             this.Close();
             resetHoaDon();
         }
     }
 }
コード例 #5
0
 void dataSourceHangHoa()
 {
     using (DataBanHang dthh = new DataBanHang())
     {
         dtgThemHoaDon.DataSource = from h in dthh.HangHoas
                                    where h.TinhTrang.Equals("True")
                                    select new
         {
             MaHH      = h.MaHH,
             TenHH     = h.TenHH,
             DonViTinh = h.DonViTinh,
             GiaBan    = h.GiaBan,
             SoLuong   = h.SoLuong,
             GhiChu    = h.GhiChu
         };
     }
 }
コード例 #6
0
 void timKiemHangHoa()
 {
     using (DataBanHang dthh = new DataBanHang())
     {
         dtgThemHoaDon.DataSource = from h in dthh.HangHoas
                                    where h.TinhTrang.Equals("True")
                                    select new
         {
             MaHH      = h.MaHH,
             TenHH     = h.TenHH,
             DonViTinh = h.DonViTinh,
             GiaBan    = h.GiaBan,
             SoLuong   = h.SoLuong,
             GhiChu    = h.GhiChu
         } into newselect
         where newselect.TenHH.Contains(txtTimkiem.Text)
         select newselect;
     }
 }