public DTOChiTietPhieuGiao(DataRow dong) { dtoPhieuGiao = new DTOPhieuGiao(dong); dtoVatLieu = new DTOVatLieu(dong); SoluongGiao = (int)dong["SoLuongGiao"]; }
public bool ThemPhieuGiao(DTOPhieuGiao dtoPhieuGiao) { bool ketqua = false; ketnoi.TaoKetNoi(); try { string lenh = "insert into PhieuGiao(MaPG, NgayGiao, NguoiGiao) values(@maPhieuGiao, @ngaygiao, @nguoigiao)"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.LenhKetNoi.Parameters.Add("@maPhieuGiao", SqlDbType.VarChar); ketnoi.LenhKetNoi.Parameters.Add("@ngaygiao", SqlDbType.DateTime); ketnoi.LenhKetNoi.Parameters.Add("@nguoigiao", SqlDbType.VarChar); ketnoi.LenhKetNoi.Parameters["@maPhieuGiao"].Value = dtoPhieuGiao.MaPhieuGiao; ketnoi.LenhKetNoi.Parameters["@ngaygiao"].Value = dtoPhieuGiao.NgayGiao; ketnoi.LenhKetNoi.Parameters["@nguoigiao"].Value = dtoPhieuGiao.NguoiGiao; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) ketqua = true; } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return ketqua; }
public DTOChiTietPhieuGiao(DataRow dong) { dtoPhieuGiao = new DTOPhieuGiao(dong); dtoVatLieu = new DTOVatLieu(dong); SoluongGiao = (int)dong["SoLuongGiao"]; }
protected void btnLuu_Click(object sender, EventArgs e) { try { string maPhieuDat = Request.QueryString["maPhieu"].ToString(); DTOPhieuNVL_SX dtoPhieuNhap = new DTOPhieuNVL_SX(); string maPhieuNhap = DateTime.Now.ToString("yyyyMMddHHmmss"); dtoPhieuNhap.dtoPhieuDat = new DTOPhieuDatVatLieuCC(); dtoPhieuNhap.MaPNVLSX = maPhieuNhap; dtoPhieuNhap.dtoPhieuDat.MaPDVLCC = maPhieuDat; dtoPhieuNhap.ngaylap = DateTime.Now.ToShortDateString(); dtoPhieuNhap.NguoiGiao = txtNguoiGiao.Text; dtoPhieuNhap.NgayGiao = txtNgayGiao.Text; dtoPhieuNhap.MaNV = int.Parse(txtMaNV.Text); int dem = 0; if (daoEntities.ThemPhieuNhap(dtoPhieuNhap)) { foreach (GridViewRow dong in gridDSVatLieu.Rows) { TextBox txtSLThuc = (TextBox)dong.FindControl("txtSLThuc"); TextBox txtSLGiao = (TextBox)dong.FindControl("txtSoluongGiao"); Label lbMaVL = (Label)dong.FindControl("lbMaVL"); int soluongThuc = 0, soluongGiao = 0; int.TryParse(txtSLThuc.Text, out soluongThuc); int.TryParse(txtSLGiao.Text, out soluongGiao); DTOChiTietPhieuNhapVL dtoChiTietPhieuNhapVL = new DTOChiTietPhieuNhapVL(); dtoChiTietPhieuNhapVL.dtoPhieuNhapVL = new DTOPhieuNVL_SX(); dtoChiTietPhieuNhapVL.dtoPhieuNhapVL.MaPNVLSX = maPhieuNhap; dtoChiTietPhieuNhapVL.dtoVatLieu = new DTOVatLieu(); dtoChiTietPhieuNhapVL.dtoVatLieu.MaVL = int.Parse(lbMaVL.Text); dtoChiTietPhieuNhapVL.SoLuongThuc = soluongThuc; dtoChiTietPhieuNhapVL.SoLuongGiao = soluongGiao; if (daoEntities.ThemCTPhieuNhap(dtoChiTietPhieuNhapVL)) dem++; //cập nhật trạng thái phiếu đặt daoEntities.capNhatTrangThaiPhieuDat(maPhieuDat, 2); //xử lý sự cố if (soluongThuc < soluongGiao) { int soLuongKhongDat = soluongGiao - soluongThuc; Label lbKhongDat = (Label)dong.FindControl("lbKhongDat"); if (daoEntities.ThemXuLySuCo(maPhieuNhap, int.Parse(lbMaVL.Text), soLuongKhongDat)) lbKhongDat.Text = soLuongKhongDat.ToString(); } } } if (dem == gridDSVatLieu.Rows.Count) { DTOPhieuGiao dtoPhieuGiao = new DTOPhieuGiao(); dtoPhieuGiao.MaPhieuGiao = maPhieuNhap; dtoPhieuGiao.NgayGiao = txtNgayGiao.Text; dtoPhieuGiao.NguoiGiao = txtNguoiGiao.Text; if (daoEntities.ThemPhieuGiao(dtoPhieuGiao)) { foreach (GridViewRow dong in gridDSVatLieu.Rows) { TextBox txtSLThuc = (TextBox)dong.FindControl("txtSLThuc"); TextBox txtSLGiao = (TextBox)dong.FindControl("txtSoluongGiao"); Label lbMaVL = (Label)dong.FindControl("lbMaVL"); int soluongThuc = 0, soluongGiao = 0; int.TryParse(txtSLThuc.Text, out soluongThuc); int.TryParse(txtSLGiao.Text, out soluongGiao); DTOChiTietPhieuGiao dtoChiTietPhieuGiao = new DTOChiTietPhieuGiao(); dtoChiTietPhieuGiao.dtoPhieuGiao = new DTOPhieuGiao(); dtoChiTietPhieuGiao.dtoVatLieu = new DTOVatLieu(); dtoChiTietPhieuGiao.dtoVatLieu.MaVL = int.Parse(lbMaVL.Text); dtoChiTietPhieuGiao.dtoPhieuGiao.MaPhieuGiao = maPhieuNhap; dtoChiTietPhieuGiao.SoluongGiao = soluongGiao; daoEntities.ThemCTPhieuGiao(dtoChiTietPhieuGiao); } } } } catch (Exception) { throw; } }