protected void BtnCreateExchange_Click(object sender, EventArgs e) { StringBuilder lineBuild = new StringBuilder(); string lineError = ""; try { rmaNo = tcRMANo.Text; docNo = tcDocNo.Text; string validateMsg = string.Empty; bool allValidLines = true; int rowCount = 0; int controlCount = 0; if (!String.IsNullOrWhiteSpace(txtZendeskTicketNo.Text) || !String.IsNullOrEmpty(txtZendeskTicketNo.Text)) { if (txtZendeskTicketNo.Text.Length == 7) { int.TryParse(txtZendeskTicketNo.Text, out zendeskTicketNo); } else { validateMsg = "Zendesk Ticket # should be 7 numeric characters."; } } if (validateMsg == string.Empty) { foreach (TableRow row in tblCreateReturnOrderTableDetails.Rows) { rowCount++; string itemNo = string.Empty; int qtyReceivedLine = 0; int actionQty = 0; controlCount = 0; foreach (TableCell cell in row.Cells) { if (cell.ID.Contains("itemNo")) { itemNo = cell.Text.ToString(); } if (cell.ID.Contains("qtyReceived_")) { int.TryParse(cell.Text.ToString(), out qtyReceivedLine); } foreach (Control c in cell.Controls) { controlCount++; if (c.GetType() == typeof(TextBox)) { string value = ((TextBox)c).Text; int.TryParse(value, out actionQty); } } string lineValidMessage = string.Empty; if ((rowCount > 1 && controlCount == 1)) { lineValidMessage = ValidateLine(itemNo, qtyReceivedLine, actionQty); if (lineValidMessage == "Valid Line Input") { lineBuild.Append(itemNo).Append(":"); lineBuild.Append(actionQty).Append(","); } else { allValidLines = false; if (lineError == "") { lineError = lineValidMessage; } } } } } if (allValidLines) { string lineValues = lineBuild.ToString(); CreatedExchangeHeader ceh = new CreatedExchangeHeader(); SendService ss = new SendService(); ceh = ss.CreateExchangeOrder(rmaNo, docNo, lineValues, zendeskTicketNo); Session["CreatedExchange"] = ceh; Session["NoUserInteraction"] = true; ClientScript.RegisterStartupScript(this.GetType(), "returnOrderNo", "alert('" + ceh.OrderNo + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "openCreatedExchange", "OpenCreateExchange();", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "lineError", "alert('" + lineError + "');", true); } } else { ClientScript.RegisterStartupScript(this.GetType(), "validateMsg", "alert('" + validateMsg + "');", true); } } catch (Exception ex) { Log.Error(ex.Message, ex); ClientScript.RegisterStartupScript(this.GetType(), "errorAlert", "alert('" + ex.Message.Replace("'", "\"") + "');", true); if (ex.Message.ToLower().Contains("session")) { ClientScript.RegisterStartupScript(this.GetType(), "closeErrorAlert", "parent.window.close();", true); } } }