///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())); } }
protected void btnUpload_Click(object sender, EventArgs e) { //HttpResponse resp = HttpContext.Current.Response; //Response.AddHeader("Content-Type", "text/event-stream"); //Response.AddHeader("Cache-Control", "no-cache"); //Response.AddHeader("Access-Control-Allow-Origin", "*"); //Response.AddHeader("Connection", "keep-alive"); clsFileUtil f = new clsFileUtil(""); string fullServerFileName = ""; SSERelay resp = new SSERelay(Response); List <string> lstFileNames = new List <string>(); try { string fn = System.IO.Path.GetFileName(filFileUpload.PostedFile.FileName); string fd = Server.MapPath(AAAK.TEMPDATA) + "\\"; fullServerFileName = fd + "\\" + fn; if (filFileUpload.PostedFile != null && filFileUpload.PostedFile.ContentLength > 0) { f.MakeDirectory(fd + "\\"); //Save the uploaded file filFileUpload.PostedFile.SaveAs(fullServerFileName); //****If zip file, unzip and start loop here****// if (fn.EndsWith(".zip")) { } else { lstFileNames.Add(fn); } clsOTSUploader cOU = new clsOTSUploader(); for (int i = 0; i < lstFileNames.Count(); i++) { if (rdbOTSImport.Checked) { string processResult = cOU.ProcessFile(resp, fd, fn); } else { string processResult = cOU.ProcessFileForInventory(resp, fd, fn, 1, txtInvComment.Text.ToUpper()); } } } else { resp.send(fn + " is not a legal File. Please make sure you have selected a valid file."); resp.send("File not processed."); } //Put the stringbuilder in divMsg divResult.InnerHtml = resp.GetMessageBlock(); } catch (Exception ex) { string errMsg = ex.GetType().ToString() + ex.Message + ex.StackTrace; resp.send("data: " + errMsg.Replace(AAAK.vbCRLF, DynControls.html_linebreak_string())); //divMsg.Controls.Add(new LiteralControl("<p>" + errMsg.Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()) + "</p>")); } finally { try { System.IO.FileInfo fl = new System.IO.FileInfo(fullServerFileName); fl.Delete(); } catch (Exception eM) { string errM = eM.Message + eM.StackTrace; } } }
protected void btnUpload_Click(object sender, EventArgs e) { clsAssyBOM aB = null; try { string fn = System.IO.Path.GetFileName(filFileUpload.PostedFile.FileName); if (filFileUpload.PostedFile != null && filFileUpload.PostedFile.ContentLength > 0) { clsFileUtil f = new clsFileUtil(""); f.MakeDirectory(Server.MapPath(AAAK.TEMPDATA) + "\\"); string fullServerFileName = Server.MapPath(AAAK.TEMPDATA) + "\\" + fn; //Create the directory filFileUpload.PostedFile.SaveAs(fullServerFileName); string pName = txtProduct.Text; string pRev = txtProductRev.Text; string bRev = txtBOMRev.Text; //create an AssyBOM object try { aB = new clsAssyBOM(pName, "", pRev, 1, 1, int.Parse(bRev), "", fullServerFileName); } catch (Exception ex2) { divMsg.Controls.Add(new LiteralControl("<p>Could not upload the BOM because of the following errors:</p>" + aB.HTML_ErrorMsg)); return; } if (aB == null) { divMsg.Controls.Add(new LiteralControl("<p>Could not upload the BOM. Please make sure you provided a valid upload BOM.</p>" + "Assembly BOM Object was null")); return; } else if (aB.HTML_ErrorMsg != "") { divMsg.Controls.Add(new LiteralControl("<p>Could not upload the BOM. Please make sure you provided a valid upload BOM.</p>" + "The error encountered was: " + aB.HTML_ErrorMsg)); return; } //Continue with upload if no errors happened during initialization if (aB.UploadToDB()) { divMsg.Controls.Add(new LiteralControl("<p>BOM Successfully Uploaded! Next step is redirect so user can view uploaded BOM.</p>")); } else { string errorResult = aB.HTML_ErrorMsg; string partAnalysisResult = aB.HTML_BadPartMessage; if (partAnalysisResult != "") { divMsg.Controls.Add(new LiteralControl("<p>Could not upload the BOM because of the following part number errors:</p>" + partAnalysisResult)); } if (errorResult != "") { divMsg.Controls.Add(new LiteralControl("<p>Could not upload the BOM because of the following errors:</p>" + errorResult)); } if (errorResult != "" || partAnalysisResult != "") { divResult.Controls.Clear(); return; } } } else { divMsg.Controls.Add(new LiteralControl("<p>" + fn + " is not a legal Upload BOM. Please make sure you have selected a valid file.")); } } catch (Exception ex) { string errMsg = ex.GetType().ToString() + ex.Message + ex.StackTrace; divMsg.Controls.Add(new LiteralControl("<p>" + errMsg.Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()) + "</p>")); } }
/// <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())); } }