Link to home
Start Free TrialLog in
Avatar of mrissi
mrissi

asked on

C# Question

Ok - I have created an app which can do data entry and do look ups based on imput variables for order number. I now want to add this same functionality for a serial number. I have started to do this and I am getting all kinds of errors. I need help.

Where do I need to make changes to the attached forms to allow for my serial number entry which I have started to add.

This is off Huge importance and will problably require us going back and forth a few times ...

Attached please find my menu.aspx file as well as my menua.html and NewData.aspx (which is my main file)

Any and all help will be GREATLY APPRECIATED!!!



Menu1a.htm
<script language="JavaScript">
Menu1LastSelected = 'Menu11';
Menu2LastSelected = 'Menu21l1';
function JsFnMenu1Clicked (sClickedId,sURL)
{

      var sMenu1 = "Menu1"+sClickedId.substring(5,6);
      var sMenu2LastType = Menu2LastSelected.substring(6,7) == 'r' ? 'right' : 'left' ;
      var  sLastMenu1Eval = "document.all."+ Menu1LastSelected + ".className='Menu1Off'"   ;
      var  sLastMenu2Eval = "document.all."+ Menu2LastSelected + ".className='Menu2Off"+ sMenu2LastType +  "'" ;
      var sThisMenu1Eval  = "document.all."+sMenu1+".className = 'Menu1On'";
      var sThisMenu2Eval  = "document.all."+sClickedId+".className ='Menu2On'" ;

      eval (sLastMenu1Eval);
      eval (sLastMenu2Eval);
      eval (sThisMenu1Eval);
      eval (sThisMenu2Eval);
      Menu1LastSelected = sMenu1;
      Menu2LastSelected = sClickedId;

      window.parent.frames[1].location=sURL;

} // end function

</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td id="Menu11" class="Menu1On">Orders<br>
                  <table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tr>
                              <td id="Menu21l1" class="Menu2On" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=Order&amp;Mode=Create')">Create
                                    Order Entry</td>
                              <td id="Menu21r2" class="Menu2OffRight" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=Order&amp;Mode=Find')">Find/Edit
                                    Order</td>
                              <td id="Menu21r3" class="Menu2OffRight" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=Serial Number&amp;Mode=Find')">Find
                                    SN</td>
                        </tr>
                  </table>
            </td>
            <td id="Menu12" class="Menu1Off">RMAs<br>
                  <table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tr>
                              <td id="Menu22l3" class="Menu2OffLeft" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=RMA&amp;Mode=Create')">Create
                                    RMA Entry</td>
                              <td id="Menu22r4" class="Menu2OffRight" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=RMA&amp;Mode=Find')">Find/Edit
                                    RMA</td>
                        </tr>
                  </table>
            </td>
            <td id="Menu13" class="Menu1Off">Returns
                  <br>
                  <table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tr>
                              <td id="Menu23l5" class="Menu2OffLeft" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=Return&amp;Mode=Create')">Create
                                    Return Entry</td>
                              <td id="Menu23r6" class="Menu2OffRight" onclick="JsFnMenu1Clicked (this.id,'NewData.aspx?Context=Return&amp;Mode=Find')">
                                    Find/Edit Return</td>
                        </tr>
                  </table>
            </td>
      </tr>
</table>

NewData.aspx

<%@ Page language="c#" Codebehind="NewData.aspx.cs" AutoEventWireup="false" Trace="false" Inherits="nsndev.NewData" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
             <title>Create <%=sTranType%>  Entry </title>
            
            <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
            <meta content="C#" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <LINK href="nsn.css" type="text/css" rel="stylesheet">
            <script language="Javascript">
var aValue ;
var bEscapeKeyMode = false ;

function jKeypress(sID, sMode)
{
//HLS Test 8/18/2003
//alert ("IN: jKeypress");
var bReturn = true;
var skey = event.keycode ;

skey = window.event.keyCode ;
if (bEscapeKeyMode == true)
      {
      if (substring(sID,0,4) == "TxtSN")
                  {
                  alert ( "in text sn field" );
                  }
            }

      if (skey == 92)
            {
            bEscapeKeyMode = true ;
            }
      else
            {
            if (skey == 32 && (sMode == "Create" || sMode=="Edit") )
                  {
                  bReturn = false;
                  switch (sID)
                        {
                        case "TxtTranID":
                              document.all.TxtProductID.focus();
                              if (sMode == "Create" )
                                    {
                                    document.all.TxtProductID.value = "";
                                    }
                              break;
                        case "TxtProductID":
                              document.all.TxtAreaSN.focus();
                              if (sMode == "Create" )
                                    {
                                    document.all.TxtAreaSN.value = "";
                                    }
                              break;
                        default:
                              break;
                        }
                  bEscapeKeyMode = false ;
                  }
            else
                  {
                  bEscapeKeyMode = false ;
                  }
            }
if (!bReturn)
      {
      window.event.returnvalue = false ;
      }
return (bReturn)
}

