Ejemplo n.º 1
0
        private int getVegunit(string gs_guid, string xs_guid)
        {
            if (this.vegunit != 0)
            {
                return(this.vegunit);
            }
            else
            {
                try
                {
                    QueryCommandConfig qry = new QueryCommandConfig("select vegunit from t_org_reginfo where org_guid = @xs_guid");
                    qry.Params["xs_guid"] = xs_guid;
                    object vegunitObj = db.ExecuteScalar(qry);
                    if (vegunitObj == null)
                    {
                        return(1);
                    }
                    else
                    {
                        this.vegunit = int.Parse(vegunitObj.ToString());
                        return(this.vegunit);
                    }
                }
                catch (Exception ex)
                {
                    DC.DCLogger.LogError(ex.Message);
                }
            }

            return(1);
        }
Ejemplo n.º 2
0
        public static void CalXsVegdata(string gs_guid, string xs_guid, ref VegData vegdata, DbNetDataProxy db)
        {
            decimal packweight = 1;

            string key = string.Concat(gs_guid, xs_guid, vegdata.Vegname);

            if (!packDic.ContainsKey(key))
            {
                QueryCommandConfig qry = new QueryCommandConfig("select cfgdata from t_lk_chcfg where xs_guid = @xs_guid limit 1");
                qry.Params["xs_guid"] = xs_guid;
                object cfg = db.ExecuteScalar(qry);
                if (cfg != null)
                {
                    DataTable cfgDt = Rest.PackOrb.JsonToObj <DataTable>(cfg.ToString());
                    foreach (DataRow cfgR in cfgDt.Rows)
                    {
                        packDic.Add(string.Concat(gs_guid, xs_guid, cfgR.Field <string>("vegname")), Convert.ToDecimal(cfgR["packweight"]));
                        if (cfgR.Field <string>("vegname").Equals(vegdata.Vegname))
                        {
                            packweight = Convert.ToDecimal(cfgR["packweight"]);
                        }
                    }
                }
            }
            else
            {
                packweight = packDic[key];
            }

            vegdata.Amount    = decimal.Round(vegdata.Amount * packweight, 3);
            vegdata.Totalcost = vegdata.Totalcost;
            vegdata.Unitcost  = decimal.Round(vegdata.Unitcost / packweight, 3);
        }
Ejemplo n.º 3
0
        public static void CalXsVegdata(string gs_guid, string xs_guid, ref DataTable vegdata, DbNetDataProxy db)
        {
            QueryCommandConfig qry = new QueryCommandConfig("select vegunit from t_org_reginfo where org_guid = @xs_guid");

            qry.Params["xs_guid"] = xs_guid;
            object vegunitObj = db.ExecuteScalar(qry);

            if (vegunitObj == null)
            {
                return;
            }

            int vegunit = int.Parse(vegunitObj.ToString());

            if (vegunit != 2)
            {
                return;
            }

            string vegname  = "vegname";
            string amount   = "amount";
            string unitcost = "unitcost";

            if (vegdata.Columns.Contains("unitprice"))
            {
                unitcost = "unitprice";
            }
            string totalcost = "totalcost";

            if (vegdata.Columns.Contains("totalprice"))
            {
                totalcost = "totalprice";
            }

            if (vegdata != null && vegdata.Rows.Count > 0)
            {
                foreach (DataRow r in vegdata.Rows)
                {
                    VegData vd = new VegData {
                        Vegname = r.Field <string>(vegname), Amount = r.Field <decimal>(amount), Unitcost = r.Field <decimal>(unitcost), Totalcost = r.Field <decimal>(totalcost)
                    };
                    CalXsVegdata(gs_guid, xs_guid, ref vd, db);
                    r[amount]    = vd.Amount;
                    r[unitcost]  = vd.Unitcost;
                    r[totalcost] = vd.Totalcost;
                }
            }
        }