private void btnsubmit_Click(object sender, System.EventArgs e) { int i = 0; string sErrMsg = ""; bool isRecSaved = false, isSelected = true; Category = Request.QueryString["InvoiceType"]; if (Category == "INV") { for (i = 0; i <= grdInvCur.Items.Count - 1; i++) { InvoiceDetailID = Convert.ToInt32(((Label)grdInvCur.Items[i].FindControl("lblInvDtlId")).Text.Trim()); OrderNo = ((Label)grdInvCur.Items[i].FindControl("lblOrderNo")).Text; if (OrderNo != "") { if (((DropDownList)grdInvCur.Items[i].FindControl("ddlProdCode")).SelectedIndex > 0) { ProductCode = ((DropDownList)grdInvCur.Items[i].FindControl("ddlProdCode")).SelectedItem.Text; } else { isSelected = false; break; } if (((DropDownList)grdInvCur.Items[i].FindControl("ddlColor")).SelectedIndex > 0) { Colour = ((DropDownList)grdInvCur.Items[i].FindControl("ddlColor")).SelectedItem.Text; } else { isSelected = false; break; } } int iInvoiceID = Convert.ToInt32(Session["oInvoiceID"].ToString()); string strInvoiceNo = Session["oInvoiceNo"].ToString(); sErrMsg = objinvoice.GetUpdate(iInvoiceID, InvoiceDetailID, OrderNo, strInvoiceNo, ProductCode, lblinvoicetype.Text.Trim().ToString(), Colour, Convert.ToInt32(lblAPCompanyID.Text)); if (sErrMsg.Trim() == "") { isRecSaved = true; } else { isRecSaved = false; } } } else if (Category == "CRN") { for (i = 0; i <= grdInvCur.Items.Count - 1; i++) { int CreditNoteID = Convert.ToInt32(Session["oInvoiceID"].ToString()); string CreditNoteNo = Session["oInvoiceNo"].ToString(); OrderNo = ((Label)grdInvCur.Items[i].FindControl("lblOrderNo")).Text; ProductCode = ((DropDownList)grdInvCur.Items[i].FindControl("ddlProdCode")).SelectedItem.Text; Colour = ((DropDownList)grdInvCur.Items[i].FindControl("ddlColor")).SelectedItem.Text; if (objinvoice.GetCreditNoteUpdate(CreditNoteID, OrderNo, CreditNoteNo, ProductCode, lblinvoicetype.Text.Trim().ToString(), Colour, Convert.ToInt32(lblAPCompanyID.Text))) { isRecSaved = true; } else { isRecSaved = false; } } } if (isRecSaved) { if (isSelected) { lblMessege.Text = " Record saved successfully"; lblMessege.Visible = true; Response.Write("<script>alert('Invoice submitted successfully');</script>"); Response.Write("<script>opener.location.reload(true);</script>"); Response.Write("<script>self.close();</script>"); } else { lblMessege.Text = "Please select dropdowns to save successfully."; lblMessege.Visible = true; } } else { lblMessege.Text = " Record not saved successfully"; lblMessege.Visible = true; } }