function SNInputClear()
{
//HLS Test 8/18/2003
//alert ("IN: SNInputClear");
document.all.TxtAreaSN.value  = "";
}

function jPrint ()
{
//HLS Test 8/18/2003
//alert ("IN: jPrint");
      var sTranID = document.all.TxtTranID.value;
      var sDateChoice = document.forms[0].rdoTranDT[0].checked ? "Now" : "" ;
      if (sDateChoice != "Now" )
                  {
                        // get other date from 3 seperate HTML form elements
                        sTranDay = document.all.selTranDTDay;
                        sTranMo = document.all.selTranDTMonth;
                        sTranYr = document.all.selTranDTYear;
                        sTranDT = sTranMo + "/" + sTranDay + "/" + sTranYr;
                  }
      else
      {
      d = new Date();
      sTranDT = "";
      sTranDT += (d.getMonth() + 1) + "/";
      sTranDT += d.getDate() + "/";
      sTranDT += d.getYear();
      }
      sURL = "NewData.aspx?Context=<%=sTranType%> &TranID=" + sTranID + "&TranDT=" + sTranDT + "&Mode=" + "Print";
      window.open(sURL) ;
}

function SNInputEditChange (sValue, nIndex )
{
// fires when a user corrrects  a single SN
//the change is stored back into the array of SNs
//HLS Test 8/18/2003
//alert ("IN: SNInputEditChange");
aValue[nIndex] = sValue ;
document.all.TxtAreaSN.value  = aValue.join (" " );
//HLS Test 8/19/2003
SNInputCheck();
}

function jTree (sDivID)
{
//HLS Test 8/18/2003
//alert ("IN: jTree");
sDelim = "|" ;
aValue = sDivID.split ( "|") ;

sLevel = aValue[0];
sType = aValue[1];
sOpenedOrClosed = aValue[2];
sIndex = aValue[3] + sDelim +  aValue[4] + sDelim +  aValue[5] + sDelim +  aValue[6]   ;

sDiv =  sLevel +  sDelim + "data" + sDelim + "closed" + sDelim + sIndex ;
oDiv = document.getElementById ( sDiv) ;
oDiv.style.display =  sOpenedOrClosed == "closed" ? "none" : "inline" ;
sDiv =  sLevel +  sDelim + "data" + sDelim + "opened" + sDelim + sIndex ;
oDiv = document.getElementById ( sDiv) ;
oDiv.style.display = sOpenedOrClosed == "closed" ? "inline" : "none" ;
}

function SNInputEditAll()
{
//HLS Test 8/18/2003
//alert ("IN: SNInputEditAll");
document.all.DivSNCheckInvalid.style.display = "none";
document.all.DivSNCheckValid.style.display = "none";
document.all.DivSN.style.display = "none";
document.all.DivSNInput.style.display = "inline" ;
document.all.TxtAreaSN.value  = aValue.join ( " " );       
}

function ProductAdd()
{
//HLS Test 8/18/2003
//alert ("IN: ProductAdd");
document.all.DivSNCheckInvalid.style.display = "none";
document.all.DivSNCheckValid.style.display = "none";
document.all.DivSN.style.display = "none";
document.all.DivSNInput.style.display = "inline" ;
document.all.TxtProductID.value = "";      
}

function jEdit (sID, sTranType, sTranID, sTranDT, sProductID)
{
//HLS Test 8/18/2003
//alert ("IN: jEdit");
//sUrl = "NewData.aspx?Mode=Edit&TranType=" + sTranType + "&TranID=" + sTranID + "&TranDT=" + sTranDT + "&ProductID=" + sProductID;
sUrl = "NewData.aspx?Mode=Edit&Context=" + sTranType + "&TranID=" + sTranID + "&TranDT=" + sTranDT + "&ProductID=" + sProductID;
//alert ("IN: jEdit::" + sUrl);
//alert ("Context = " + sTranType);
window.location = sUrl;
}

function jOnChange(sID, sMode)
{
//HLS Test 8/18/2003
//alert ("IN: jOnChange");
      if (sMode == "Create"  || sMode=="Edit" )
      {
            var oID = document.getElementById(sID);
            var sText = oID.value;
            sText = sText.replace ( " " , "" );
            oID.value = sText ;
            if ( sID == "TxtTranID")
                        {
                        document.all.TxtProductID.focus();
                        }
            if (document.all.DivSNInput.style.display == "inline" )
                        {
                        if ( sID == "TxtProductID")
                                    {
                                    document.all.TxtAreaSN.focus();
                                    }
                        }
      }
      if (sMode == "Find" || sMode == "Found" || sMode == "Print")
            {
            // document.all.BtnFind.focus();
            }
}

