Esempio n. 1
0
        /// <summary>
        /// Maps: BUID to the Code used in that BU's part numbers, as well as to that BU's Name
        /// </summary>
        public static void UpdateBUIDInfo()
        {
            Dictionary <string, string> BUIDToBUPNCode = new Dictionary <string, string>();
            Dictionary <string, string> BUIDToBUName   = new Dictionary <string, string>();
            //Initialize some global values to store in the Application Object
            //ID to Part Type gets stored in dctIDToPARTTYPE
            clsDB         myDB   = new clsDB();
            SqlCommand    sqlcmd = new SqlCommand();
            List <string> lstBU  = new List <string>();

            using (myDB.OpenConnection())
            {
                using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spGETKVPBUINFO, null, clsDB.SPExMode.READER, ref sqlcmd))
                {
                    if (dR != null && dR.HasRows)
                    {
                        while (dR.Read())
                        {
                            BUIDToBUPNCode.Add((string)dR[DBK.keyACTUALVALUE], (string)dR[DBK.strBUCODE]);
                            BUIDToBUName.Add((string)dR[DBK.keyACTUALVALUE], (string)dR[DBK.valDISPLAYEDVALUE]);
                            lstBU.Add((Convert.ToString(dR[DBK.keyACTUALVALUE])));
                            lstBU.Add((Convert.ToString(dR[DBK.valDISPLAYEDVALUE])));
                        }
                    }
                }
            }
            HttpContext.Current.Application[K.BUIDToBUPNCode] = BUIDToBUPNCode;
            HttpContext.Current.Application[K.BUIDToBUName]   = BUIDToBUName;
            HttpContext.Current.Application["kvpl_" + DBK.SP.spGETKVPBUINFO] = lstBU;
            HttpContext.Current.Application["kvpd_" + DBK.SP.spGETKVPBUINFO] = BUIDToBUName;
        }
