public void Get_total_cube_by_QuoteID(string QuoteID, ref AES_API_info api_info) { try { using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringAesAPI)) { #region SQL string sql = string.Concat("SELECT TotalCube ", "FROM Genera_Rating ", "WHERE QuoteID=", QuoteID); #endregion DB.LogGenera(iam, "Get_total_cube_by_QuoteID sql", sql); using (SqlCommand command = new SqlCommand()) { command.Connection = conn; command.CommandText = sql; conn.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { LTLPiece piece = new LTLPiece(); if (reader["TotalCube"] != DBNull.Value) { api_info.total_cube = (double)reader["TotalCube"]; DB.LogGenera(iam, "Get_total_cube_by_QuoteID api_info.total_cube", api_info.total_cube.ToString()); } } } } DB.LogGenera(iam, "Get_total_cube_by_QuoteID api_info.total_cube", api_info.total_cube.ToString()); } } catch (Exception e) { DB.LogGenera(iam, "Get_total_cube_by_QuoteID", e.ToString()); } //return api_info; }
/// <summary> /// Genera /// </summary> private void SetLTLPiecesObject(out int numOfUnitsPieces, out int numOfUnits, ref LTLQuoteRequest ltl_quote_request, ref QuoteData quoteData) { // numOfUnitsPieces = 0; numOfUnits = 0; int Quantity = 0, pieces = 0;// intResult, //double parsedDouble; // quoteData.m_lPieceList = new List <LTLPiece>(); quoteData.m_lPiece_actual_List = new List <LTLPiece>(); // // int Units = 0, Pieces = 0; try { for (byte i = 1; i <= ltl_quote_request.items.Count; i++) { if (ltl_quote_request.items[i - 1].weight > 0) { if (ltl_quote_request.items[i - 1].pieces > 0) { pieces = ltl_quote_request.items[i - 1].pieces; } Units = 0; Pieces = 0; if (ltl_quote_request.items[i - 1].units > 0) { numOfUnitsPieces += ltl_quote_request.items[i - 1].units; numOfUnits += ltl_quote_request.items[i - 1].units; Quantity = ltl_quote_request.items[i - 1].units; // Units = ltl_quote_request.items[i - 1].units; Pieces = pieces; } else if (ltl_quote_request.items[i - 1].pieces > 0) { numOfUnitsPieces += ltl_quote_request.items[i - 1].pieces; Quantity = ltl_quote_request.items[i - 1].pieces; // Pieces = ltl_quote_request.items[i - 1].pieces; } else { numOfUnitsPieces += 1; Quantity = 1; Pieces = pieces; } LTLPiece ltlPiece = new LTLPiece(); LTLPiece ltlPiece_actual = new LTLPiece(); // Set class weight and quantity //--------------------------------------------------------------------------------- if (quoteData.isHHG.Equals(true)) { ltlPiece.FreightClass = "150"; ltlPiece_actual.FreightClass = "150"; //DB.Log("hhg", ""); } else { ltlPiece.FreightClass = ltl_quote_request.items[i - 1].freightClass.ToString(); ltlPiece_actual.FreightClass = ltl_quote_request.items[i - 1].freightClass.ToString(); //DB.Log("not hhg", ""); } //ltlPiece.FreightClass = Request.QueryString["q_Class" + i.ToString()]; // Check if this rate has freight class if (i.Equals(1) && (string.IsNullOrEmpty(ltlPiece.FreightClass) || ltlPiece.FreightClass.Equals("-1"))) { quoteData.hasFreightClass = false; } if (i.Equals(1) && quoteData.isHHG_AndUnder500 == true && quoteData.extraWeight > 0) { // Extra weight ltlPiece.Weight = (double)ltl_quote_request.items[i - 1].weight + quoteData.extraWeight; quoteData.totalWeight += ltlPiece.Weight; ltlPiece_actual.Weight = (double)ltl_quote_request.items[i - 1].weight; //ltlPiece_actual.Weight = (int)ltlPiece_actual.Weight; } else { // Regular case ltlPiece.Weight = (double)ltl_quote_request.items[i - 1].weight; quoteData.totalWeight += ltlPiece.Weight; ltlPiece_actual.Weight = (double)ltl_quote_request.items[i - 1].weight; //ltlPiece_actual.Weight = (int)ltlPiece_actual.Weight; } ltlPiece.Quantity = Quantity; ltlPiece.Units = Units; ltlPiece.Pieces = Pieces; ltlPiece_actual.Quantity = Quantity; ltlPiece_actual.Units = Units; ltlPiece_actual.Pieces = Pieces; //--------------------------------------------------------------------------------- #region Set dimensions // If there are no dims they are set to 0 by default, otherwise set dims if (ltl_quote_request.items[i - 1].length > 0) { ltlPiece.Length = (double)ltl_quote_request.items[i - 1].length; ltlPiece_actual.Length = (double)ltl_quote_request.items[i - 1].length; } if (ltl_quote_request.items[i - 1].width > 0) { ltlPiece.Width = (double)ltl_quote_request.items[i - 1].width; ltlPiece_actual.Width = (double)ltl_quote_request.items[i - 1].width; } if (ltl_quote_request.items[i - 1].height > 0) { ltlPiece.Height = (double)ltl_quote_request.items[i - 1].height; ltlPiece_actual.Height = (double)ltl_quote_request.items[i - 1].height; } #endregion ltlPiece.HazMat = quoteData.isHazmat; ltlPiece_actual.HazMat = quoteData.isHazmat; // Commodity //if (form.Get("q_Commodity" + i.ToString()) != null) //{ // ltlPiece.Commodity = form.Get("q_Commodity" + i.ToString()); //} ltlPiece.Commodity = ltl_quote_request.items[i - 1].commodity; ltlPiece_actual.Commodity = ltl_quote_request.items[i - 1].commodity; quoteData.m_lPieceList.Add(ltlPiece); quoteData.m_lPiece_actual_List.Add(ltlPiece_actual); } } quoteData.m_lPiece = quoteData.m_lPieceList.ToArray(); quoteData.m_lPiece_actual = quoteData.m_lPiece_actual_List.ToArray(); #region For testing //for (int i = 0; i < m_lPieceList.Count; i++) //{ // DB.Log("myTest", m_lPieceList[i].FreightClass + " " + m_lPieceList[i].Weight.ToString() + // " quantity: " + m_lPieceList[i].Quantity.ToString() + " length: " + m_lPieceList[i].Length.ToString() // + " width: " + m_lPieceList[i].Width.ToString() + " height: " + m_lPieceList[i].Height.ToString(), ""); //} #endregion } catch (Exception e) { DB.LogException("SetLTLPiecesObject", e.ToString()); } }
public void Get_items_by_QuoteID(string QuoteID, ref AES_API_info api_info) { List <LTLPiece> pieces = new List <LTLPiece>(); try { using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringRater2009)) { #region SQL string sql = string.Concat("SELECT Class,Weight,Units ", "FROM SQL_STATS_GCM_LTL ", "WHERE ID=", QuoteID); #endregion using (SqlCommand command = new SqlCommand()) { command.Connection = conn; command.CommandText = sql; conn.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { LTLPiece piece = new LTLPiece(); if (reader["Class"] != DBNull.Value) { piece.FreightClass = reader["Class"].ToString(); DB.LogGenera(iam, "Get_items_by_QuoteID piece.FreightClass", piece.FreightClass); } if (reader["Weight"] != DBNull.Value) { piece.Weight = (int)reader["Weight"]; api_info.total_weight += (int)piece.Weight; DB.LogGenera(iam, "Get_items_by_QuoteID piece.Weight", piece.Weight.ToString()); } if (reader["Units"] != DBNull.Value) { piece.Units = (int)reader["Units"]; api_info.total_units += (int)piece.Units; DB.LogGenera(iam, "Get_items_by_QuoteID piece.Units", piece.Units.ToString()); } pieces.Add(piece); } } } } api_info.m_lPiece = pieces.ToArray(); } catch (Exception e) { DB.LogGenera(iam, "Get_items_by_QuoteID", e.ToString()); } //return api_info; }
/// <summary> /// Intention here is to work with the inputs on this page same as the objects on WS, this way adding a new carrier to both files is easier /// </summary> private void SetLTLPiecesObject(out int numOfUnitsPieces, out int numOfUnits, ref FormDataCollection form, ref QuoteData quoteData) { numOfUnitsPieces = 0; numOfUnits = 0; int Quantity = 0, intResult, pieces = 0; double parsedDouble; // quoteData.m_lPieceList = new List <LTLPiece>(); quoteData.m_lPiece_actual_List = new List <LTLPiece>(); // // int Units = 0, Pieces = 0; try { for (byte i = 1; i <= 4; i++) { if (!string.IsNullOrEmpty(form.Get("q_Weight" + i.ToString()))) { if (form.Get("q_Piece" + i.ToString()) != null) { int.TryParse(form.Get("q_Piece" + i.ToString()), out pieces); } Units = 0; Pieces = 0; if (form.Get("commodity_unit" + i.ToString()) != null && form.Get("commodity_unit" + i.ToString()).Length > 0 && int.TryParse(form.Get("commodity_unit" + i.ToString()), out intResult)) { numOfUnitsPieces += intResult; numOfUnits += intResult; Quantity = intResult; // Units = intResult; Pieces = pieces; } else if (form.Get("q_Piece" + i.ToString()) != null && form.Get("q_Piece" + i.ToString()).Length > 0 && int.TryParse(form.Get("q_Piece" + i.ToString()), out intResult)) { numOfUnitsPieces += intResult; Quantity = intResult; // Pieces = intResult; } else { numOfUnitsPieces += 1; Quantity = 1; Pieces = pieces; } LTLPiece ltlPiece = new LTLPiece(); LTLPiece ltlPiece_actual = new LTLPiece(); // Set class weight and quantity //--------------------------------------------------------------------------------- if (quoteData.isHHG.Equals(true)) { ltlPiece.FreightClass = "150"; ltlPiece_actual.FreightClass = "150"; } else { ltlPiece.FreightClass = form.Get("q_Class" + i.ToString()); ltlPiece_actual.FreightClass = form.Get("q_Class" + i.ToString()); } //ltlPiece.FreightClass = Request.QueryString["q_Class" + i.ToString()]; // Check if this rate has freight class if (i.Equals(1) && (string.IsNullOrEmpty(ltlPiece.FreightClass) || ltlPiece.FreightClass.Equals("-1"))) { quoteData.hasFreightClass = false; } if (i.Equals(1) && form.Get("q_isHHG_AndUnder500") != null && form.Get("q_isHHG_AndUnder500") == "true" && form.Get("q_ExtraWeight") != null && double.TryParse(form.Get("q_ExtraWeight"), out quoteData.extraWeight) && quoteData.extraWeight > 0) { // Extra weight ltlPiece.Weight = Convert.ToDouble(form.Get("q_Weight" + i.ToString())) + quoteData.extraWeight; quoteData.totalWeight += ltlPiece.Weight; ltlPiece_actual.Weight = Convert.ToDouble(form.Get("q_Weight" + i.ToString())); } else { // Regular case ltlPiece.Weight = Convert.ToDouble(form.Get("q_Weight" + i.ToString())); quoteData.totalWeight += ltlPiece.Weight; ltlPiece_actual.Weight = Convert.ToDouble(form.Get("q_Weight" + i.ToString())); } ltlPiece.Quantity = Quantity; ltlPiece.Units = Units; ltlPiece.Pieces = Pieces; ltlPiece_actual.Quantity = Quantity; ltlPiece_actual.Units = Units; ltlPiece_actual.Pieces = Pieces; //--------------------------------------------------------------------------------- #region Set dimensions // If there are no dims they are set to 0 by default, otherwise set dims if (form.Get("q_Length" + i.ToString()) != null && form.Get("q_Length" + i.ToString()) != "NaN" && double.TryParse(form.Get("q_Length" + i.ToString()), out parsedDouble)) { ltlPiece.Length = parsedDouble; ltlPiece_actual.Length = parsedDouble; } if (form.Get("q_Width" + i.ToString()) != null && form.Get("q_Width" + i.ToString()) != "NaN" && double.TryParse(form.Get("q_Width" + i.ToString()), out parsedDouble)) { ltlPiece.Width = parsedDouble; ltlPiece_actual.Width = parsedDouble; } if (form.Get("q_Height" + i.ToString()) != null && form.Get("q_Height" + i.ToString()) != "NaN" && double.TryParse(form.Get("q_Height" + i.ToString()), out parsedDouble)) { ltlPiece.Height = parsedDouble; ltlPiece_actual.Height = parsedDouble; } #endregion ltlPiece.HazMat = Convert.ToBoolean(form.Get("q_HazMat" + i.ToString())); ltlPiece_actual.HazMat = Convert.ToBoolean(form.Get("q_HazMat" + i.ToString())); // Commodity if (form.Get("q_Commodity" + i.ToString()) != null) { ltlPiece.Commodity = form.Get("q_Commodity" + i.ToString()); ltlPiece_actual.Commodity = form.Get("q_Commodity" + i.ToString()); } quoteData.m_lPieceList.Add(ltlPiece); quoteData.m_lPiece_actual_List.Add(ltlPiece_actual); } } quoteData.m_lPiece = quoteData.m_lPieceList.ToArray(); quoteData.m_lPiece_actual = quoteData.m_lPiece_actual_List.ToArray(); #region For testing //for (int i = 0; i < m_lPieceList.Count; i++) //{ // DB.Log("myTest", m_lPieceList[i].FreightClass + " " + m_lPieceList[i].Weight.ToString() + // " quantity: " + m_lPieceList[i].Quantity.ToString() + " length: " + m_lPieceList[i].Length.ToString() // + " width: " + m_lPieceList[i].Width.ToString() + " height: " + m_lPieceList[i].Height.ToString(), ""); //} #endregion } catch (Exception e) { DB.LogException("SetLTLPiecesObject", e.ToString()); } }