function jOnLoad()
{
//HLS Test 8/18/2003

sMode = "<%=sMode%>";
sTranID = "<%=sTranID%>";
sValue = '<%=sbAreaSns%>';
sNwSN = "<%=sNwSN%>;
      if (sMode == "Print")
      {
      return (true);
      }
      
      if (sMode == "Create" && sTranID != "")
      {
            document.all.TxtProductID.focus();
      }
      else
      {
      document.all.TxtTranID.focus();
      }
      
      if (sMode == "Edit")
      {
      document.all.TxtAreaSN.value=sValue;
      return (true);
      }

}


function SNInputCheck()
{
// convert SN Input field to an Array of individual SNs based on InputDelimiter selected,
// and present back to the user for validation  within separate HTML form input elements.
// strategy is to use the  InnerHTML property of an HTML div tag to dynamically re-render
// data without round trips to the server

//HLS Test 8/18/2003
//alert ("IN: SNInputCheck");
var sInputDelimiter = " ";
// get the data from the unformatted SN data input Form
var sValue = document.all.TxtAreaSN.value ;
// convert the data into an array of SNs.based on input delimiter.
aValue = sValue.split (sInputDelimiter) ;
aValue.sort();
// uncomment the following three lines to debug  the initial Input form data
//var sOutputDelimiter = "|";
//var sDelimitedValue = aValue.join (sOutputDelimiter);
 alert (sDelimitedValue);
var sHtml = "";  
var nIndex= 0;

var nValidCount = 0 ;
// Count of duplicates
var nDuplicateCount = 0;
// Flag if there is a duplicate
var bDuplicateInstance = false ;
if  (sValue.length == 0 )
      {
      alert ( "No Serial Numbers have been entered.  Please enter a serial number");
      nCount = 0 ;
      return (0);
      }
      
// create a validated string first that strips out all doubles of delimiters and trailing delimiters
var sValidValue = "";      
nCount  = aValue.length ;

// strip out doubles of delimiters (e.g. spaces, if that's the delimiter)
for (nIndex = 0; nIndex < nCount; nIndex++)
      {
      if (aValue[nIndex] != sInputDelimiter && aValue[nIndex] != "" )
            {
            sValidValue = sValidValue+aValue[nIndex] + sInputDelimiter;
            }
      }
      
// chop off trailing delimiter
sValidValue = sValidValue.substring (0, sValidValue.length-1);
// alert (sValidValue);

// now create the array of values
aValue = sValidValue.split ( sInputDelimiter ) ;

nCount  = aValue.length ;
// alert ( nCount ) ;
for (nIndex = 0; nIndex < nCount; nIndex++)
      {
            // check for duplicates
            bDuplicateInstance = false ;
            
            // check if the next  SN is a duplicate
      
                  if (nIndex > 0)
                        {
                        if   (aValue[nIndex] == aValue[nIndex-1] )
                              {
                               bDuplicateInstance = true  ;
                               }
                        }
                  if (nIndex < (nCount + 1))
                        {
                        if   (aValue[nIndex] == aValue[nIndex+1] )
                              {
                               bDuplicateInstance = true  ;
                               }
                        }
            // end duplicate if
      
            
            // set the style to be rendered as a string to be added into the dynamic HTML'      
            sStyle = bDuplicateInstance ? "SNInputDuplicate"  : "SNInputOK" ;
            // format the dynamic HTML
            sHtml = sHtml + "<input id='TxtSn"+nIndex + "' value= '" + aValue[nIndex] + "' class=" + sStyle + " onChange='SNInputEditChange (this.value," + nIndex  + ")'>&nbsp;" ;
            
            
            // add a new line after every 5 SNs.
            
            nValidCount++ ;
            if  (nValidCount % 5 == 0  )
                  {
                  sHtml= sHtml+ "<br>";
                  }
            if  ( bDuplicateInstance)
                  {
                  nDuplicateCount++ ;
                  }
            

      }
      // END OF FOR LOOP
            
// render the dynamic HTML ;
/// ggalert ( sHtml)


// Show Validation layer if user action is required prior to submit

if  ( nDuplicateCount > 0)
      {
      document.all.DivSNCheckValid.style.display = "none";
      document.all.DivSNCheckInvalid.style.display = "inline";
      document.all.DivSNCountInvalid.innerHTML= 'Duplicate SNs have been entered.  Please correct and select  [Re-submit Serial Numbers] to continue';
      }
// Show Submit layer if validation passed
else
      {
      document.all.DivSNCheckValid.style.display = "inline";
      document.all.DivSNCheckInvalid.style.display = "none";
      document.all.DivSNCountValid.innerHTML= nValidCount;
      }
document.all.DivSN.style.display = "inline";
document.all.DivSNInput.style.display = "none" ;      
document.all.DivSN.innerHTML = sHtml;
document.all.TxtAreaSN.value = aValue.join(" ") ;

// END OF FUNCTION
}
</script>
</HEAD>
<body onload="jOnLoad(); ">
<form id="Form1" method="post" runat="server">
<DIV id="DivPage" style="Z-INDEX: 3; LEFT: 8px; WIDTH: 798px; POSITION: absolute; TOP: 8px; HEIGHT: 221px">
<DIV id="DivMainQuery"  style="display:<%=(sMode=="Print" ) ? "none" : "inline" %>">

                        <TABLE id="TblContextPrompt" cellSpacing="0" width="98%" border="0">
                              <TR>
                                    <TD width="99%" align="left"><FONT face="Eras Bold ITC" color="#000066" size="5"><%=sMode + " "+ sTranType+ " Entry"%></FONT>
                                    </TD>
                              </TR>
                        </TABLE>
                        <TABLE id="TblOrderNumber" cellSpacing="0" cellPadding="0" width="100%" border="0">
                              <TR>
                                    <TD width="2%">&nbsp;</TD>
                                    <TD class="prompt1" align="left" width="16%"><%=sTranType%>&nbsp;&nbsp;</TD>
                                    <TD class="prompt1"><INPUT value="<%=sTranID%>" type="text" maxLength="50" size="30" name="TxtTranID" id="TxtTranID" onkeypress="return jKeypress(this.id, '<%=sMode%>')" onchange="jOnChange(this.id, '<%=sMode%>')">
                                    </TD>
                              </TR>
                              <TR>
                                    <TD>&nbsp;</TD>
                                    <TD class="prompt1" align="left"><%=sTranTypeDatePrompt%>&nbsp;Date: &nbsp;</TD>
                                    <%
                                    %>
                                    <TD class="prompt1"><INPUT type="radio" <%=(bNow ? "CHECKED" : "") %> value="Now" name="rdoTranDT" id="rdoTranDTNow"><%="Today (" + sDtNowFormatted + ")"%> &nbsp; <INPUT type="radio" <%=( bNow ? "":"CHECKED" )%> value="Other" name="rdoTranDT" id="rdoTranDTOther"> Other:
                                          
                                                <div id="DivSelectOtherMonth" style="display:inline" ><%=sBuildHtmlSelectOtherDate()%></div>
                                                <SELECT name="selTranDTDay" id ="selTranDTDay">
                                                      <% for (nIndex = 1; nIndex <=31 ; nIndex++)
                                                            {
                                                            %>
                                                            <OPTION value="<%=nIndex%>" <%=(nIndex == DtOther.Day ? "selected" : "") %>><%=nIndex%></OPTION>
                                                            <%
                                                            }
                                                      %>
                                                </SELECT>
                                                <SELECT name="selTranDTYear" id ="selTranDTYear">
                                                      <% for (nIndex = (DtOther.Year-1); nIndex <= (DtOther.Year + 10) ; nIndex++)
                                                            {      
                                                            %>
                                                            <OPTION value="<%=nIndex%>" <%=(nIndex == DtOther.Year ? "selected" : "") %>><%=nIndex%></OPTION>
                                                            <%
                                                            }
                                                      %>
                                                </SELECT>
                                    </TD>
                              </TR>
                        </TABLE>
                        <div id="DivProduct" style="display:<%=(sMode=="Find" || sMode=="Found") ? "none" : "inline" %>">
                        <TABLE id="TblProductNumber" cellSpacing="0" cellPadding="0" width="100%" border="0">
                              <TR>
                                    <TD width="2%"></TD>
                                    <TD class="prompt1" align="right" width="16%"></TD>
                                    <TD class="prompt1"></TD>
                              </TR>
                              <TR>
                                    <TD>&nbsp;</TD>
                                    <TD colspan="2" align="left" class="prompt1"><hr>
                                    </TD>
                              </TR>
                              <TR>
                                    <TD width="2%">&nbsp;
                                    </TD>
                                    <TD class="prompt1" align="left" width="16%">Product Number:&nbsp;</TD>
                                    <TD class="prompt1"><INPUT value="<%=sProductID%>" type="text" id="TxtProductID" maxLength="50" size="30" name="TxtProductID" onkeypress="return jKeypress(this.id, '<%=sMode%>')" onchange="jOnChange(this.id, '<%=sMode%>')">
                                    </TD>
                              </TR>
                        </TABLE>
                        </div>
                        
            <!-- Mike added code 2004.03.16-->
            <TABLE id="TblSerialNumber" cellSpacing="0" cellPadding="0" width="100%" border="0">
                              <TR>
                                    <TD width="2%">&nbsp;</TD>
                                    <TD class="prompt1" align="left" width="16%"><%=sTranType%>&nbsp;&nbsp;</TD>
                                    <TD class="prompt1"><INPUT value="<%=sNwSN%>" type="text" maxLength="50" size="30" name="TxtTranID" id="TxtTranID" onkeypress="return jKeypress(this.id, '<%=sMode%>')" onchange="jOnChange(this.id, '<%=sMode%>')">
                                    </TD>
                              </TR>
                              <TR>
                                    <TD>&nbsp;</TD>
                                    <TD class="prompt1" align="left"><%=sTranTypeDatePrompt%>&nbsp;Date: &nbsp;</TD>
                                    <%
                                    %>
                                    <TD class="prompt1"><INPUT type="radio" <%=(bNow ? "CHECKED" : "") %> value="Now" name="rdoTranDT" id="rdoTranDTNow"><%="Today (" + sDtNowFormatted + ")"%> &nbsp; <INPUT type="radio" <%=( bNow ? "":"CHECKED" )%> value="Other" name="rdoTranDT" id="rdoTranDTOther"> Other:
                                          
                                                <div id="DivSelectOtherMonth" style="display:inline" ><%=sBuildHtmlSelectOtherDate()%></div>
                                                <SELECT name="selTranDTDay" id ="selTranDTDay">
                                                      <% for (nIndex = 1; nIndex <=31 ; nIndex++)
                                                            {
                                                            %>
                                                            <OPTION value="<%=nIndex%>" <%=(nIndex == DtOther.Day ? "selected" : "") %>><%=nIndex%></OPTION>
                                                            <%
                                                            }
                                                      %>
                                                </SELECT>
                                                <SELECT name="selTranDTYear" id ="selTranDTYear">
                                                      <% for (nIndex = (DtOther.Year-1); nIndex <= (DtOther.Year + 10) ; nIndex++)
                                                            {      
                                                            %>
                                                            <OPTION value="<%=nIndex%>" <%=(nIndex == DtOther.Year ? "selected" : "") %>><%=nIndex%></OPTION>
                                                            <%
                                                            }
                                                      %>
                                                </SELECT>
                                    </TD>
                              </TR>
                        </TABLE>            
                        
            <DIV id="DivSNAddEdit"  style="display:<%=(sMode=="Create" || sMode=="Edit") ? "inline" : "none" %>">                        
                        <DIV id="DivSNInput" >
                              <TABLE id="TblSNPrompt" cellSpacing="0" cellPadding="0" width="100%" border="0">
                                          <TR>
                                          <TD width="2%">&nbsp;
                                          </TD>
                                          <TD class="prompt1" align="left" width="16%">Serial Number(s):&nbsp;</TD>
                                          <TD class="prompt1">Please scan or key Serial Numbers into the space below.
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD class="prompt1">&nbsp;</TD>
                                          <TD class="prompt1" align="left"></TD>
                                    </TR>
                                    <TR>
                                          <TD></TD>
                                          <TD class="prompt1" colSpan="2"><INPUT onclick="SNInputCheck()" type="button" align="left" value="Submit Serial Numbers" name="BtnSNInpuCheck">
                                                &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <INPUT onclick="SNInputClear()" type="button" align="left" value="&nbsp;Clear Serial Numbers&nbsp;" name="BtnSNInputClear"></TD>
                                    </TR>
                                    <TR>
                                          <TD></TD>
                                          <TD class="prompt1" colSpan="2">&nbsp;</TD>
                                    </TR>
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD class="prompt1" colSpan="2"><TEXTAREA style="WIDTH: 100%" name="TxtAreaSN" rows="10" cols="20" accessKey="TxtAreaSN" ></TEXTAREA></TD>
                                    </TR>
                              </TABLE>
                        </DIV>
                        <DIV id="DivSNCheckInvalid" style="DISPLAY: none">
                              <TABLE id="TblSNCheck2" cellSpacing="0" cellPadding="0" width="100%" border="0">
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD colspan="2" align="left" class="prompt1"><hr>
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD width="2%"></TD>
                                          <TD width="16%" class="prompt1" align="left">Serial Number(s):</TD>
                                          <TD class="prompt2" align="left"><B><FONT color="#ff0000"><DIV id="DivSNCountInvalid" align="left" style="DISPLAY:inline">&nbsp;</DIV>
                                                      </FONT></B>
                                          </TD>
                                    </TR>
                              </TABLE>
                              <TABLE id="TblSNValidate1" cellSpacing="0" width="100%" border="0" cellpadding="0">
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD colspan="2" align="left" class="prompt1"><hr>
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD height="21" style="WIDTH: 21px">&nbsp;</TD>
                                          <TD class="prompt1">
                                                <INPUT onclick="SNInputCheck()" type="button" value="Re-Submit Serial Numbers" name="BtnSNInputAddProduct " id="Button1">&nbsp;&nbsp;
                                                <INPUT onClick="SNInputEditAll()" type="button" value="Freeform Scan/Edit " name="BtnSNInputFinished 42">&nbsp;&nbsp;
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD height="21" style="WIDTH: 21px">&nbsp;</TD>
                                          <TD class="prompt1">&nbsp;</TD>
                                    </TR>
                              </TABLE>
                        </DIV>
                        <DIV id="DivSNCheckValid" style="DISPLAY: none">
                              <TABLE id="TblSNCheck" cellSpacing="0" cellPadding="0" width="100%" border="0">
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD colspan="2" align="left" class="prompt1"><hr>
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD width="2%"></TD>
                                          <TD width="16%" class="prompt1" align="left">Serial Number(s):</TD>
                                          <TD class="prompt2" align="left"><B><FONT color="#ff0000"><DIV id="DivSNCountValid" align="left" style="DISPLAY:inline">&nbsp;</DIV>
                                                      </FONT></B>&nbsp;Serial Number(s) have been entered.
                                          </TD>
                                    </TR>
                              </TABLE>
                              <TABLE id="TblSNSaveMenu" cellSpacing="0" width="100%" border="0" cellpadding="0">
                                    <TR>
                                          <TD>&nbsp;</TD>
                                          <TD colspan="2" align="left" class="prompt1"><hr>
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD height="21" style="WIDTH: 21px">&nbsp;</TD>
                                          <TD class="prompt1">
                                          <% if (sMode != "Edit") { %><INPUT runat="server" type="button" value="Add another Product" name="BtnAddProduct " id="BtnAddProduct">&nbsp;&nbsp;<% } %>
                                          <INPUT runat="server" type="button" value="Complete" name="BtnCompleteTransaction" id="BtnCompleteTransaction">
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD height="21" style="WIDTH: 21px">&nbsp;</TD>
                                          <TD class="prompt1">&nbsp;</TD>
                                    </TR>
                              </TABLE>
                        </DIV>
                        <TABLE id="TblSNDivMenu" cellSpacing="0" width="100%" border="0" cellpadding="0">
                              <TR>
                                    <TD width="2%" height="21">&nbsp;</TD>
                                    <TD><DIV id="DivSN"></DIV>
                                          &nbsp;
                                          <DIV></DIV>
                                    </TD>
                              </TR>
                        </TABLE>
            </DIV>

            <DIV id="DivSNFind"  style="display:<%=(sMode=="Print" || sMode=="Find" || sMode== "Found" ) ? "inline" : "none" %>">
                  <TABLE id="TblFind" cellSpacing="0" width="100%" border="0" cellpadding="0">
                                    <TR>
                                          <TD width="2%" height="21">&nbsp;</TD>
                                          <TD  align="left" class="prompt1"><hr>
                                          </TD>
                                    </TR>
                                    <TR>
                                    <TD width="2%" height="21">&nbsp;</TD>
                                    <TD class="prompt1"><INPUT runat="server" type="button" value="Find Now" name="BtnFind" id="BtnFind">&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="button" value="Print" name="BtnFind" id="BtnPrint" onclick="jPrint()">
                                          </TD>
                                    </TR>
                                    <TR>
                                          <TD></TD>&nbsp;</TD>
                                          <TD class="prompt1">&nbsp;</TD>
                                    </TR>
                              </TABLE>            
            </DIV>
            <% // end of find div %>
            </DIV>
            <% // end of mainquery div %>
            <DIV id="DivSNPrint"  style="display:<%=(sMode=="Print" ) ? "inline" : "none" %>">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td bgcolor="#66CCFF">&nbsp;</td>
            <td width="147"><div align="center"><img src="images/logo.gif" width="147" height="30" border="0"></div>
            </td>
            <td bgcolor="#00CCCC">&nbsp;</td>
      </tr>
