private void Sua() { HoaDonNhapDTO hd = new HoaDonNhapDTO(); hd.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); hd.NgayNhap = dateNhap.Value.ToShortDateString(); hd.MaNhaCC = (int)cboCC.SelectedValue; hd.TongTien = 0; HoaDonNhapDAO.sua(hd); ChiTietNhapDTO hh = new ChiTietNhapDTO(); hh.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); for (int i = 0; i < dgvchitiet.RowCount - 1; i++) { hh.TenHang = dgvchitiet.Rows[i].Cells[2].Value.ToString(); hh.SoLuong = int.Parse(dgvchitiet.Rows[i].Cells[3].Value.ToString()); hh.DonGia = int.Parse(dgvchitiet.Rows[i].Cells[4].Value.ToString()); hh.GiaXuat = int.Parse(dgvchitiet.Rows[i].Cells[4].Value.ToString()) * 2; try { hh.GhiChu = dgvchitiet.Rows[i].Cells[0].Value.ToString(); } catch { } DataTable dt = HoaDonNhapDAO.TimHangHoa(hh.TenHang); try { hh.MaHangHoa = int.Parse(dt.Rows[0][0].ToString()); ChiTietNhapDAO.SuaCT(hh); } catch { hh.MaHangHoa = ChiTietNhapDAO.IDMax() + 1; ChiTietNhapDAO.themmoi(hh); } HoaDonNhapDAO.UpdateTongTien(hh); } }
private void dgvchitiet_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { if (x == 1) { try { dgvchitiet.Rows.RemoveAt(e.RowIndex); } catch { } return; } ChiTietNhapDTO hh = new ChiTietNhapDTO(); hh.TenHang = dgvchitiet.Rows[e.RowIndex].Cells[2].Value.ToString(); hh.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); DataTable dt = HoaDonNhapDAO.TimHangHoa(hh.TenHang); try { hh.SoLuong = int.Parse(dgvchitiet.Rows[e.RowIndex].Cells[3].Value.ToString()); hh.MaHangHoa = int.Parse(dt.Rows[0][0].ToString()); ChiTietNhapDAO.Xoa(hh); LoadChiTiet(int.Parse(txtMaHD.Text.ToString())); HoaDonNhapDTO hd = new HoaDonNhapDTO(); hd.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); } catch { try { dgvchitiet.Rows.RemoveAt(e.RowIndex); } catch { } } } else { return; } }
public int ThemHoaDonNhap(HoaDonNhapDTO HoaDonNhapDTO) { string CauLenh = "INSERT INTO HoaDonNhap (MaHDN, MaNV, NgayNhap,TongTien,TrangThai) values ('{0}','{1}','{2}','{3}','1')"; SqlConnection conn = DataProvider_QLCHTapHoa.TaoKetNoi(); int kq = DataProvider_QLCHTapHoa.ThucThiCauLenh(String.Format(CauLenh, HoaDonNhapDTO.MaHDN, HoaDonNhapDTO.MaNV, HoaDonNhapDTO.NgayNhap, HoaDonNhapDTO.TongTien, HoaDonNhapDTO.TrangThai = 1), conn); return(kq); }
public static bool Xoa(HoaDonNhapDTO hd) { string sTruyVan = string.Format("delete tblHoaDonNhap where MaHDNhap={0}", hd.MaHDNhap); con = DataProvider.KetNoi(); DataProvider.ThucThiTruyVan(sTruyVan, con); DataProvider.DongKetNoi(con); return(true); }
public static bool sua(HoaDonNhapDTO hd) { string sTruyVan = string.Format("update tblHoaDonNhap set NgayNhap='{0}',MaNhaCC={1} where MaHDNhap={2}", hd.NgayNhap, hd.MaNhaCC, hd.MaHDNhap); con = DataProvider.KetNoi(); DataProvider.ThucThiTruyVan(sTruyVan, con); DataProvider.DongKetNoi(con); return(true); }
public static bool them(HoaDonNhapDTO hd) { string sTruyVan = string.Format("insert into tblHoaDonNhap values ({0},'{1}',{2},{3})", hd.MaHDNhap, hd.NgayNhap, hd.TongTien, hd.MaNhaCC); con = DataProvider.KetNoi(); DataProvider.ThucThiTruyVan(sTruyVan, con); DataProvider.DongKetNoi(con); return(true); }
public List <HoaDonNhapDTO> SEARCHHOADONNHAP(string str) { List <HoaDonNhapDTO> HDList = new List <HoaDonNhapDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("EXEC USP_SEARCHHOADONNHAP @str ", new object[] { str }); foreach (DataRow item in data.Rows) { HoaDonNhapDTO hd = new HoaDonNhapDTO(item); HDList.Add(hd); } return(HDList); }
public List <HoaDonNhapDTO> GETHOADONNHAP() { List <HoaDonNhapDTO> list = new List <HoaDonNhapDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("dbo.USP_GETHOADONNHAP "); foreach (DataRow item in data.Rows) { HoaDonNhapDTO hd = new HoaDonNhapDTO(item); list.Add(hd); } return(list); }
public IHttpActionResult GetHoaDonNhap(int id) { HoaDonNhap s = db.HoaDonNhaps.Find(id); if (s == null) { return(NotFound()); } // convert to DTO. HoaDonNhapDTO hdndto = new HoaDonNhapDTO { ChiNhanhID = s.ChiNhanh.ChiNhanhID, NgayNhap = s.NgayNhap, HoaDonNhapID = s.HoaDonNhapID, NguyenLieuID = s.NguyenLieu.NguyenLieuID, SoLuong = s.SoLuong, TongTienNhap = s.TongTienNhap }; return(Ok(hdndto)); }
public HoaDonNhapDTO LayHoaDonNhapTheoMa(string maHD) { HoaDonNhapDTO hoadonnhap = new HoaDonNhapDTO(); string caulenh = "SELECT MaHDN, nv.TenNV, NgayNhap, TongTien, hdn.TrangThai FROM HoaDonNhap hdn INNER JOIN NhanVien nv ON hdn.MaNV = nv.MaNV Where hdn.TrangThai = 1 AND hdn.MaHDN='" + maHD + "'"; SqlConnection conn = DataProvider_QLCHTapHoa.TaoKetNoi(); SqlDataReader dr = DataProvider_QLCHTapHoa.TruyVanDuLieu(caulenh, conn); while (dr.Read()) { hoadonnhap.MaHDN = dr[0].ToString(); hoadonnhap.MaNV = dr[1].ToString(); hoadonnhap.NgayNhap = Convert.ToDateTime(dr[2].ToString()); hoadonnhap.TongTien = int.Parse(dr[3].ToString()); hoadonnhap.TrangThai = int.Parse(dr[4].ToString()); } dr.Close(); conn.Close(); return(hoadonnhap); }
private void Xoa() { HoaDonNhapDTO hd = new HoaDonNhapDTO(); ChiTietNhapDTO ct = new ChiTietNhapDTO(); ct.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); hd.MaHDNhap = int.Parse(txtMaHD.Text.ToString()); for (int i = 0; i < dgvchitiet.RowCount; i++) { DataTable dt = HoaDonNhapDAO.TimHangHoa(dgvchitiet.Rows[i].Cells[2].Value.ToString()); try { ct.SoLuong = int.Parse(dgvchitiet.Rows[i].Cells[3].Value.ToString()); ct.MaHangHoa = int.Parse(dt.Rows[0][0].ToString()); ChiTietNhapDAO.Xoa(ct); } catch { } } HoaDonNhapDAO.Xoa(hd); }
private void frmHoaDonNhapHang_Load(object sender, EventArgs e) { ReportDocument rp = new ReportDocument(); rp.Load(@"C:\Users\Ron\Desktop\Tốt Nghiệp\CHTapHoa\CHTapHoa\Reports\HoaDonNhapHang.rpt"); List <HoaDonNhapDTO> dsHDN = new List <HoaDonNhapDTO>(); HoaDonNhapDTO hdn = _hdnbus.LayHDNhapTheoMa(MaHDN); dsHDN.Add(hdn); rp.SetDataSource(dsHDN); List <CTHDNhapDTO> dsSanPham = _cthdnbus.DanhSachChiTietHoaDonNhap(MaHDN); rp.Subreports[0].SetDataSource(dsSanPham); crystalReportViewer1.ReportSource = rp; this.crystalReportViewer1.Show(); this.crystalReportViewer1.Refresh(); }
public List <HoaDonNhapDTO> TimHoaDonNhap(DateTime tungay, DateTime denngay) { List <HoaDonNhapDTO> lsthoadonhap = new List <HoaDonNhapDTO>(); string caulenh = "SELECT * FROM HoaDonNhap Where TrangThai = 1 and NgayNhap >= convert (nvarchar,'" + tungay + "',103) and NgayNhap <= convert (nvarchar,'" + denngay + "',103)"; SqlConnection conn = DataProvider_QLCHTapHoa.TaoKetNoi(); SqlDataReader dr = DataProvider_QLCHTapHoa.TruyVanDuLieu(caulenh, conn); while (dr.Read()) { HoaDonNhapDTO hdndto = new HoaDonNhapDTO(); hdndto.MaHDN = dr[0].ToString(); hdndto.MaNV = dr[1].ToString(); hdndto.NgayNhap = Convert.ToDateTime(dr[2].ToString()); hdndto.TongTien = int.Parse(dr[3].ToString()); hdndto.TrangThai = int.Parse(dr[4].ToString()); lsthoadonhap.Add(hdndto); } dr.Close(); conn.Close(); return(lsthoadonhap); }
public List <HoaDonNhapDTO> DSHoaDonNhap() { List <HoaDonNhapDTO> lsthoadonhap = new List <HoaDonNhapDTO>(); string caulenh = "SELECT MaHDN, nv.TenNV, NgayNhap, TongTien, hdn.TrangThai FROM HoaDonNhap hdn INNER JOIN NhanVien nv ON hdn.MaNV = nv.MaNV Where hdn.TrangThai = 1"; SqlConnection conn = DataProvider_QLCHTapHoa.TaoKetNoi(); SqlDataReader dr = DataProvider_QLCHTapHoa.TruyVanDuLieu(caulenh, conn); while (dr.Read()) { HoaDonNhapDTO hdndto = new HoaDonNhapDTO(); hdndto.MaHDN = dr[0].ToString(); hdndto.MaNV = dr[1].ToString(); hdndto.NgayNhap = Convert.ToDateTime(dr[2].ToString()); hdndto.TongTien = int.Parse(dr[3].ToString()); hdndto.TrangThai = int.Parse(dr[4].ToString()); lsthoadonhap.Add(hdndto); } dr.Close(); conn.Close(); return(lsthoadonhap); }
public int ThemHoaDonNhap(HoaDonNhapDTO HoaDonNhapDTO) { return(hoadonhapdao.ThemHoaDonNhap(HoaDonNhapDTO)); }
private void btnLapHD_Click(object sender, EventArgs e) { GetDuLieu(); if (gridView2.RowCount > 0 || gridView2.RowCount != 0) { try { double tien = 0; foreach (CTHDNhapDTO ct in lstchitiet) { tien += ct.GiaNhap * ct.SoLuong; } HoaDonNhapDTO hdb = new HoaDonNhapDTO(); frmSanPham sp = new frmSanPham(); Form1 frm = (Form1)this.MdiParent; hdb.MaHDN = hdnbus.TangHD(); hdb.MaNV = frm.NhanVienDN.MaNV; hdb.NgayNhap = System.DateTime.Now; hdb.TongTien = tien; int mhd = hdnbus.ThemHoaDonNhap(hdb); CTHDNhapBUS ctbus = new CTHDNhapBUS(); int kq = 0; foreach (CTHDNhapDTO ct in lstchitiet) { ct.MaCTHoaDonNhap = hdb.MaHDN; if (ctbus.ThemCTHoaDonNhap(ct)) { kq++; } if (sanphambus.TimSP(ct.MaSP)) { SanPhamDTO hh = new SanPhamDTO(); hh.MaSP = ct.MaSP; hh.SoLuong = ct.SoLuong; sanphambus.CongSL(hh); } } if (kq == lstchitiet.Count) { XtraMessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK); frmHoaDonNhapHang frm1 = new frmHoaDonNhapHang(); frm1.MaHDN = txtMHD.Text; frm1.ShowDialog(); } else { XtraMessageBox.Show("Thanh toán thất bại", "Thông báo"); } } catch (Exception) { XtraMessageBox.Show("Bạn chưa nhập hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } gctSanPham.DataSource = sanphambus.DanhSachSanPham(); for (int i = 0; i < gridView2.RowCount;) { gridView2.DeleteRow(i); } } else { XtraMessageBox.Show("Bạn chưa chọn hàng cần nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } lblThanhTien.Text = ""; lblTT.Text = ""; txtSL.Text = ""; TangHD(); }