public JsonResult SaveOtherMilk() { OtherMilk milkSale = new OtherMilk(); milkSale.PastureID = UserBLL.Instance.CurrentUser.Pasture.ID; milkSale.MilkDate = Convert.ToDateTime(Request.Form["OtherMilkDate"]); if (!string.IsNullOrWhiteSpace(Request.Form["MilkForCalf"])) { milkSale.MilkForCalf = (float)Convert.ToDouble(Request.Form["MilkForCalf"]); } if (!string.IsNullOrWhiteSpace(Request.Form["AbnormalSaleMilk"])) { milkSale.AbnormalSaleMilk = (float)Convert.ToDouble(Request.Form["AbnormalSaleMilk"]); } if (!string.IsNullOrWhiteSpace(Request.Form["BadMilk"])) { milkSale.BadMilk = (float)Convert.ToDouble(Request.Form["BadMilk"]); } if (!string.IsNullOrWhiteSpace(Request.Form["LeftMilk"])) { milkSale.LeftMilk = (float)Convert.ToDouble(Request.Form["LeftMilk"]); } int result = bllMilkRecord.InsertOtherMilkRecord(milkSale); return(Json(new { Result = result }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取牧场某天其他奶单个记录 /// </summary> /// <param name="pastureID">牧场ID</param> /// <param name="date">日期</param> /// <returns></returns> public OtherMilk GetOtherMilk(int pastureID, DateTime date) { OtherMilk other = null; List <OtherMilk> listOther = GetOtherMilkList(pastureID, date); if (listOther.Count == 1) { other = listOther[0]; } return(other); }
/// <summary> /// 封装OtherMilk /// </summary> /// <param name="row"></param> /// <returns></returns> private OtherMilk WrapOtherMilkItem(DataRow row) { OtherMilk other = new OtherMilk(); other.ID = Convert.ToInt32(row["ID"]); other.PastureID = Convert.ToInt32(row["PastureID"]); other.MilkDate = Convert.ToDateTime(row["MilkDate"]); other.MilkForCalf = Convert.ToSingle(row["MilkForCalf"]); other.AbnormalSaleMilk = Convert.ToSingle(row["AbnormalSaleMilk"]); other.BadMilk = Convert.ToSingle(row["BadMilk"]); other.LeftMilk = Convert.ToSingle(row["LeftMilk"]); return(other); }
/// <summary> /// 插入其他奶记录,有重复记录放弃插入记录。 /// </summary> /// <param name="otherMilk"></param> /// <returns></returns> public int InsertOtherMilkRecord(OtherMilk otherMilk) { OtherMilk om = GetOtherMilk(otherMilk.PastureID, otherMilk.MilkDate); if (om == null) { return(dalMilk.InsertOtherMilkRecord(otherMilk.PastureID, otherMilk.MilkDate.Date, otherMilk.MilkForCalf, otherMilk.AbnormalSaleMilk, otherMilk.BadMilk, otherMilk.LeftMilk)); } else { //放弃插入,前台处理失败逻辑 return(0); } }