Esempio n. 2
0
 ///Returns list of all addresses in the database
 public static string getAddressList(string input)
 {
     try
     {
         clsDB         myDB = new clsDB();
         SqlCommand    cmd  = new SqlCommand();
         StringBuilder sB   = new StringBuilder();
         using (myDB.OpenConnection())
         {
             using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spGETKVPFULLADDRESS, new List <SqlParameter>(), clsDB.SPExMode.READER, ref cmd))
             {
                 if (dR != null && dR.HasRows)
                 {
                     while (dR.Read())
                     {
                         sB.Append("<p>" + myDB.Fld2Str(dR[DBK.valDISPLAYEDVALUE]) + "</p>");
                     }
                 }
                 else
                 {
                     sB.Append("<p>No addresses found when executing stored procedure " + DBK.SP.spGETKVPFULLADDRESS + " in WebMethod getAddressList.</p>");
                 }
             }
         }
         return(sB.ToString());
     } catch (Exception ex)
     {
         return((ex.Message + ex.StackTrace).Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Returns a JSON string based on the contents of the database and user input
        /// </summary>
        /// <param name="sProcName">the name of the stored proc to invoke.</param>
        /// <param name="filterValue">The value to feed to the stored proc</param>
        /// <param name="fieldNameForDisplayedValue">The name of the field to read from the datareader;
        /// This value is what will be displayed in the auto-complete box.  This is the column whose matches
        /// you are expecting from the datatable.
        /// If you only provide this value, you get:
        /// ["value_0",...,"value_N-1"]</param>
        /// <param name="fieldNameForInsertedValue">Optional.  The name of the field to read from the datareader;
        /// This value is what will be inserted into the auto-complete box when you select fieldNameForDisplayedValue.
        /// When your provide this value, you get:
        /// [
        /// {label:"dR[fieldNameForDisplayedValue]_0", value:"dR[fieldNameForInsertedValue]_0"},
        /// {label:"dR[fieldNameForDisplayedValue]_N-1", value:"dR[fieldNameForInsertedValue]_N-1"},
        /// ]</param>
        /// <param name="ps">List of sql parameters required by the stored procedure.
        /// If you use this parameter, you are responsible for providing all parameters required by the stored procedure,
        /// including @filter.  In this scenario, parameters filterValue and pName are ignored.</param>
        /// <param name="pName">Parameter name; default is @filter</param>
        /// <returns></returns>
        public string[] GetJSONFromDB(string sProcName, string filterValue,
                                      string fieldNameForDisplayedValue,
                                      string fieldNameForInsertedValue = "",
                                      string pName           = "@filter",
                                      List <SqlParameter> ps = null)
        {
            try
            {
                clsDB      xdB = new clsDB();
                SqlCommand cmd = new SqlCommand();
                if (ps == null)
                {
                    ps = new List <SqlParameter>();
                    ps.Add(new SqlParameter("@filter", filterValue));
                }

                List <string> lstResult = new List <string>();
                using (xdB.OpenConnection())
                {
                    using (SqlDataReader dR = (SqlDataReader)xdB.ExecuteSP(sProcName, ps, clsDB.SPExMode.READER, ref cmd))
                    {
                        if (dR != null && dR.HasRows)
                        {
                            while (dR.Read())
                            {
                                if (fieldNameForInsertedValue == "")
                                {
                                    lstResult.Add(xdB.Fld2Str(dR[fieldNameForDisplayedValue]));
                                }
                                else
                                {
                                    lstResult.Add("{label:" +
                                                  xdB.Fld2Str(dR[fieldNameForDisplayedValue]) +
                                                  ", value:" +
                                                  xdB.Fld2Str(dR[fieldNameForInsertedValue]) +
                                                  "}");
                                }
                            }
                        }
                    }
                }

                if (lstResult.Count > 0)
                {
                    return(lstResult.ToArray());
                }
                else
                {
                    return(new string[0]);
                }
            } catch (Exception ex)
            {
                string strErr = ex.Message + ex.StackTrace;
                return(new string[0]);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Looks for searchVal in d; if not found, looks in database.  If found, records value in d; if not, returns default value
 /// </summary>
 /// <param name="d">Dictionary that we search for first.  </param>
 /// <param name="searchVal">The value (key) in the dictionary we are searching for; if found, we get d(key)</param>
 /// <param name="spName">The stored proc to use if searchVal is not in the dictionary</param>
 /// <param name="fldName_key">The database field name to use as the dictionary key</param>
 /// <param name="fldName_value">The database field name to use as the dictionary value</param>
 /// <param name="defaultValue">The default value to return if not searchVal not found in either the dictioanry
 /// or the database</param>
 /// <param name="spParamName">Name of the parameter in the stored procedure.  Leave this blank, and the function will use
 /// @[fldName_key]</param>
 /// <param name="putDefaultInDictionary">If not found in the dictionary or in the database, then if this set TRUE, searchVal
 /// is put in the database with the default value, so that you don't query the database for the same searchVal next time this
 /// function is called</param>
 /// <returns></returns>
 public string GetDBValueFromDictionary(ref Dictionary <string, string> d,
                                        string searchVal,
                                        string spName,
                                        string fldName_key,
                                        string fldName_value,
                                        string defaultValue,
                                        string spParamName             = "",
                                        Boolean putDefaultInDictionary = true)
 {
     try
     {
         if (d.ContainsKey(searchVal))
         {
             return(d[searchVal]);
         }
         else
         {
             clsDB xDB = new clsDB();
             List <SqlParameter> ps  = new List <SqlParameter>();
             SqlCommand          cmd = new SqlCommand();
             if (spParamName == "")
             {
                 spParamName = "@" + fldName_key;
             }
             ps.Add(new SqlParameter(spParamName, searchVal));
             using (xDB.OpenConnection())
             {
                 using (SqlDataReader dR = (SqlDataReader)xDB.ExecuteSP(spName, ps, clsDB.SPExMode.READER, ref cmd))
                 {
                     if (dR != null && dR.HasRows)
                     {
                         dR.Read();
                         string foundVal = xDB.Fld2Str(dR[fldName_value]);
                         d.Add(searchVal, foundVal);
                         return(foundVal);
                     }
                 }
             }
         }
         //if we made it this far, we should return the default value. BUT:
         if (putDefaultInDictionary)
         {
             d.Add(searchVal, defaultValue);
         }
         return(defaultValue);
     } catch (Exception ex)
     {
         return(defaultValue);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Creates elements based on the fields in a database.
 /// Optionally, the elements are enclosed in a from with ID 'form_[formID]'.
 /// </summary>
 /// <param name="appID">The appID on which these controls are based.</param>
 /// <param name="cntlContainer">The container that contains these controls</param>
 /// <param name="dctDefaultOverride">A dictionary that maps the default value given in the database
 /// with the value to use as an override</param>
 /// <param name="uid">A unique identified to append to the control IDs of the generated controls.
 /// You will need this if you are calling this method several times to generate similar output one page.
 /// (One recommended value for thie Unique ID is the Database ID).</param>
 /// <param name="cntlDisplayStyle"></param>
 /// <param name="blElementsInLine">Set false to allow displaying all elements in line (no line breaks)</param>
 /// <param name="blRunAtServer">When TRUE, includes runat=server as a property of all controls</param>
 public static void GenerateControlsFromDatabase(int appID, System.Web.UI.Control cntlContainer,
                                                 Dictionary <string, string> dctDefaultOverride = null, string uid = "", int cntlDisplayStyle = -1,
                                                 Boolean blElementsInLine = false, Boolean blRunAtServer           = false)
 {
     try
     {
         if (dctDefaultOverride == null)
         {
             dctDefaultOverride = new Dictionary <string, string>();
         }
         SqlCommand          cmd   = new SqlCommand();
         clsDB               myDB  = new clsDB();
         ControlCollection   cntls = new ControlCollection(cntlContainer);
         List <SqlParameter> ps    = new List <SqlParameter>();
         ps.Add(new SqlParameter("@" + DBK.fkAPPID, appID));
         using (myDB.OpenConnection())
         {
             using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spGETWEBDISPLAYFIELDINFO,
                                                                     ps,
                                                                     clsDB.SPExMode.READER,
                                                                     ref cmd)
                    )
             {
                 if ((dR != null) && (dR.HasRows))
                 {
                     CustomCode x = new CustomCode();
                     x.ConstructInputControls(dR, cntlContainer, dctDefaultOverride, uid, cntlDisplayStyle,
                                              blElementsInLine, blRunAtServer);
                 }
             }
         }
     } catch (Exception ex)
     {
         cntlContainer.Controls.Add(renderLiteralControlError(ex, ""));
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Calls stored procedure spOTSGetBasePartNumber to get the next available number from table
        /// otsSeed; this number is used to form the OTS Part Number.
        /// </summary>
        /// <returns></returns>
        public int GetOTSBasePartNumber()
        {
            try
            {
                clsDB               myDB = new clsDB();
                SqlParameter        p    = myDB.makeOutputParameter("@basePartNumber", System.Data.SqlDbType.Int);
                SqlCommand          cmd  = new SqlCommand();
                List <SqlParameter> ps   = new List <SqlParameter>();
                ps.Add(p);

                using (myDB.OpenConnection())
                {
                    lock (lockOTSobj)
                    {
                        myDB.ExecuteSP(DBK.SP.spOTSGETBASEPARTNUMBER, ps, clsDB.SPExMode.NONQUERY, ref cmd);
                    }
                    return(Convert.ToInt32(cmd.Parameters[DBK.SPVar.basePartNumber].Value));
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
Esempio n. 7
0
        public Boolean UploadToDB()
        {
            try
            {
                CustomCode u      = new CustomCode();
                Int64      assyID = -1;
                if (m_lstObsoleteParts.Count > 0 || m_lstUndefinedPNs.Count > 0)
                {
                    return(false);
                }
                m_errMsg.Clear();
                //First, we need to make an entry in table asyBOM so we can get the DB ID of the Assy
                xDB = new clsDB();
                cmd = new SqlCommand();
                List <SqlParameter> ps = new List <SqlParameter>();
                string assyDesc        = "ASSY," + m_topLevelName;
                ps.Add(new SqlParameter("@" + DBK.strNAME, m_topLevelName));
                ps.Add(new SqlParameter("@" + DBK.strASSYPARTNUMBER, m_assyPN));
                ps.Add(new SqlParameter("@" + DBK.strREVISION, m_assyRev));
                ps.Add(new SqlParameter("@" + DBK.intBOMREV, m_bomRev));
                ps.Add(new SqlParameter("@" + DBK.strDESCRIPTION, assyDesc));
                ps.Add(new SqlParameter("@intMajor", u.getMajorRev(m_assyRev)));
                ps.Add(new SqlParameter("@intMinor", u.getMinorRev(m_assyRev)));
                ps.Add(new SqlParameter("@" + DBK.keyUPLOADEDBY, u.getUserDBID()));
                ps.Add(new SqlParameter("@" + DBK.keyASSYBU, u.getUserdBUID()));
                ps.Add(new SqlParameter("@" + DBK.keyREASONFORREV, 1));
                ps.Add(new SqlParameter("@" + DBK.keyASSYSTATUS, 1));
                ps[ps.Count - 1].Direction = System.Data.ParameterDirection.InputOutput;
                ps.Add(new SqlParameter("@" + DBK.ID, -1));
                ps[ps.Count - 1].Direction = System.Data.ParameterDirection.Output;
                using (xDB.OpenConnection())
                {
                    xDB.ExecuteSP(DBK.SP.spUPSERTASSYBOMENTRY, ps, clsDB.SPExMode.NONQUERY, ref cmd);
                    if (int.Parse(cmd.Parameters["@" + DBK.keyASSYSTATUS].Value.ToString()) == 1)
                    {
                        assyID = Int64.Parse(cmd.Parameters["@" + DBK.ID].Value.ToString());
                        //Delete this ASSY ID From the database
                        List <SqlParameter> tmpLstP = new List <SqlParameter>();
                        tmpLstP.Add(new SqlParameter("@" + DBK.keyASSY, assyID));
                        SqlCommand tmpCmd = new SqlCommand();
                        using (xDB.OpenConnection())
                        {
                            xDB.ExecuteSP(DBK.SP.spDELETEASSYBOMPARTS, tmpLstP, clsDB.SPExMode.NONQUERY, ref tmpCmd);
                        }
                        StringBuilder sqlStr = new StringBuilder();
                        sqlStr.Append("INSERT INTO " + DBK.asyBOMPARTS + " (" + DBK.keyASSY + ", " + DBK.keyPN + ", " +
                                      DBK.strREFDES + ", " + DBK.strBOMNOTES + ", " + DBK.intQTY + ") VALUES ");
                        //The values we will insert are in m_BOM
                        foreach (string assyPNKy in m_BOM.Keys)
                        {
                            string abk = assyPNKy;
                            foreach (string PNKy in m_BOM[assyPNKy].Keys)
                            {
                                AssyBomLineItem x        = m_BOM[assyPNKy][PNKy];
                                string          bomNotes = x.BOMNotes;
                                if (bomNotes == "" || bomNotes == "-")
                                {
                                    bomNotes = "''";
                                }
                                sqlStr.Append("(" +
                                              assyID + ", " +
                                              x.PNID.ToString() + ", " +
                                              "'" + x.RefDes + "', " +
                                              bomNotes + ", " +
                                              x.Qty.ToString() + "),");
                            }
                        }

                        //Remove the last comma
                        sqlStr.Remove(sqlStr.Length - 1, 1);
                        cmd.Parameters.Clear();
                        using (xDB.OpenConnection())
                        {
                            if (xDB.ExecuteNonQuery(sqlStr.ToString()))
                            {
                                if (xDB.NAffectedRows > 0)
                                {
                                    return(true);
                                }
                                else
                                {
                                    m_errMsg.Append("Executed following query without errors:" +
                                                    sqlStr + AAAK.vbCRLF + "...but no rows were affected by the Statement.  Please report this bug.");
                                    return(false);
                                }
                            }
                            else
                            {
                                m_errMsg.Append("Method UploadToDB: Unable to execute Nonquery: " +
                                                sqlStr + AAAK.vbCRLF + xDB.ErrMsg);
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        m_errMsg.Append(m_topLevelName + " Revision " + m_assyRev + " BOM Revision " + m_bomRev +
                                        "is RELEASED.  You cannot upload a new BOM if it's status is RELEASED." + AAAK.vbCRLF +
                                        "If you want to upload a new BOM, you must change the Assembly and/or BOM revision.");
                        return(false);
                    }
                }
            } catch (Exception ex)
            {
                m_errMsg.Append(ex.Message + AAAK.vbCRLF + ex.StackTrace);
                return(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a new Assy BOM Object;
        /// If successful, look at property BOM; if it fails, check property ErrorMsg
        /// Call method Upload to upload the object to the database
        /// </summary>
        /// <param name="topLevelName">aka the Product Name</param>
        /// <param name="assyPN">Part Number of the top level name; leave this blank, and the constructor will use
        /// the first AssyPN it encounters i the file specified in filePath as the Part Number for the assembly.</param>
        /// <param name="assyRev">Revision of the Assembly</param>
        /// <param name="uploaderID">ID of the user uploading the BOM</param>
        /// <param name="assyBU">BU of the BOM</param>
        /// <param name="bomRev">Revision of the Assembly BOM</param>
        /// <param name="reasonForRev">reason for the revision; OK to leave this blank, in which case
        /// the constructor will use the default key for Initial Release.</param>
        /// <param name="filePath">Path and file of the tsv file containing BOM information.</param>
        public clsAssyBOM(string topLevelName, string assyPN, string assyRev, int uploaderID, int assyBU,
                          int bomRev, string reasonForRev, string filePath)
        {
            try
            {
                StringBuilder sB = new StringBuilder();

                m_topLevelName = topLevelName.ToUpper();
                m_assyPN       = assyPN.ToUpper();
                m_assyRev      = assyRev.ToUpper();
                m_uploadedByID = uploaderID;
                m_assyBUID     = assyBU;
                m_bomRev       = bomRev;
                m_ReasonForRev = reasonForRev;
                clsFileUtil f = new clsFileUtil(filePath);

                m_BOM = new Dictionary <string, Dictionary <string, AssyBomLineItem> >();
                using (StreamReader sR = f.OpenAndRead())
                {
                    string l = sR.ReadLine();   //First line is the header row; position of the headers tells us
                                                //which columns to look at
                    int      colAssyPN   = -1;
                    int      colRefDes   = -1;
                    int      colPN       = -1;
                    int      colQ        = -1;
                    int      colBOMNotes = -1;
                    int      colInum     = -1;
                    string[] arr         = l.Split('\t');
                    for (int i = 0; i <= arr.GetUpperBound(0); i++)
                    {
                        switch (arr[i].ToLower())
                        {
                        case "bom item id":
                            colAssyPN = i;
                            break;

                        case "ref designator":
                            colRefDes = i;
                            break;

                        case "component id":
                            colPN = i;
                            break;

                        case "qty per assy":
                            colQ = i;
                            break;

                        case "bom notes":
                            colBOMNotes = i;
                            break;

                        case "i#":
                            colInum = i;
                            break;
                        }
                    }
                    //Loop the remainder of the file
                    while (!sR.EndOfStream)
                    {
                        l   = sR.ReadLine();
                        arr = l.Split('\t');
                        string aPN = arr[colAssyPN];
                        if (!m_BOM.ContainsKey(aPN))
                        {
                            Dictionary <string, AssyBomLineItem> d = new Dictionary <string, AssyBomLineItem>();
                            m_BOM.Add(aPN, d);
                            if (m_assyPN == "")
                            {
                                m_assyPN = aPN;
                            }
                        }
                        m_BOM[aPN].Add(arr[colPN],
                                       new AssyBomLineItem(arr[colPN], -1, arr[colRefDes].ToString().Replace(AAAK.DQ, ""), arr[colBOMNotes], int.Parse(arr[colQ])));
                        sB.Append(arr[colPN] + ",");
                    }

                    string csvPN = sB.ToString().Substring(0, sB.Length - 1);

                    //Execute the stored procedure to:
                    //1) Determine if there are any invalid part numbers
                    //2) Get the ID for each PN
                    List <SqlParameter> ps = new List <SqlParameter>();
                    ps.Add(new SqlParameter("@csvPN", csvPN));
                    using (xDB.OpenConnection())
                    {
                        using (SqlDataReader dR = (SqlDataReader)xDB.ExecuteSP(DBK.SP.spOTSGETPNIDS, ps, clsDB.SPExMode.READER, ref cmd))
                        {
                            if (dR != null && dR.HasRows)
                            {
                                while (dR.Read())
                                {
                                    if (xDB.Fld2Str(dR[DBK.ID]) == "")
                                    {
                                        m_lstUndefinedPNs.Add(dR[DBK.SP_COLALIAS.PN].ToString());
                                    }
                                    else
                                    {
                                        foreach (string assyKy in m_BOM.Keys)
                                        {
                                            if (m_BOM[assyKy].ContainsKey(xDB.Fld2Str(dR[DBK.SP_COLALIAS.PN])))
                                            {
                                                m_BOM[assyKy][dR[DBK.SP_COLALIAS.PN].ToString()].PNID = Int64.Parse(dR[DBK.ID].ToString());
                                            }
                                        }

                                        if (int.Parse(dR[DBK.keyPARTSTATUS].ToString()) == 3)
                                        {
                                            m_lstObsoleteParts.Add(dR[DBK.SP_COLALIAS.PN].ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                f.Delete();
            } catch (Exception ex)
            {
                m_errMsg.Append("Error in clsAssyBOM.New:" + AAAK.vbCRLF + ex.Message + AAAK.vbCRLF + ex.StackTrace);
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check for any url encoded parameters
            string foundIDData = "";

            if (Request.QueryString.HasKeys())
            {
                try
                {
                    CustomCode x        = new CustomCode();
                    string     targetID = Request.QueryString["ID"];
                    //The following is a bogus division that will go at the end of the displayed page so that the client can't obtain the ID
                    string htmlForID = "<div " +
                                       DynControls.encodeProperty("id", "x_" + targetID) +
                                       DynControls.encodeProperty("class", "getID") + " ></div>";
                    //Get the PN associated with the targetID
                    clsDB               myDB = new clsDB();
                    SqlCommand          cmd  = new SqlCommand();
                    List <SqlParameter> ps   = new List <SqlParameter>();
                    ps.Add(new SqlParameter("@pnID", Int64.Parse(targetID)));
                    string pageHeader = "";
                    using (myDB.OpenConnection())
                    {
                        using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spOTSGETPNINFO, ps, clsDB.SPExMode.READER, ref cmd))
                        {
                            if (dR != null && dR.HasRows)
                            {
                                dR.Read();
                                pageHeader = myDB.Fld2Str(dR[DBK.strPARTNUMBER]);
                            }
                        }
                    }

                    if (Request.QueryString["INV"] != null)
                    {
                        pageHeader  = DynControls.html_header_string(pageHeader + " Inventory", 1);
                        foundIDData = pageHeader + x.InvForPN(targetID) + htmlForID;
                    }
                    else if (Request.QueryString["INVH"] != null)
                    {
                        pageHeader  = DynControls.html_header_string(pageHeader + " Inventory History", 1);
                        foundIDData = pageHeader + x.MakePartNumberInventoryHistoryTable(Int64.Parse(targetID)) + htmlForID;
                    }
                    else
                    {
                        foundIDData = x.getHTMLForPartNumberID(targetID);
                    }
                    otsdivs.Controls.Add(new LiteralControl(foundIDData));
                    foreach (Control c in divMenuButtons.Controls)
                    {
                        divMenuButtons.Controls.Remove(c);
                    }
                    return;
                } catch (Exception ex)
                {
                    string x = ex.Message + ex.StackTrace;
                }
            }
            //Create three panels and add them to the existing div
            Panel divOTSNew = new Panel();

            divOTSNew.ID = "divOTSNew";
            divOTSNew.Style.Add(HtmlTextWriterStyle.Display, "none");
            otsdivs.Controls.Add(divOTSNew);

            //There are two panels in divOTSNew: divOTSNewIn and divOTSNewOut

            Panel divOTSNewIn = new Panel();

            divOTSNewIn.ID = "divOTSNewIn";
            //Get the input controls from the database for divOTSNewIn...
            DynControls.GenerateControlsFromDatabase(DBK.AppKeys.GET_NEWOTSPN, divOTSNewIn);
            //Add a Submit button
            divOTSNewIn.Controls.Add(DynControls.html_button("btnOTSNewIn", "SUBMIT", "inputButton",
                                                             true, AAAK.DISPLAYTYPES.BLOCK, "Create an OTS Part Number", "frmNewOTS"));
            //...and add a div for the ajax output
            Panel divOTSNewOut = new Panel();

            divOTSNewOut.ID = "divOTSNewOut";
            divOTSNewOut.Controls.Add(new LiteralControl("<p>Enter the information on the left, then press Submit to get your new OTS Part Number.</p>"));
            //Add these two sub panels
            divOTSNew.Controls.Add(divOTSNewIn);
            divOTSNew.Controls.Add(divOTSNewOut);
            //***** End divOTSNew

            //***** Start divOTSFind
            Panel divOTSFind = new Panel();

            divOTSFind.ID = "divOTSFind";
            divOTSFind.Style.Add(HtmlTextWriterStyle.Display, "none");
            //divOTSFind.Style.Add(HtmlTextWriterStyle.OverflowX, "auto");
            otsdivs.Controls.Add(divOTSFind);
            //Now: The html in this div is simple, but as the user make selections, the AJAX calls increase the
            //complexity of the children's html.
            //This div has 3 divs.
            ///divOTSFind Child Div 1:
            Panel divSearch = new Panel();

            divSearch.ID = "divSearch";

            DynControls.GenerateControlsFromDatabase(DBK.AppKeys.SEARCH_OTS, divSearch, null, "", -1, true);
            //Create the search button
            string btnSearchHtmlString = DynControls.html_button_string("btnLook", "SEARCH", "searchButton",
                                                                        true, AAAK.DISPLAYTYPES.BLOCK, form: "frmSearchOTS");

            divSearch.Controls.Add(new LiteralControl(btnSearchHtmlString));

            ///divOTSFind Child Div 2:
            ///The message div
            Panel divSearchMsg = new Panel();

            divSearchMsg.Style.Add(HtmlTextWriterStyle.Display, "block");
            divSearchMsg.ID = "divMessage";
            divSearchMsg.Controls.Add(new LiteralControl("<p " + DynControls.encodeProperty("id", "searchmsg") + ">" +
                                                         "Enter search criteria above to find Part Number Information.</p>"));
            ///divOTSFind Child Div 3:
            ///
            Panel divLook = new Panel();

            divLook.Style.Add(HtmlTextWriterStyle.Display, "block");
            divLook.Style.Add(HtmlTextWriterStyle.OverflowX, "auto");
            divLook.ID = "divLook";
            /// divLook's html will be determine when user presses SEARCH

            ///Add the three divs to divOTSFind
            divOTSFind.Controls.Add(divSearch);
            divOTSFind.Controls.Add(new LiteralControl("<div></div>"));
            divOTSFind.Controls.Add(divSearchMsg);
            divOTSFind.Controls.Add(divLook);

            Panel divOTSAdmin = new Panel();

            divOTSAdmin.ID = "divOTSAdmin";
            divOTSAdmin.Controls.Add(new LiteralControl("<p>Admin</p>"));
            divOTSAdmin.Style.Add(HtmlTextWriterStyle.Display, "none");
            otsdivs.Controls.Add(divOTSAdmin);
        }
Esempio n. 10
0
        /// <summary>
        /// Updates invBulk with user information in input
        /// </summary>
        /// <param name="input">FORMAT:
        /// [comment]DELIM[invBulk.ID]DELIM[EXISTING QTY]DELIM[DELTA]DELIM[SubInv]DELIM[LocationID]DELIM[OwnerID]DELIM[VPNID]DELIM[TransactionType ID]......</param>
        /// <returns></returns>
        public string UpdatePartInventory(string input, string[] m_dlim)
        {
            StringBuilder sB = new StringBuilder();

            try
            {
                string[] arr = input.Split(m_dlim, StringSplitOptions.None);
                string   cmt = arr[0].ToUpper();
                lock (lockUpdateInvObj)
                {
                    for (int i = 1; i < arr.Length; i = i + 8)
                    {
                        clsDB               myDB        = new clsDB();
                        SqlCommand          cmd         = new SqlCommand();
                        List <SqlParameter> ps          = new List <SqlParameter>();
                        string              spName      = "";
                        string              ID          = arr[i];
                        string              Qty         = arr[i + 1];
                        string              Delta       = arr[i + 2];
                        string              SubInv      = arr[i + 3].ToUpper();
                        string              Loc         = arr[i + 4];
                        string              Owner       = arr[i + 5];
                        string              VPNID       = arr[i + 6];
                        string              TransTypeID = arr[i + 7];

                        int    oldQty       = 0;
                        int    oldLoc       = -1;
                        Int64  oldOwner     = -1;
                        string oldSubInv    = "";
                        int    oldKeySubInv = -1;
                        //Get the current subinv, location, qty, and owner for the given ID
                        ps.Add(new SqlParameter("@" + DBK.ID, Int64.Parse(ID)));
                        using (myDB.OpenConnection())
                        {
                            using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spINVGETINFOFORINVBULKID, ps, clsDB.SPExMode.READER, ref cmd))
                            {
                                if (dR != null && dR.HasRows)
                                {
                                    dR.Read();
                                    oldQty       = (int)dR[DBK.intQTY];
                                    oldLoc       = (int)dR[DBK.keyLOCATIONBULK];
                                    oldOwner     = (Int64)dR[DBK.keyOWNER];
                                    oldKeySubInv = (int)dR[DBK.keySUBINV];
                                    oldSubInv    = (string)dR[DBK.strSUBINV];
                                }
                            }
                        }

                        //Reset for next usage
                        ps.Clear();

                        if (Qty == "-1" && Int64.Parse(ID) > -1)
                        {
                            //User wants to remove this entry from invBulk
                            ps.Add(new SqlParameter("@" + DBK.keyBULKITEM, VPNID));
                            ps.Add(new SqlParameter("@" + DBK.keyCHANGEDBY, AAAK.CHANGEDBY));
                            ps.Add(new SqlParameter("@" + DBK.intDELTA, -oldQty));
                            ps.Add(new SqlParameter("@" + DBK.strCOMMENT, cmt));
                            ps.Add(new SqlParameter("@" + DBK.keyTRANSACTIONTYPE, 1));
                            ps.Add(new SqlParameter("@" + DBK.keyLOCATIONBULK, oldLoc));
                            ps.Add(new SqlParameter("@" + DBK.keyOWNER, oldOwner));
                            ps.Add(new SqlParameter("@" + DBK.keySUBINV, oldKeySubInv));
                            ps.Add(new SqlParameter("@" + DBK.ID, ID));
                            spName = DBK.SP.spINVREMOVEBULKINVENTRY;
                        }
                        else if (!clsUtil.IsInteger(Qty))
                        {
                            //Ignore this value, but alert user via email
                        }
                        else if (Qty != "" && Int64.Parse(Loc) > -1 && Int64.Parse(Owner) > -1)
                        {
                            //Update Qty based on Delta; note the client has already determined if there is a minus or not in front of delta, so
                            int newQty = int.Parse(Qty) + int.Parse(Delta);

                            //Only continue if there is a change in the data
                            if (oldLoc != int.Parse(Loc) || oldOwner != Int64.Parse(Owner) || oldQty != newQty || oldSubInv != SubInv)
                            {
                                //User wants to make a new/update an existing entry
                                ps.Add(new SqlParameter("@" + DBK.keyBULKITEM, VPNID));
                                ps.Add(new SqlParameter("@" + DBK.keyCHANGEDBY, AAAK.CHANGEDBY));
                                ps.Add(new SqlParameter("@" + DBK.intDELTA, Delta));
                                ps.Add(new SqlParameter("@" + DBK.strCOMMENT, cmt));
                                ps.Add(new SqlParameter("@" + DBK.keyTRANSACTIONTYPE, TransTypeID));
                                ps.Add(new SqlParameter("@" + DBK.keyLOCATIONBULK, Loc));
                                ps.Add(new SqlParameter("@" + DBK.keyOWNER, Owner));
                                ps.Add(new SqlParameter("@" + DBK.intQTY, newQty));
                                ps.Add(new SqlParameter("@" + DBK.ID, ID));
                                ps.Add(new SqlParameter("@" + DBK.strSUBINV, SubInv));
                                spName = DBK.SP.spINVUPSERTINVBULKENTRY;
                            }
                        }
                        if (spName != "")
                        {
                            using (myDB.OpenConnection())
                            {
                                myDB.ExecuteSP(spName, ps, clsDB.SPExMode.NONQUERY, ref cmd);
                                {
                                    if (myDB.ErrMsg != "")
                                    {
                                        sB.Append(myDB.ErrMsg);
                                    }
                                }
                            }
                        }
                    }
                }

                return(sB.ToString().Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()));
            }
            catch (Exception ex)
            {
                return((ex.Message + AAAK.vbCRLF + ex.StackTrace).Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()));
            }
        }