</table>
            <p class="Tree1" align="center">SERIAL NUMBER REPORT</p>
            <p ><hr></p>
            <p class="Tree2">
                              Neoware Systems, Inc.<br>
                              400 Feheley Drive<br>
                              King of Prussia, PA 19406<br>
                              FAX: (610) 275-5739<br></p>
                  <P><hr></P>
            </DIV>
<DIV id="DivSNFound"  style="display:<%=(sMode=="Print"  || sMode=="Found" ) ? "inline" : "none" %>">
      <%
                        nTranIndex = 0 ;
                        nDateIndex = 0 ;
                        nProductIndex = 0 ;
                        nSNIndex = 0;
                        nPrevTranIndex = 0 ;
                        nPrevDateIndex = 0 ;
                        nPrevProductIndex = 0 ;
                        nPrevSNIndex = 0 ;
                        
sPrevTranID    =  "" ;
sPrevTranDT    = "" ;
sPrevProductID =  "" ;
sPrevSnID      =  "" ;

// BEGIN TREE

if (sMode == "Found" || sMode == "Print")
{
while( SqlDataReaderSelTran.Read())
      {
      sTranID    = SqlDataReaderSelTran.GetString(0);
      sTranDT    = SqlDataReaderSelTran.GetDateTime(1).ToShortDateString();
      sProductID = SqlDataReaderSelTran.GetString(2);
      sSnID      = SqlDataReaderSelTran.GetString(3);
      
      // TRANSACTION LEVEL
      if ( sTranID == sPrevTranID && sTranDT == sPrevTranDT && sProductID == sPrevProductID )
            {
            if ( nSNIndex % 4 == 0 )
                  {
                  Page.Response.Write ( "</tr><tr>" );
                  }
            Page.Response.Write ( "<td class=\"tree4\" width=25% >"+ sSnID+ "</td>" );
            nSNIndex++ ;
            }
      if ( sTranID != sPrevTranID || (sTranID ==  sPrevTranID && sTranDT != sPrevTranDT) || (sTranID ==  sPrevTranID && sTranDT ==  sPrevTranDT && sProductID != sPrevProductID )   )
            {
            // write closing div tags for both Open Serial Numbers Div and  Open Product Div
            
            if ( nProductIndex > 0 )
                        {
                        // write the closing tags for the serial numbers
                        while ( nSNIndex % 4 != 0)
                              {
                              // finish up the serial number  table so it's # of cells per row are consistant
                              Page.Response.Write ( "<td class=\"tree4\" width=25% >&nbsp;</td>" );
                              nSNIndex++ ;
                              }
                        // write th end of table tag
                        Page.Response.Write ( "</tr></table></div></div>" );      
                        }
      
      if ( sTranID != sPrevTranID || (sTranID ==  sPrevTranID && sTranDT != sPrevTranDT) )
                  {
                  nProductIndex =1 ;
                  }
            else
                  {
                  nProductIndex++;
                  }
            }
      if ( sTranID != sPrevTranID || (sTranID ==  sPrevTranID && sTranDT != sPrevTranDT)    )
            {
            // write closing div tags for both Open Serial Numbers Div and  Open Product Div
            if ( nDateIndex > 0 )
                  {
                  Page.Response.Write ( "</div>" );
                  }
            if ( sTranID != sPrevTranID )
                  {
                  nDateIndex =1 ;
                  }
            else
                  {
                  nDateIndex++;
                  }
            }            
      
      if ( sTranID != sPrevTranID && nTranIndex > 0  )
            {
            Page.Response.Write ( "</div>" );
            nTranIndex++ ;
            }
      else
            {
            nTranIndex = 1;
            }      
      
      if ( sTranID != sPrevTranID )
            {
            
            // write new transaction tags
            %>
            <br><div class=tree1 id="tran|data|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: none"><div id="tran|image|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)" >+&nbsp;</div>
                              <%=sTranID%>
                              &nbsp;
            </div>
            <div class=tree1 id="tran|data|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline"><div id="tran|image|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)" >-&nbsp;</div>
                              <%=sTranID%>
                              &nbsp;
                              <%
      
            } // end if
      // end Transaction table conditions
      
                                                
      // Date LEVEL--------------------
            
      if ( sTranID != sPrevTranID || (sTranID ==  sPrevTranID && sTranDT != sPrevTranDT) )
            {
      
            %>
            <br><div id="date|data|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" class="tree2" style="DISPLAY: none"><div id="date|image|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)">+&nbsp;</div>
                              <%=sTranDT%>
                              &nbsp;
            </div>
            <div id="date|data|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" class="tree2" style="DISPLAY: inline"><div id="date|image|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)">-&nbsp;</div>
                              <%=sTranDT%>
                              &nbsp;
                              <%
            } // end if


      if ( sTranID != sPrevTranID || (sTranID ==  sPrevTranID && sTranDT != sPrevTranDT) || (sTranID ==  sPrevTranID && sTranDT ==  sPrevTranDT && sProductID != sPrevProductID )   )
            {
            // write new product tags
            %>
            <br><div id="product|data|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" class="tree3" style="DISPLAY: none"><div id="product|image|closed|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)">+&nbsp;</div>
                        <%=sProductID%>
                        &nbsp;
            </div>
            <div id="product|data|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" class="tree3" style="DISPLAY: inline"><div id="product|image|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY: inline; CURSOR: hand" onclick="jTree(this.id)">-&nbsp;</div>
                        <%=sProductID%>
            <div id="product|editbutton|opened|<%=nTranIndex%>|<%=nDateIndex%>|<%=nProductIndex%>|0" style="DISPLAY:inline" onclick="jEdit(this.id,'<%=sTranType%>','<%=sTranID%>','<%=sTranDT%>','<%=sProductID%>')">&nbsp;<%=(sMode != "Print")?"<IMG alt=\"edit\" src=\"images\\editbutton.gif\">" : "" %></div>
            <div class="tree4"><Table cellSpacing="0" cellpadding="2" width="80%" border="1"><tr><td class="tree4" width=25%><%=sSnID%></td>
                        <%
                  nSNIndex=1 ;
            } // end if
                  
                  sPrevTranID = sTranID;
                  sPrevTranDT = sTranDT;
                  sPrevProductID = sProductID;
                  sPrevSnID = sSnID;
                  
                  nPrevTranIndex = nTranIndex;
                  nPrevDateIndex = nDateIndex;
                  nPrevProductIndex = nProductIndex;
                  nPrevSNIndex = nSNIndex;
                  
            } // end while
      // end SqlDataReaderSelTran while loop
      SqlDataReaderSelTran.Close();
      SqlCon1.Close();
      
      if ( nProductIndex > 0 )
            {
            // write the closing tags for the serial numbers
                        while ( nSNIndex % 4 != 0)
                              {
                              // finish up the serial number  table so it's # of cells per row are consistant
                              Page.Response.Write ( "<td class=\"tree4\" width=25% >&nbsp;</td>" );
                              nSNIndex++ ;
                              }
                        // write the end of table tag
                  Page.Response.Write ( "</tr></table></div></div>" );      
            } // end previous nProductIndex write end tag
      if ( nDateIndex > 0 )
            {
            Page.Response.Write ( " </div>" );
            } // end previous nDateIndex write end tag                                                            
      if ( nTranIndex > 0 )
            {
            Page.Response.Write ( " </div>" );
            } // end previous nTranIndex write end tag
            // END OF TREE. write closing divs for result and page divs, closing form tag
} // end if
%>
</div>      
</DIV>

            </form>
      </body>
