Beispiel #1
0
        //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();
            }
        }