public DTOChiTietPhieuNhapVL(DataRow dong)
 {
     dtoPhieuNhapVL = new DTOPhieuNVL_SX(dong);
     dtoVatLieu     = new DTOVatLieu(dong);
     SoLuongThuc    = (int)dong["Soluongthuc"];
     SoLuongGiao    = (int)dong["Soluonggiao"];
 }
예제 #2
0
 public DTOChiTietPhieuDatNCC(DataRow dong)
 {
     PhieuDat   = new DTOPhieuDatVatLieuCC(dong);
     dtoVatLieu = new DTOVatLieu(dong);
     SoLuong    = (int)dong["SoLuong"];
     ThanhTien  = (decimal)dong["Thanhtien"];
 }
 public DTOChiTietPhieuDatNCC(DataRow dong)
 {
     PhieuDat = new DTOPhieuDatVatLieuCC(dong);
     dtoVatLieu = new DTOVatLieu(dong);
     SoLuong = (int)dong["SoLuong"];
     ThanhTien = (decimal)dong["Thanhtien"];
 }
 public DTOChiTietPhieuNhapVL(DataRow dong)
 {
     dtoPhieuNhapVL = new DTOPhieuNVL_SX(dong);
     dtoVatLieu = new DTOVatLieu(dong);
     SoLuongThuc = (int)dong["Soluongthuc"];
     SoLuongGiao = (int)dong["Soluonggiao"];
 }
 public DTOChiTietPhieuGiao(DataRow dong)
 {
     dtoPhieuGiao = new DTOPhieuGiao(dong);
     dtoVatLieu = new DTOVatLieu(dong);
     SoluongGiao = (int)dong["SoLuongGiao"];
 }
 public DTOChiTietPhieuGiao(DataRow dong)
 {
     dtoPhieuGiao = new DTOPhieuGiao(dong);
     dtoVatLieu   = new DTOVatLieu(dong);
     SoluongGiao  = (int)dong["SoLuongGiao"];
 }
        public DTOVatLieu LayThongTinVatLieu(string maSua)
        {
            ketnoi.TaoKetNoi();
            DTOVatLieu dtoVL = null;
            try
            {
                string lenh = "select * from VatLieu,NhaCungCap  where MaVL = @maSua and VatLieu.MaNCC = NhaCungCap.MaNCC ";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

                ketnoi.LenhKetNoi.Parameters.Add("@maSua", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters["@maSua"].Value = maSua;

                DataTable bang = new DataTable();
                ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi);
                ketnoi.TichHopCSDL.Fill(bang);
                DataRow dong = bang.Rows[0];
                dtoVL = new DTOVatLieu(dong);

            }
            catch (Exception)
            { }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return dtoVL;
        }
        public bool XoaVatLieu(DTOVatLieu dtoVL)
        {
            bool kq = false;
            ketnoi.TaoKetNoi();
            try
            {
                string lenh = "delete from VatLieu where MaVL = @mavl";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

                ketnoi.LenhKetNoi.Parameters.Add("@mavl", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters["@mavl"].Value = dtoVL.MaVL;

                if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0)
                {
                    kq = true;
                }
            }
            catch (Exception)
            {

            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return kq;
        }
        public bool capnhatdanhsach(DTOVatLieu dtoVL)
        {
            bool kq = false;
            ketnoi.TaoKetNoi();
            try
            {
                string lenh = "update VatLieu set TenVL = @tenvl , MaNCC = @mancc , Donvi = @donvi ,Gia = @gia where MaVL = @maVL";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

                ketnoi.LenhKetNoi.Parameters.Add("@maVL", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters.Add("@tenvl", SqlDbType.NVarChar);
                ketnoi.LenhKetNoi.Parameters.Add("@mancc", SqlDbType.Int);//mancc
                ketnoi.LenhKetNoi.Parameters.Add("@donvi", SqlDbType.NVarChar);
                ketnoi.LenhKetNoi.Parameters.Add("@gia", SqlDbType.Decimal);
                ketnoi.LenhKetNoi.Parameters.Add("@sl", SqlDbType.Int);

                ketnoi.LenhKetNoi.Parameters["@maVL"].Value = dtoVL.MaVL;
                ketnoi.LenhKetNoi.Parameters["@tenvl"].Value = dtoVL.TenVL;
                ketnoi.LenhKetNoi.Parameters["@mancc"].Value = dtoVL.dtoNCC.MaNCC;
                ketnoi.LenhKetNoi.Parameters["@donvi"].Value = dtoVL.Donvi;
                ketnoi.LenhKetNoi.Parameters["@gia"].Value = dtoVL.Gia;
                ketnoi.LenhKetNoi.Parameters["@sl"].Value = dtoVL.Soluong;

                if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0)
                {
                    kq = true;
                }
            }
            catch (Exception)
            { }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return kq;

        }
        //ThemVL
        public bool ThemVatLieu(DTOVatLieu dtoVL)
        {
            bool kq = false;
            ketnoi.TaoKetNoi();
            try
            {
                string lenh = " insert into VatLieu (TenVL ,MaNCC ,Donvi ,Gia, SoLuong) values (@tenvl ,@mancc ,@donvi ,@gia, @sl)";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

                //ketnoi.LenhKetNoi.Parameters.Add("@maVL", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters.Add("@tenvl", SqlDbType.NVarChar);
                ketnoi.LenhKetNoi.Parameters.Add("@mancc", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters.Add("@donvi", SqlDbType.NVarChar);
                ketnoi.LenhKetNoi.Parameters.Add("@gia", SqlDbType.Decimal);
                ketnoi.LenhKetNoi.Parameters.Add("@sl", SqlDbType.Int);

                //ketnoi.LenhKetNoi.Parameters["@maVL"].Value = dtoVL.MaVL;
                ketnoi.LenhKetNoi.Parameters["@tenvl"].Value = dtoVL.TenVL;
                ketnoi.LenhKetNoi.Parameters["@mancc"].Value = dtoVL.dtoNCC.MaNCC;
                ketnoi.LenhKetNoi.Parameters["@donvi"].Value = dtoVL.Donvi;
                ketnoi.LenhKetNoi.Parameters["@gia"].Value = dtoVL.Gia;
                ketnoi.LenhKetNoi.Parameters["@sl"].Value = dtoVL.Soluong;

                if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0)
                {
                    kq = true;

                }

            }
            catch (Exception)
            {

            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return kq;
        }
        // Tao danh sach Vat Lieu
        public List<DTOVatLieu> TaoDSVL()
        {
            List<DTOVatLieu> ds = new List<DTOVatLieu>();
            string lenh = "select * from VatLieu VL ,NhaCungCap NCC where VL.MaNCC = NCC.MaNCC";
            ketnoi.TaoKetNoi();
            DataTable bang = new DataTable();
            try
            {
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);
                ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi);
                ketnoi.TichHopCSDL.Fill(bang);
                foreach (DataRow dongDL in bang.Rows)
                {
                    DTOVatLieu dtovl = new DTOVatLieu(dongDL);
                    ds.Add(dtovl);
                }

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return ds;

        }