public override BaseResult Get(Hashtable param) { BaseResult res = new BaseResult() { Success = true }; try { Td_Jh_Th_1_Query_DetailModel result = new Td_Jh_Th_1_Query_DetailModel(); var head = DAL.GetItem <Td_Jh_Th_1_QueryModel>(typeof(Td_Jh_Th_1), param); if (head != null && !string.IsNullOrEmpty(head.id)) { result.head = head; param.Clear(); param.Add("id_bill", head.id); param.Add("dh", head.dh); var body = DAL.QueryList <Td_Jh_Th_2_QueryModel>(typeof(Td_Jh_Th_2), param); result.body = body.ToList(); res.Data = result; } else { res.Success = false; res.Message.Add("未找到此退货单信息!"); } } catch (Exception ex) { res.Success = false; res.Message.Add("操作异常!"); } return(res); }
/// <summary> ///删除 /// </summary> /// <param name="param"></param> /// <returns></returns> public override BaseResult Delete(Hashtable param) { #region 参数验证 BaseResult result = new BaseResult() { Success = true }; if (param == null || param.Count < 2) { result.Success = false; result.Message.Add("参数有误!"); return(result); } var id = param["id"].ToString(); var id_masteruser = param["id_masteruser"].ToString(); if (string.IsNullOrEmpty(id)) { result.Success = false; result.Message.Add("参数有误!"); return(result); } if (string.IsNullOrEmpty(id_masteruser)) { result.Success = false; result.Message.Add("请登录!"); return(result); } #endregion #region 更新数据 Hashtable ht = new Hashtable(); ht.Add("id", id); var brJh = this.Get(ht); if (!brJh.Success) { return(brJh); } else { Td_Jh_Th_1_Query_DetailModel dbModel = (Td_Jh_Th_1_Query_DetailModel)brJh.Data; if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id) || dbModel.body == null || dbModel.body.Count() <= 0) { result.Success = false; result.Message.Add("获取退货单信息不符合要求!"); return(result); } if (dbModel.head.flag_sh == (byte)Enums.FlagSh.HadSh) { result.Success = false; result.Message.Add("该单据已经审核,不允许删除!"); return(result); } ht.Clear(); ht.Add("id", id); ht.Add("id_masteruser", id_masteruser); ht.Add("flag_sh", (byte)Enums.FlagSh.UnSh); ht.Add("new_flag_delete", (int)Enums.FlagCancel.Canceled); try { if (DAL.UpdatePart(typeof(Td_Jh_Th_1), ht) <= 0) { result.Success = false; result.Message.Add("删除操作失败!"); return(result); } } catch (Exception ex) { result.Success = false; result.Message.Add("删除操作异常!"); } #endregion return(result); } }
/// <summary> /// 审核 /// </summary> /// <param name="param"></param> /// <returns></returns> public BaseResult ActiveWork(Hashtable param) { #region 参数验证 BaseResult result = new BaseResult() { Success = true }; if (param == null || param.Count < 2) { result.Success = false; result.Message.Add("参数有误!"); return(result); } var id = param["id"].ToString(); var id_masteruser = param["id_masteruser"].ToString(); var id_user = param["id_user"].ToString(); if (string.IsNullOrEmpty(id)) { result.Success = false; result.Message.Add("参数有误!"); return(result); } if (string.IsNullOrEmpty(id_masteruser)) { result.Success = false; result.Message.Add("请登录!"); return(result); } #endregion #region 数据操作 Hashtable ht = new Hashtable(); ht.Add("id", id); var brJh = this.Get(ht); if (!brJh.Success) { return(brJh); } else { #region 校验商品合法性 Td_Jh_Th_1_Query_DetailModel dbModel = (Td_Jh_Th_1_Query_DetailModel)brJh.Data; if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id) || dbModel.body == null || dbModel.body.Count() <= 0) { result.Success = false; result.Message.Add("获取进货单信息不符合要求!"); return(result); } ht.Clear(); ht.Add("id_masteruser", id_masteruser); ht.Add("id_shop", dbModel.head.id_shop); var shopspList = DAL.QueryList <Tb_Shopsp>(typeof(Tb_Shopsp), ht); if (shopspList == null || shopspList.Count() <= 0) { result.Success = false; result.Message.Add("该门店下不存在商品!"); return(result); } //ht.Clear(); //ht.Add("id_masteruser", id_masteruser); //ht.Add("id_shop", dbModel.head.id_shop); //var kcList = DAL.QueryList<Tz_Sp_Kc>(typeof(Tz_Sp_Kc), ht); //if (kcList == null || kcList.Count() <= 0) //{ // result.Success = false; // result.Message.Add("未查询到库存信息!"); // return result; //} var noShopspList = (from body in dbModel.body where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim()) == 0 select body).ToList(); if (noShopspList != null && noShopspList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,门店[{0}]不存在商品[{1}]", dbModel.head.shop_name, noShopspList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var stopShopspList = (from body in dbModel.body where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && d.flag_state == (byte)Enums.FlagShopspStop.Stoped) > 0 select body).ToList(); if (stopShopspList != null && stopShopspList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,商品为[{0}]已停用!", stopShopspList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var noSpflShopspList = (from body in dbModel.body where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && d.id_spfl == "0") > 0 select body).ToList(); if (noSpflShopspList != null && noSpflShopspList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,商品为[{0}]未设置分类", noSpflShopspList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var noId_kcspShopspList = (from body in dbModel.body where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && (d.id_kcsp == null || d.id_kcsp == "")) > 0 select body).ToList(); if (noId_kcspShopspList != null && noId_kcspShopspList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,商品为[{0}] 库存ID 为空!", noId_kcspShopspList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var noDwShopspList = (from body in dbModel.body where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && (d.dw == null || d.dw == "")) > 0 select body).ToList(); if (noDwShopspList != null && noDwShopspList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,商品为[{0}] 单位 为空!", noDwShopspList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var noIdSpList = (from body in dbModel.body where shopspList.Count(d => d.id_sp.ToString().Trim() == body.id_sp.ToString().Trim()) == 0 select body).ToList(); if (noIdSpList != null && noIdSpList.Count > 0) { result.Success = false; result.Message.Add(string.Format("过账失败,门店[{0}]不存在商品[{1}]的id_sp", dbModel.head.shop_name, noIdSpList.FirstOrDefault().shopsp_name)); throw new CySoftException(result); } var bodyInfo = dbModel.body.GroupBy(d => d.id_kcsp).Select(d => new { id_kcsp = d.Key, sl_qm = d.Sum(s => s.sl_total), je_qm = d.Sum(s => s.je) }); #endregion ht.Clear(); ht.Add("proname", "p_jh_th_sh"); ht.Add("errorid", "-1"); ht.Add("errormessage", "未知错误!"); ht.Add("id_bill", dbModel.head.id); ht.Add("id_user", id_user); DAL.RunProcedure(ht); if (!ht.ContainsKey("errorid") || !ht.ContainsKey("errormessage")) { result.Success = false; result.Message.Add("过账失败,执行审核出现异常!"); throw new CySoftException(result); } if (!string.IsNullOrEmpty(ht["errorid"].ToString()) || !string.IsNullOrEmpty(ht["errormessage"].ToString())) { result.Success = false; result.Message.Add(ht["errormessage"].ToString()); throw new CySoftException(result); } result.Success = true; result.Message.Add("过账成功,审核成功!"); return(result); } #endregion }