コード例 #1
0
ファイル: frmNhapKho.cs プロジェクト: Org-1124/QuanLyKho
        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);
            }
        }
コード例 #2
0
ファイル: frmNhapKho.cs プロジェクト: Org-1124/QuanLyKho
 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;
     }
 }
コード例 #3
0
ファイル: HoaDonNhapDAO.cs プロジェクト: DangTri/CHTapHoa
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
ファイル: HoaDonNhapDAO.cs プロジェクト: DangTri/CHTapHoa
        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);
        }
コード例 #11
0
ファイル: frmNhapKho.cs プロジェクト: Org-1124/QuanLyKho
        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);
        }
コード例 #12
0
ファイル: frmHoaDonNhapHang.cs プロジェクト: DangTri/CHTapHoa
        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();
        }
コード例 #13
0
ファイル: HoaDonNhapDAO.cs プロジェクト: DangTri/CHTapHoa
        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);
        }
コード例 #14
0
ファイル: HoaDonNhapDAO.cs プロジェクト: DangTri/CHTapHoa
        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);
        }
コード例 #15
0
ファイル: HoaDonNhapBUS.cs プロジェクト: DangTri/CHTapHoa
 public int ThemHoaDonNhap(HoaDonNhapDTO HoaDonNhapDTO)
 {
     return(hoadonhapdao.ThemHoaDonNhap(HoaDonNhapDTO));
 }
コード例 #16
0
ファイル: frmNhapHang.cs プロジェクト: DangTri/CHTapHoa
        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();
        }