private void BindData() { var newmodel = DepDateManager.GetDepDateInfo(Convert.ToInt32(Cookie.getCookie("PerId")), DateTime.Now); if (newmodel != null) { model = newmodel; } }
/// <summary> /// 更新出栏存栏 2015.10.17 cbl /// </summary> /// <returns></returns> private string UpdateDepOutDate() { if (string.IsNullOrEmpty(Request["perId"])) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ParaError), "参数错误"); } int perId = Convert.ToInt32(Request["perId"]); var depDlk = Request["depDlk"]; if (string.IsNullOrEmpty(depDlk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写杜洛克公猪个数"); } if (!Validator.IsNumber(depDlk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "杜洛克公猪个数必须填写数字"); } var depDyk = Request["depDyk"]; if (string.IsNullOrEmpty(depDyk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写大约克公猪个数"); } if (!Validator.IsNumber(depDyk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "大约克公猪个数必须填写数字"); } var depCb = Request["depCb"]; if (string.IsNullOrEmpty(depCb)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写长白公猪个数"); } if (!Validator.IsNumber(depCb)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "长白公猪个数必须填写数字"); } var depNfmz = Request["depNfmz"]; if (string.IsNullOrEmpty(depNfmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写能繁母猪个数"); } if (!Validator.IsNumber(depNfmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "能繁母猪个数必须填写数字"); } var depHbmz = Request["depHbmz"]; if (string.IsNullOrEmpty(depHbmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写后备母猪个数"); } if (!Validator.IsNumber(depHbmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "后备母猪个数必须填写数字"); } var depZz = Request["depZz"]; if (string.IsNullOrEmpty(depZz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写仔猪个数"); } if (!Validator.IsNumber(depZz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "仔猪个数必须填写数字"); } var depBy = Request["depBy"]; if (string.IsNullOrEmpty(depBy)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写保育个数"); } if (!Validator.IsNumber(depBy)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "保育个数必须填写数字"); } var depYf = Request["depYf"]; if (string.IsNullOrEmpty(depYf)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写育肥个数"); } if (!Validator.IsNumber(depYf)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "育肥个数必须填写数字"); } var outDxsz = Request["outDxsz"]; if (string.IsNullOrEmpty(outDxsz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写当前待销售生猪个数"); } if (!Validator.IsNumber(outDxsz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "当前待销售生猪个数必须填写数字"); } var outSzcl = Request["outSzcl"]; if (string.IsNullOrEmpty(outSzcl)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写本月生猪出栏量"); } if (!Validator.IsNumber(outSzcl)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "本月生猪出栏量个数必须填写数字"); } if (string.IsNullOrEmpty(Request["sTime"])) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "月份选择不正确"); } string sTime = Request["sTime"]; var nowDate = Convert.ToDateTime(sTime.Substring(0, 4) + "-" + sTime.Substring(4, 2)); DepDate depModel = new DepDate() { DepPerId = perId, DepDlk = Convert.ToInt32(depDlk), DepDyk = Convert.ToInt32(depDyk), DepCb = Convert.ToInt32(depCb), DepNfmz = Convert.ToInt32(depNfmz), DepHbmz = Convert.ToInt32(depHbmz), DepZz = Convert.ToInt32(depZz), DepBy = Convert.ToInt32(depBy), DepYf = Convert.ToInt32(depYf), DepUTime = nowDate }; OutDate outModel = new OutDate() { OutPerId = perId, OutDxsz = Convert.ToInt32(outDxsz), OutSzcl = Convert.ToInt32(outSzcl), OutUTime = nowDate }; try { var olddepModel = DepDateManager.GetDepDateInfo(depModel.DepPerId, depModel.DepUTime); if (olddepModel != null) { depModel.DepId = olddepModel.DepId; DepDateManager.UpdateDepDate(depModel, olddepModel); } else { DepDateManager.InsertDepDate(depModel); } var oldoutModel = OutDateManager.GetOutDateInfo(outModel.OutPerId, outModel.OutUTime); if (oldoutModel != null) { outModel.OutId = oldoutModel.OutId; OutDateManager.UpdateOutDate(outModel, oldoutModel); } else { OutDateManager.InsertOutDate(outModel); } return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Success), OutDateManager.GetOutDateSum(outModel.OutPerId, nowDate).ToString()); } catch (Exception) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), "保存失败"); } }
/// <summary> /// 存栏 2015.10.12 cbl /// </summary> /// <returns></returns> private string UpdatePerDeposit() { string returnJson = GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Success), "存栏成功"); var depDlk = Request["depDlk"]; if (string.IsNullOrEmpty(depDlk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写杜洛克公猪个数"); } if (!Validator.IsNumber(depDlk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "杜洛克公猪个数必须填写数字"); } var depDyk = Request["depDyk"]; if (string.IsNullOrEmpty(depDyk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写大约克公猪个数"); } if (!Validator.IsNumber(depDyk)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "大约克公猪个数必须填写数字"); } var depCb = Request["depCb"]; if (string.IsNullOrEmpty(depCb)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写长白公猪个数"); } if (!Validator.IsNumber(depCb)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "长白公猪个数必须填写数字"); } var depNfmz = Request["depNfmz"]; if (string.IsNullOrEmpty(depNfmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写能繁母猪个数"); } if (!Validator.IsNumber(depNfmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "能繁母猪个数必须填写数字"); } var depHbmz = Request["depHbmz"]; if (string.IsNullOrEmpty(depHbmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写后备母猪个数"); } if (!Validator.IsNumber(depHbmz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "后备母猪个数必须填写数字"); } var depZz = Request["depZz"]; if (string.IsNullOrEmpty(depZz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写仔猪个数"); } if (!Validator.IsNumber(depZz)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "仔猪个数必须填写数字"); } var depBy = Request["depBy"]; if (string.IsNullOrEmpty(depBy)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写保育个数"); } if (!Validator.IsNumber(depBy)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "保育个数必须填写数字"); } var depYf = Request["depYf"]; if (string.IsNullOrEmpty(depYf)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "请填写育肥个数"); } if (!Validator.IsNumber(depYf)) { return GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.ValidationError), "育肥个数必须填写数字"); } DepDate model = new DepDate() { DepPerId = Convert.ToInt32(Cookie.getCookie("PerId")), DepDlk = Convert.ToInt32(depDlk), DepDyk = Convert.ToInt32(depDyk), DepCb = Convert.ToInt32(depCb), DepNfmz = Convert.ToInt32(depNfmz), DepHbmz = Convert.ToInt32(depHbmz), DepZz = Convert.ToInt32(depZz), DepBy = Convert.ToInt32(depBy), DepYf = Convert.ToInt32(depYf), DepUTime=DateTime.Now }; try { var oldModel = DepDateManager.GetDepDateInfo(model.DepPerId, model.DepUTime); if (oldModel != null) { model.DepId = oldModel.DepId; DepDateManager.UpdateDepDate(model, oldModel); } else { DepDateManager.InsertDepDate(model); } } catch (Exception) { returnJson = GetReturnStatusJsonStr(Convert.ToInt32(EnumType.ReturnStatus.Fail), "存栏失败"); } return returnJson; }