我正在创建一个类的实例,但是获取对象引用没有设置错误。我的代码如下:
Dim objFloatEnquiryDL As New FloatEnquiryDL
Dim QuotID As Integer = objFloatEnquiryDL.InsertUpdateQuotationHeader(txtQuotationNo.Text, txtFromDate.Text, 53, txtToDate.Text, txtPaymentCondition.Text, txtDeliverySchedule.Text, txtTransport.Text, Session("username").ToString(), "comp", hdLibNo.Value, hdEnqID.Value)
Dim lblUnitTechnical As New Label
Dim lblQuantity As New Label
Dim lblMaterialID As New Label
Dim txtRate As New TextBox
Dim txtCredit As New TextBox
Dim txtDiscount As New TextBox
Dim txtRemark As New TextBox
Dim txtConvFact As New TextBox
Dim ddlTaxScheme As New DropDownList
Dim lblTotalTax As New TextBox
Dim ddlBrand As New DropDownList
Dim ddlCompUnit As New DropDownList
Dim ddlTcurr As New DropDownList
Dim txtTCRate As New TextBox
Dim lblEnquiryDetailId As New Label
Dim brandID As Integer = 0
Dim ComUnit As Integer = 0
Dim taxID As Integer = 0
For Each row As GridViewRow In gvQuotation.Rows
ddlCompUnit = TryCast(row.FindControl("ddlCompUnit"), DropDownList)
lblUnitTechnical = TryCast(row.FindControl("lblUnitTechnical"), Label)
lblQuantity = TryCast(row.FindControl("lblQuantity"), Label)
lblMaterialID = TryCast(row.FindControl("lblMaterialID"), Label)
txtRate = TryCast(row.FindControl("txtRate"), TextBox)
txtCredit = TryCast(row.FindControl("txtCredit"), TextBox)
txtDiscount = TryCast(row.FindControl("txtDiscount"), TextBox)
txtRemark = TryCast(row.FindControl("txtRemark"), TextBox)
txtConvFact = TryCast(row.FindControl("txtConvFact"), TextBox)
ddlTaxScheme = TryCast(row.FindControl("ddlTaxScheme"), DropDownList)
lblTotalTax = TryCast(row.FindControl("lblTotalTax"), TextBox)
ddlBrand = TryCast(row.FindControl("ddlBrand"), DropDownList)
'get username
ddlTcurr = TryCast(row.FindControl("ddlTcurr"), DropDownList)
txtTCRate = TryCast(row.FindControl("txtTCRate"), TextBox)
lblEnquiryDetailId = TryCast(row.FindControl("lblEnquiryDetailId"), Label)
If (ddlBrand.SelectedIndex <> 0) Then
brandID = ddlBrand.SelectedValue
End If
If (ddlCompUnit.SelectedIndex <> 0) Then
ComUnit = ddlCompUnit.SelectedValue
End If
If (ddlTaxScheme.SelectedIndex <> 0) Then
taxID = ddlTaxScheme.SelectedValue
End If
Dim obj As New FloatEnquiryDL
obj.InsertUpdateQuotationDetail(QuotID, System.Convert.ToInt32(lblMaterialID.Text), Val(lblQuantity.Text), System.Convert.ToInt32(lblUnitTechnical.Text), Val(txtRate.Text), System.Convert.ToInt32(txtCredit.Text), Val(txtDiscount.Text), txtRemark.Text, Val(txtConvFact.Text), ComUnit, taxID, Val(lblTotalTax.Text), brandID, "admin", System.Convert.ToInt32(ddlTcurr.SelectedValue), Val(txtTCRate.Text), Val(txtConvFact.Text), System.Convert.ToInt32(lblEnquiryDetailId.Text))
Next
基本上我使用存储过程在表中插入值。第一步给我主表ID,工作正常。在第二步中,我正在迭代throw gridview并在第二个表中插入值。
正在调用的类的函数/方法如下:
Public Function InsertUpdateQuotationDetail(ByVal Quotation_Id As Integer, ByVal Material_Id As Integer, ByVal Qty As Decimal, ByVal Unit_Id As Integer, ByVal Rate As Decimal, ByVal Credit As Integer, ByVal Discount As Decimal, ByVal Remark As String, ByVal Conv_Factor As Decimal, ByVal Unit_Comm As Integer, ByVal TaxScheme_Id As Integer, ByVal Tax_Amount As Decimal, ByVal Band_Id As Integer, ByVal User_Name As String, ByVal Currency_ID As Integer, ByVal Currency_rate As Decimal, ByVal Currency_ConvFact As Decimal, ByVal Enquiry_DetailID As Integer) As Integer
Dim objSQLHelper As New SqlHelper
Dim SPName As String = "Sp_Quot_Detail_InsertUpdate"
Dim params As New Dictionary(Of String, Object)
params.Add("@Quotation_Id", Quotation_Id) 'get previous inserted quotation id
params.Add("@Material_Id", Material_Id)
params.Add("@Qty", Qty)
params.Add("@Unit_Id", Unit_Id)
params.Add("@Rate", Rate)
params.Add("@Credit", Credit)
params.Add("@Discount", Discount)
params.Add("@Remark", Remark)
params.Add("@QuotationDetail_Id", 0) ' always 0
params.Add("@Detail_Status", 1)
params.Add("@Conv_Factor", Conv_Factor)
params.Add("@Unit_Comm", Unit_Comm)
params.Add("@TaxScheme_Id", TaxScheme_Id)
params.Add("@Tax_Amount", Tax_Amount)
params.Add("@Band_Id", Band_Id)
params.Add("@User_Name", User_Name)
params.Add("@Currency_ID", Currency_ID)
params.Add("@Currency_rate", Currency_rate)
params.Add("@Currency_ConvFact", Currency_ConvFact)
params.Add("@Enquiry_DetailID", Enquiry_DetailID)
Return objSQLHelper.ExecuteStoredProcedure(SPName, params, Nothing)
End Function
但是,它没有调用此函数,错误在同一行上出现,即
obj.InsertUpdateQuotationDetail(QuotID, System.Convert.ToInt32(lblMaterialID.Text), Val(lblQuantity.Text), System.Convert.ToInt32(lblUnitTechnical.Text), Val(txtRate.Text), System.Convert.ToInt32(txtCredit.Text), Val(txtDiscount.Text), txtRemark.Text, Val(txtConvFact.Text), ComUnit, taxID, Val(lblTotalTax.Text), brandID, "admin", System.Convert.ToInt32(ddlTcurr.SelectedValue), Val(txtTCRate.Text), Val(txtConvFact.Text), System.Convert.ToInt32(lblEnquiryDetailId.Text))
重要的一点是,我正在研究TFS,由于其他程序员代码页面中的错误,我无法构建解决方案。 InsertUpdateQuotationDetail 被放置在该数据层类中,但是因为我将它放在那里,所以甚至没有单一的成功构建。这可能是原因
在逐个检查每个参数后,错误出现在下面的代码中:
txtRate = TryCast(row.FindControl("txtRate"), TextBox)
Rate = CDec(txtRate.Text)
其aspx标记如下:
<asp:TextBox ID="txtRate" Text="0" runat="server" CssClass="Input70" AutoPostBack="true"
OnTextChanged="txtRate_TextChanged"></asp:TextBox>
现在为什么它无法获取其值,因为其余控件正常运行
我的控件出现问题,现在很好