Beispiel #1
0
        public override BaseResult Get(Hashtable param)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };

            try
            {
                Td_Jh_1_Query_DetailModel result = new Td_Jh_1_Query_DetailModel();
                var head = DAL.GetItem <Td_Jh_1_QueryModel>(typeof(Td_Jh_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_2_QueryModel>(typeof(Td_Jh_2), param).OrderBy(d => d.sort_id);
                    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);
        }
Beispiel #2
0
        /// <summary>
        ///是否允许退货
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public override BaseResult Export(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = false
            };
            if (param == null || param.Count < 3)
            {
                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) || string.IsNullOrEmpty(id_user))
            {
                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);
            }

            Td_Jh_1_Query_DetailModel data = (Td_Jh_1_Query_DetailModel)brJh.Data;

            if (data == null || string.IsNullOrEmpty(data.head.id))
            {
                result.Success = false;
                result.Message.Add("未查询到符合的数据!");
                return(result);
            }

            var shopModel = QueryShopById(data.head.id_shop);
            if (shopModel == null || shopModel.id.IsEmpty())
            {
                result.Success = false;
                result.Message.Add("该门店已停用或删除 不允许操作!");
                return(result);
            }

            ht.Clear();
            ht.Add("id_bill_origin", id);
            ht.Add("flag_sh", (byte)Enums.FlagSh.UnSh);
            ht.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
            if (DAL.GetCount(typeof(Td_Jh_Th_1), ht) > 0)
            {
                result.Success = false;
                result.Message.Add("该订单存在引单未审核退货订单 不允许操作!");
                return(result);
            }

            if (data.head.finish_th == 0 && data.head.flag_sh == 1 && data.head.flag_cancel == 0)
            {
                result.Success = true;
                result.Message.Add("允许退货操作!");
                return(result);
            }
            else
            {
                if (data.head.finish_th == 1)
                {
                    result.Success = false;
                    result.Message.Add("本单据已完成退货 请刷新数据后重试!");
                    return(result);
                }
                if (data.head.flag_sh != 1)
                {
                    result.Success = false;
                    result.Message.Add("本单据还未审核 不允许退货!");
                    return(result);
                }
                if (data.head.flag_cancel != 0)
                {
                    result.Success = false;
                    result.Message.Add("本单据已作废 不允许退货!");
                    return(result);
                }
            }

            #endregion
            result.Success = false;
            result.Message.Add("本单据不允许退货!");
            return(result);
        }
Beispiel #3
0
        /// <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 < 3)
            {
                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) || string.IsNullOrEmpty(id_user))
            {
                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_1_Query_DetailModel dbModel = (Td_Jh_1_Query_DetailModel)brJh.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id))
                {
                    result.Success = false;
                    result.Message.Add("获取进货单信息不符合要求!");
                    return(result);
                }

                if (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", dbModel.head.id_gys);
                var gysList = DAL.QueryList <Tb_Gys>(typeof(Tb_Gys), ht);
                if (gysList == null || gysList.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);
                }

                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);
                }

                #endregion
                #region 执行存储过程并返回结果
                ht.Clear();
                ht.Add("proname", "p_jh_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
            }
            #endregion
        }
Beispiel #4
0
        /// <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_1_Query_DetailModel dbModel = (Td_Jh_1_Query_DetailModel)brJh.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id))
                {
                    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.FlagDelete.Deleted);

                try
                {
                    if (DAL.UpdatePart(typeof(Td_Jh_1), ht) <= 0)
                    {
                        result.Success = false;
                        result.Message.Add("删除操作失败!");
                        return(result);
                    }
                }
                catch (Exception ex)
                {
                    result.Success = false;
                    result.Message.Add("删除操作异常!");
                }
                #endregion
                return(result);
            }
        }
Beispiel #5
0
        /// <summary>
        ///作废
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public override BaseResult Stop(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = true
            };
            if (param == null || param.Count < 3)
            {
                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) || string.IsNullOrEmpty(id_user))
            {
                result.Success = false;
                result.Message.Add("请登录!");
                return(result);
            }
            #endregion
            #region 更新数据
            #region 之前的
            //Hashtable ht = new Hashtable();
            //ht.Add("id", id);
            //ht.Add("id_masteruser", id_masteruser);
            //ht.Add("new_flag_cancel", (int)Enums.FlagCancel.Canceled);
            //try
            //{
            //    if (DAL.UpdatePart(typeof(Td_Jh_1), ht) <= 0)
            //    {
            //        result.Success = false;
            //        result.Message.Add("作废操作失败!");
            //        return result;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    result.Success = false;
            //    result.Message.Add("作废操作异常!");
            //}
            #endregion


            Hashtable ht = new Hashtable();
            ht.Add("id", id);
            var brJh = this.Get(ht);
            if (!brJh.Success)
            {
                return(brJh);
            }
            else
            {
                #region 校验商品合法性
                Td_Jh_1_Query_DetailModel dbModel = (Td_Jh_1_Query_DetailModel)brJh.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id))
                {
                    result.Success = false;
                    result.Message.Add("获取进货单信息不符合要求!");
                    return(result);
                }
                #endregion
                #region 执行存储过程并返回结果
                ht.Clear();
                ht.Add("proname", "p_jh_zf");
                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
            }
            #endregion
        }