//This method to return the Converted values public static double UomCnvertedVal(string FromUom, string ToUom, double Qty, double VlFact, DataTable dtUomConv) { try { //Asign values to properties UomConversions cls = new UomConversions(FromUom, ToUom, Qty, VlFact, default(double), string.Empty); DataRow[] dr; if (dtUomConv.Columns.Contains("FromUom") && dtUomConv.Columns.Contains("ToUom")) { dr = dtUomConv.Select("FromUom='" + UomConversions.FrUOM + "' and ToUom='" + UomConversions.ToUOM + "'"); if (dr != null && dr.Count() > 0) { UomConversions.CnvQty = UomConversions.FrQty * (Convert.ToDouble(dr[0]["Numenator"]) / Convert.ToDouble(dr[0]["Denominator"])); } else { UomConversions.CnvQty = UomConversions.FrQty * UomConversions.ValFct; } } else { UomConversions.CnvQty = UomConversions.FrQty * UomConversions.ValFct; } return(Math.Round(UomConversions.CnvQty, 4)); } catch (Exception ex) { throw ex; } }
//This method will return the converted value by comparing the UOMs from XML File. public static double ConvertedValue(string FrUOM, string ToUOM, double FrQty, double ValFct, double WT, string WTUOM) { try { //Asign values to properties UomConversions cls = new UomConversions(FrUOM, ToUOM, FrQty, ValFct, WT, WTUOM); if (count == 0) { xmlUrl = HttpContext.Current.Server.MapPath(@"~\UILayer\Documents\FTZ\XmlFiles\UOMConversion.xml"); ParseByXMLDocument(); //calling static method from static contructor to load the xml only once. count = 1; } //Check the invoice UOM with HTS UOM, If Invoice UOM is NO or PCS or EA and HTS UOM is DOZ then divide qty/12 and return the value if ((FrUOM == "NO" || FrUOM == "PCS" || FrUOM == "EA") == (ToUOM == "DOZ")) { UomConversions.CnvQty = UomConversions.FrQty / UomConversions.DOZ; } else { UomConversions.CnvQty = UomConversions.FrQty * UomConversions.ValFct; } return(UomConversions.CnvQty); } catch (Exception ex) { throw ex; } }
//This method will return the converted value by comparing the UOMs from DB. public static double UomCnvVal(string FrUOM, string ToUOM, double FrQty, double ValFct, double WT, string WTUOM) { IDBManager dbManager = CommonConnection.Connectionstring(); try { double sRetVal = default(double); dbManager.Open(); dbManager.CreateParameters(7); DataSet dsVal = new DataSet(); //Asign values to properties UomConversions cls = new UomConversions(FrUOM, ToUOM, FrQty, ValFct, WT, WTUOM); if (ConfigurationSettings.AppSettings["DataB"] == "SQL") { dbManager.AddParameters(0, "@FrUOM", UomConversions.FrUOM, ParameterDirection.Input); dbManager.AddParameters(1, "@ToUOM", UomConversions.ToUOM, ParameterDirection.Input); dbManager.AddParameters(2, "@FrQty", UomConversions.FrQty, ParameterDirection.Input); dbManager.AddParameters(3, "@ValFct", UomConversions.ValFct, ParameterDirection.Input); dbManager.AddParameters(4, "@WT", UomConversions.WT, ParameterDirection.Input); dbManager.AddParameters(5, "@WTUOM", UomConversions.WTUOM, ParameterDirection.Input); dbManager.AddParameters(6, "@CnvQty", 0, ParameterDirection.Output); string spCall = Helper.Ins.GetSPCall(dbManager.Parameters, "ObjUom_Convert"); dsVal = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "ObjUom_Convert"); } if (dbManager.Parameters[6].Value.ToString() != "") { sRetVal = double.Parse(dbManager.Parameters[6].Value.ToString()); } return(sRetVal); } catch (Exception ex) { throw ex; } finally { dbManager.Dispose(); } }