Esempio n. 1
0
        /// <summary>
        /// 插入售奶记录,未输入指标按0.0或者空字符串
        /// </summary>
        /// <param name="milkSale">售奶</param>
        /// <returns></returns>
        public int InsertMilkSale(MilkSale milkSale)
        {
            //validation
            if (milkSale.Company == null)
            {
                milkSale.Company = String.Empty;
            }
            if (milkSale.TruckNum == null)
            {
                milkSale.TruckNum = String.Empty;
            }
            if (milkSale.TankerNum == null)
            {
                milkSale.TankerNum = String.Empty;
            }
            if (milkSale.Decoding == null)
            {
                milkSale.Decoding = String.Empty;
            }
            if (milkSale.ShipCode == null)
            {
                milkSale.ShipCode = String.Empty;
            }

            if (milkSale.Fat == null)
            {
                milkSale.Fat = 0.0f;
            }
            if (milkSale.Protein == null)
            {
                milkSale.Protein = 0.0f;
            }
            if (milkSale.DryMatter == null)
            {
                milkSale.DryMatter = 0.0f;
            }
            if (milkSale.NonFatSolid == null)
            {
                milkSale.NonFatSolid = 0.0f;
            }
            if (milkSale.Microbe == null)
            {
                milkSale.Microbe = 0.0f;
            }
            if (milkSale.Lactose == null)
            {
                milkSale.Lactose = 0.0f;
            }
            if (milkSale.IcePoint == null)
            {
                milkSale.IcePoint = 0.0f;
            }
            if (milkSale.Acidity == null)
            {
                milkSale.Acidity = 0.0f;
            }


            return(dalMilk.InsertMilkSale(milkSale.PastureID, milkSale.MilkDate.Date, milkSale.Amount, milkSale.MilkWeight, milkSale.Company, milkSale.ShipCode, milkSale.Decoding, milkSale.TankerNum, milkSale.TruckNum, milkSale.Fat, milkSale.Protein, milkSale.DryMatter, milkSale.NonFatSolid, milkSale.Microbe, milkSale.Lactose, milkSale.IcePoint, milkSale.Acidity));
        }
        public JsonResult SaveMilkShipping()
        {
            MilkSale milkSale = new MilkSale();

            milkSale.PastureID = UserBLL.Instance.CurrentUser.Pasture.ID;
            milkSale.MilkDate  = Convert.ToDateTime(Request.Form["MilkDate"]);
            milkSale.TankerNum = Request.Form["TankerNum"];
            milkSale.Decoding  = Request.Form["Decoding"];
            milkSale.ShipCode  = Request.Form["ShipCode"];
            milkSale.TruckNum  = Request.Form["TruckNum"];
            if (!string.IsNullOrWhiteSpace(Request.Form["MilkWeight"]))
            {
                milkSale.MilkWeight = (float)Convert.ToDouble(Request.Form["MilkWeight"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Fat"]))
            {
                milkSale.Fat = (float)Convert.ToDouble(Request.Form["Fat"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Protein"]))
            {
                milkSale.Protein = (float)Convert.ToDouble(Request.Form["Protein"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["NonFatSolid"]))
            {
                milkSale.NonFatSolid = (float)Convert.ToDouble(Request.Form["NonFatSolid"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Lactose"]))
            {
                milkSale.Lactose = (float)Convert.ToDouble(Request.Form["Lactose"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Microbe"]))
            {
                milkSale.Microbe = (float)Convert.ToDouble(Request.Form["Microbe"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["IcePoint"]))
            {
                milkSale.IcePoint = (float)Convert.ToDouble(Request.Form["IcePoint"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Acidity"]))
            {
                milkSale.Acidity = (float)Convert.ToDouble(Request.Form["Acidity"]);
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["Amount"]))
            {
                milkSale.Amount = (float)Convert.ToDouble(Request.Form["Amount"]);
            }
            milkSale.Company = Request.Form["Company"];
            int result = bllMilkRecord.InsertMilkSale(milkSale);

            return(Json(new { Result = result }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        /// <summary>
        /// 封装MilkSale
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private MilkSale WrapMilkSaleItem(DataRow row)
        {
            MilkSale sale = new MilkSale();

            //milkSale.PastureID, milkSale.MilkDate.Date, milkSale.Amount, milkSale.MilkWeight,
            //不可空字段
            sale.ID         = Convert.ToInt32(row["ID"]);
            sale.PastureID  = Convert.ToInt32(row["PastureID"]);
            sale.MilkDate   = Convert.ToDateTime(row["MilkDate"]);
            sale.Amount     = Convert.ToSingle(row["Amount"]);
            sale.MilkWeight = Convert.ToSingle(row["MilkWeight"]);

            //可空字段

            if (row["Company"] != DBNull.Value)
            {
                sale.Company = row["Company"].ToString();
            }
            if (row["ShipCode"] != DBNull.Value)
            {
                sale.ShipCode = row["ShipCode"].ToString();
            }
            if (row["Decoding"] != DBNull.Value)
            {
                sale.Decoding = row["Decoding"].ToString();
            }
            if (row["TankerNum"] != DBNull.Value)
            {
                sale.TankerNum = row["TankerNum"].ToString();
            }
            if (row["TruckNum"] != DBNull.Value)
            {
                sale.TruckNum = row["TruckNum"].ToString();
            }

            if (row["Fat"] != DBNull.Value)
            {
                sale.Fat = Convert.ToSingle(row["Fat"]);
            }
            if (row["Protein"] != DBNull.Value)
            {
                sale.Protein = Convert.ToSingle(row["Protein"]);
            }
            if (row["DryMatter"] != DBNull.Value)
            {
                sale.DryMatter = Convert.ToSingle(row["DryMatter"]);
            }
            if (row["NonFatSolid"] != DBNull.Value)
            {
                sale.NonFatSolid = Convert.ToSingle(row["NonFatSolid"]);
            }
            if (row["Microbe"] != DBNull.Value)
            {
                sale.Microbe = Convert.ToSingle(row["Microbe"]);
            }
            if (row["Lactose"] != DBNull.Value)
            {
                sale.Lactose = Convert.ToSingle(row["Lactose"]);
            }
            if (row["IcePoint"] != DBNull.Value)
            {
                sale.IcePoint = Convert.ToSingle(row["IcePoint"]);
            }
            if (row["Acidity"] != DBNull.Value)
            {
                sale.Acidity = Convert.ToSingle(row["Acidity"]);
            }
            return(sale);
        }