private void dongGoiChiTietHangNhapDTO(ThongTinHangNhapDTO dto) { for (int i = 0; i < grid_chiTietPhieuDat.RowCount; i++) { ChiTietHangNhapDTO chiTiet = new ChiTietHangNhapDTO(); chiTiet.NhaCungCap = (NhaCungCapDTO)grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cNCC"].Value; chiTiet.NguyenLieu = (NguyenLieuDTO)grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cNguyenLieu"].Value; chiTiet.SoLuong = Convert.ToDecimal(grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cLuongDat"].Value); dto.ChiTietHangNhap.Add(chiTiet); } }
public static int themChiTietHangNhap(ChiTietHangNhapDTO chiTiet) { DbCommand command = DataAccessCode.CreateCommand(); //// create a new parameter DbParameter param = command.CreateParameter(); command.CommandText = "dbo.themChiTietHangNhap"; param.ParameterName = "@maNguyenLieu"; param.Value = chiTiet.NguyenLieu.MaNguyenLieu; param.DbType = DbType.Int32; command.Parameters.Add(param); //// create a new parameter param = command.CreateParameter(); param.ParameterName = "@maNhaCungCap"; param.Value = chiTiet.NhaCungCap.MaNhaCungCap; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@donGia"; param.Value = chiTiet.DonGia; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@soLuong"; param.Value = chiTiet.SoLuong; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@maThongTinHangNhap"; param.Value = chiTiet.MaThongTinHangNhap; param.DbType = DbType.Int32; command.Parameters.Add(param); return(DataAccessCode.ExecuteNonQuery(command)); }