public JsonResult GetSysFodders()
        {
            List <Fodder> sysFodderList = new List <Fodder>();
            FodderBLL     fBLL          = new FodderBLL();

            sysFodderList = fBLL.GetAllSysFodderList();
            return(Json(new { Rows = sysFodderList }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeletePastureFodder(string fodderID)
        {
            FodderBLL fBLL = new FodderBLL();
            int       temp = fBLL.DeletePastureFodder(Int32.Parse(fodderID));
            string    s    = temp == 1 ? "成功删除饲料!" : "未删除。";

            return(Json(new { Msg = s }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetFormulaFodders(int formulaID)
        {
            FodderBLL            fBLL = new FodderBLL();
            List <PastureFodder> list = new List <PastureFodder>();

            if (formulaID != 0)
            {
                list = fBLL.GetMappedPastureFodders(formulaID, UserBLL.Instance.CurrentUser.Pasture.ID);
            }

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetPastureFoldders()
        {
            List <PastureFodder> fodderList = new List <PastureFodder>();
            FodderBLL            fBLL       = new FodderBLL();

            fodderList = fBLL.GetPastureFodders(UserBLL.Instance.CurrentUser.Pasture.ID);
            var fodders = new
            {
                Rows = fodderList
            };

            return(Json(fodders, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public JsonResult AddFodder()
        {
            FodderBLL fodderBLL = new FodderBLL();
            Fodder    f         = new Fodder();

            f.Name        = Request.Form["fodderName"].ToString();
            f.Description = Request.Form["description"].ToString();
            f.RefPrice    = ToDouble(Request.Form["price"]);

            f.DM  = ToDouble(Request.Form["DM"]);
            f.NND = ToDouble(Request.Form["NND"]);
            f.Ca  = ToDouble(Request.Form["Ca"]);
            f.P   = ToDouble(Request.Form["P"]);
            f.CP  = ToDouble(Request.Form["CP"]);
            f.CF  = ToDouble(Request.Form["CF"]);
            f.Fat = ToDouble(Request.Form["Fat"]);
            f.NFE = ToDouble(Request.Form["NFE"]);
            f.ASH = ToDouble(Request.Form["ASH"]);
            f.NDF = ToDouble(Request.Form["NDF"]);
            f.ADF = ToDouble(Request.Form["ADF"]);
            f.NPP = ToDouble(Request.Form["NPP"]);
            f.Arg = ToDouble(Request.Form["Arg"]);
            f.His = ToDouble(Request.Form["His"]);
            f.Ile = ToDouble(Request.Form["Ile"]);
            f.Leu = ToDouble(Request.Form["Leu"]);
            f.Lys = ToDouble(Request.Form["Lys"]);
            f.Met = ToDouble(Request.Form["Met"]);
            f.Cys = ToDouble(Request.Form["Cys"]);
            f.Phe = ToDouble(Request.Form["Phe"]);
            f.Tyr = ToDouble(Request.Form["Tyr"]);
            f.Thr = ToDouble(Request.Form["Thr"]);
            f.Trp = ToDouble(Request.Form["Trp"]);
            f.Val = ToDouble(Request.Form["Val"]);
            f.Na  = ToDouble(Request.Form["Na"]);
            f.Cl  = ToDouble(Request.Form["Cl"]);
            f.Mg  = ToDouble(Request.Form["Mg"]);
            f.K   = ToDouble(Request.Form["K"]);
            f.Fe  = ToDouble(Request.Form["Fe"]);
            f.Cu  = ToDouble(Request.Form["Cu"]);
            f.Mn  = ToDouble(Request.Form["Mn"]);
            f.Zn  = ToDouble(Request.Form["Zn"]);
            f.Se  = ToDouble(Request.Form["Se"]);

            int temp = fodderBLL.InsertFodder(f);

            return(Json(new { Result = temp }));
        }
        public JsonResult CheckFormulaFodders(int formulaID)
        {
            FodderBLL            fBLL       = new FodderBLL();
            FormulaBLL           formulaBLL = new FormulaBLL();
            string               formulaName;
            List <PastureFodder> list  = new List <PastureFodder>();
            List <Fodder>        sList = new List <Fodder>();
            string               msg;
            int result;

            if (formulaID != 0)
            {
                list        = fBLL.GetMappedPastureFodders(formulaID, UserBLL.Instance.CurrentUser.Pasture.ID);
                sList       = fBLL.GetFodderList(formulaID);
                formulaName = formulaBLL.GetFormulaList().Find(p => p.ID == formulaID).Name;
                if (sList.Count == list.Count)
                {
                    //饲料匹配
                    msg    = "配方Ready!";
                    result = 0;
                }
                else
                {
                    msg    = "本配方存在未匹配的标准饲料。";
                    result = 1;
                }
            }
            else
            {
                msg         = "未找到配方。请联系运营方指定配方。";
                result      = 2;
                formulaName = "";
            }

            CheckFodderResult r = new CheckFodderResult()
            {
                Msg         = msg,
                Result      = result,
                FormulaName = formulaName
            };

            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AddPastureFodder(string fodderName, string quantity, string price, string sysFodderID)
        {
            string        Msg;
            PastureFodder p = new PastureFodder();

            p.FodderName = fodderName;
            p.IsCurrent  = true;
            double result;

            if (Double.TryParse(quantity, out result))
            {
                p.Quantity = result;

                if (Double.TryParse(price, out result))
                {
                    p.Price = result;
                    int rr;
                    if (Int32.TryParse(sysFodderID, out rr))
                    {
                        p.SysFodderID = rr;
                        p.PastureID   = UserBLL.Instance.CurrentUser.Pasture.ID;

                        FodderBLL fBLL = new FodderBLL();
                        int       temp = fBLL.InsertPastureFodder(p);
                        Msg = temp == 1 ? "成功添加牧场饲料!" : "未添加成功!";
                    }
                    else
                    {
                        Msg = "标准饲料选择错!";
                    }
                }
                else
                {
                    Msg = "价格输入错!";
                }
            }
            else
            {
                Msg = "饲料数量输入错!";
            }
            return(Json(new { Msg = Msg }, JsonRequestBehavior.AllowGet));
        }