Esempio n. 1
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 DTOPhieuNVL_SX(DataRow dongDL)
 {
     MaPNVLSX    = dongDL["MaPNVLSX"].ToString();
     dtoPhieuDat = new DTOPhieuDatVatLieuCC(dongDL);
     ngaylap     = dongDL["Ngaylap"].ToString();
     NgayGiao    = dongDL["Ngaygiao"].ToString();
     NguoiGiao   = dongDL["NguoiGiao"].ToString();
     MaNV        = (int)dongDL["MaNV"];
 }
 public DTOPhieuNVL_SX(DataRow dongDL)
 {
     MaPNVLSX = dongDL["MaPNVLSX"].ToString();
     dtoPhieuDat = new DTOPhieuDatVatLieuCC(dongDL);
     ngaylap = dongDL["Ngaylap"].ToString();
     NgayGiao = dongDL["Ngaygiao"].ToString();
     NguoiGiao = dongDL["NguoiGiao"].ToString();
     MaNV = (int)dongDL["MaNV"];
 }
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            
            DTOCongNoVatLieu dtovl = new DTOCongNoVatLieu();
            dtovl.MaPDVLCC = int.Parse(lbMPD.Text);
            dtovl.MaNCC = int.Parse(lbNCC.Text);
            dtovl.MaNV = int.Parse(TextBox1.Text);
            dtovl.NgayTraNo = Convert.ToDateTime(lbNTT.Text);
            dtovl.Sotien = int.Parse(TextBox2.Text);

            DAO_Entity dao = new DAO_Entity();
            dao.ThemCongNoNCC(dtovl);


            DTOPhieuDatVatLieuCC dtopd = new DTOPhieuDatVatLieuCC();
            dtopd.MaPDVLCC = lbMPD.Text;
            int tong = int.Parse(lbTong.Text);
            int no = int.Parse(TextBox2.Text);
            dtopd.CongNoNCC = tong - no;
            dao.CapNhatCongNoNCC(dtopd);

            Response.Redirect("~/QLBoPhan_VatLieu/QLCongNoNCC/DanhSachCongNo.aspx");
        }
        // DAOPhieuNhapVatLieu_NCC

        //Tao danh sach san pham
        public List<DTOPhieuDatVatLieuCC> LayDSPhieuDatVatLieu_NCC()
        {
            List<DTOPhieuDatVatLieuCC> dssp = new List<DTOPhieuDatVatLieuCC>();
            string lenh = "select * from PDVL_CC pd, Nhacungcap ncc where pd.mancc = ncc.mancc and pd.TrangThai = 1";
            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)
                {
                    DTOPhieuDatVatLieuCC dtosp = new DTOPhieuDatVatLieuCC(dongDL);
                    dssp.Add(dtosp);

                }
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return dssp;
        }
        public bool CapNhatCongNoNCC(DTOPhieuDatVatLieuCC dtoPD)
        {
            bool ketqua = false;
            ketnoi.TaoKetNoi();
            try
            {
                string lenh = "update PDVL_CC set CongNoNCC = @cc where MaPDVLCC=@ma";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

                ketnoi.LenhKetNoi.Parameters.Add("@ma", SqlDbType.Int);
                ketnoi.LenhKetNoi.Parameters.Add("@cc", SqlDbType.Int);

                ketnoi.LenhKetNoi.Parameters["@ma"].Value = dtoPD.MaPDVLCC;
                ketnoi.LenhKetNoi.Parameters["@cc"].Value = dtoPD.CongNoNCC;

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

            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return ketqua;
        }
        public DTOPhieuDatVatLieuCC LayTTPhieuDatTheoMa(string ma)
        {
            ketnoi.TaoKetNoi();
            DTOPhieuDatVatLieuCC dtoDH = null;
            try
            {
                string lenh = "Select * from PDVL_CC pd, NhaCungCap ncc where ncc.MaNCC=pd.MaNCC and pd.MaPDVLCC = @ma ";
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);

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

                DataTable bang = new DataTable();
                ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi);
                ketnoi.TichHopCSDL.Fill(bang);
                DataRow dong = bang.Rows[0];
                dtoDH = new DTOPhieuDatVatLieuCC(dong);
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return dtoDH;
        }
    //   DAOCongNoNCC

        public List<DTOPhieuDatVatLieuCC> LayDSCongNoNCC()
        {
            List<DTOPhieuDatVatLieuCC> ds = new List<DTOPhieuDatVatLieuCC>();

            string lenh = "Select * from PDVL_CC vl, NhaCungCap ncc where vl.MaNCC=ncc.MaNCC and vl.CongNoNCC>0";

            ketnoi.TaoKetNoi();
            DataTable bang = new DataTable();
            try
            {
                ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi);
                //dong bo lenh ket noi voi du lieu trong database
                ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi);
                ketnoi.TichHopCSDL.Fill(bang);
                foreach (DataRow dongDL in bang.Rows)
                {
                    DTOPhieuDatVatLieuCC dtoct = new DTOPhieuDatVatLieuCC(dongDL);
                    ds.Add(dtoct);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                ketnoi.DongKetNoi();
            }
            return ds;
        }