</HTML>
Avatar of mrissi
mrissi

ASKER

Sorry about that.

It would be great if you could move it! Thanks!
MJR
mrissi, this is classic ASP coding style and is to be avoided like the plague in ASP.NET

stuff such as this:
<SELECT name="selTranDTDay" id ="selTranDTDay">
<% for (nIndex = 1; nIndex <=31 ; nIndex++)
{
%>
<OPTION value="<%=nIndex%>" <%=(nIndex == DtOther.Day ? "selected" : "") %>><%=nIndex%></OPTION>
<%
  }
%>
</SELECT>

is totally an abuse IMHO of ASP.NET:
in the aspx page:
<asp:DropDownList id="TransactionDayList" runat="server" />

you could have done better in the aspx.cs like so
private void Page_Load(object sender, EventArgs e)
{
  if (! Page.IsPostBack)
  {
    PopulateControls();
  }
}

/// entry point to populate controls
private void PopulateControls()
{
  PopulateListControlByNumber(TransactionDayList.Items,1,32);
}

private void PopulateListControlByNumbers(ListItemCollection items,int start,int end)
{
  for(int i=start,i<end;i++)
  {
    ListItem item = new ListItem(i.ToString(),i.ToString());
    items.Add(item);
   }
}

private void SetSingularListItem(ListControl listControl,string value)
{
  listControl.SelectedIndex = -1;
  ListItem listItem = listControl.Items.FindByValue(value);
  if (listItem != null)
  {
    listItem.Selected = true;
  }

}


/// entry point to populate controls
private void PopulateControls()
{
  PopulateListControlByNumber(TransactionDayList.Items,1,32);
  SetSingularListItem(TransactionDayList,"15");
  /// other stuff
}

you must think in terms of controls instead of the traditional code-everywhere-like-spaghetti ASP style.
Avatar of mrissi

ASKER

ok -- so I should basically start over, huh?
Thanks for your help!
yes, that would really be in your best interests.
Avatar of mrissi

ASKER

Any books or resources that you can recommend as a starting place for C#?
Beginning ASP.NET Using C#
From Wrox.
http://www.wrox.com

also, any books on ASP.NET & C# from Microsoft Press would strengthen your expertise.
Avatar of mrissi

ASKER

Cool, Thanks -- I do appreciate your help .... Back to the drawing board.

MJR
ASKER CERTIFIED SOLUTION
Avatar of devplayer04
devplayer04

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrissi

ASKER

We use XML in a few of our other custom internal apps. I was trying  teach myself C#.

Just as a guide -- is there anywhere you recommend I should start?