Esempio n. 1
0
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="PlainPassword"></param>
        /// <param name="StrAccID"></param>
        /// <param name="AccYear"></param>
        /// <param name="Act"></param>
        /// <param name="entity"></param>
        /// <param name="success"></param>
        /// <returns></returns>
        public string DelDispatchList(string UserCode, string PlainPassword,
                                      string StrAccID, int AccYear, string Act, EntityDispatchListHead entity, out int success)
        {
            success = 1;
            string msg = "";

            DispatchListBll bll = new DispatchListBll(StrAccID, AccYear, UserCode, PlainPassword);

            if (bll.GetGlmendFlag(entity.dDate.Year, entity.dDate.Month, "bflag_SA") == true)
            {
                success = 0;
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cDLCode));
            }
            if (GetDispatchList(entity.cDLCode) != 0)
            {
                if (DispatchListChecked(entity.cDLCode) == 0)
                {
                    msg     = string.Format("U8中发/退货单:{0} 已审核,不允许删除!", entity.cDLCode);
                    success = 0;
                }
                else
                {
                    //执行删除发货单操作
                    DeleteDispatchList(entity.cDLCode);
                    msg     = string.Format("U8中发/退货单:{0} 已删除!", entity.cDLCode);
                    success = 1;
                }
            }
            else
            {
                msg = string.Format("U8中发/退货单:{0} 不存在!", entity.cDLCode);
            }

            return(msg);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取发货单实体类数据
        /// </summary>
        /// <param name="cDLCode"></param>
        /// <returns></returns>
        public EntityDispatchListHead GetEntityDispatchListHead(string cDLCode)
        {
            EntityDispatchListHead        entity   = new EntityDispatchListHead();
            List <EntityDispatchListBody> listBody = new List <EntityDispatchListBody>();
            string sqlHead = "SELECT cDLCode ,dDate,cDepCode,cCusCode,cDefine1,cSTCode,cDefine14,ccusperson,cShipAddress,cDefine8,cDefine3,cMemo FROM DispatchList WHERE cDLCode=@cDLCode ";
            string sqlBody = "SELECT cInvCode ,cWhCode ,iQuantity,iQuotedPrice,iSum,iTaxRate,cBatch FROM DispatchLists where DLID = (SELECT DLID FROM DispatchList WHERE cDLCode = @cDLCode )";

            SqlParameter[] paras =
            {
                new SqlParameter("@cDLCode", cDLCode)
            };
            SqlDataReader drHead = DB_SqlHelper.ExecuteReader(CommandType.Text, sqlHead, paras);
            SqlDataReader drBody = DB_SqlHelper.ExecuteReader(CommandType.Text, sqlBody, paras);

            while (drBody.Read())
            {
                EntityDispatchListBody body = new EntityDispatchListBody();
                body.cInvCode     = drBody["cInvCode"].ToString();
                body.cWhCode      = drBody["cWhCode"].ToString();
                body.iQuantity    = ConvertToDecimal(drBody["iQuantity"]);
                body.iQuotedPrice = ConvertToDecimal(drBody["iQuotedPrice"]);
                body.iSum         = ConvertToDecimal(drBody["iSum"]);
                body.iTaxRate     = ConvertToDecimal(drBody["iTaxRate"]);
                body.cBatch       = drBody["cBatch"].ToString();
                listBody.Add(body);
            }

            if (drHead.Read())
            {
                entity.cDLCode      = cDLCode;
                entity.dDate        = Convert.ToDateTime(drHead["dDate"]);
                entity.cDepCode     = drHead["cDepCode"].ToString();
                entity.cCusCode     = drHead["cCusCode"].ToString();
                entity.cDefine1     = drHead["cDefine1"].ToString();
                entity.cSTCode      = drHead["cSTCode"].ToString();
                entity.cDefine14    = drHead["cDefine14"].ToString();
                entity.ccusperson   = drHead["ccusperson"].ToString();
                entity.cShipAddress = drHead["cShipAddress"].ToString();
                entity.cDefine8     = drHead["cDefine8"].ToString();
                entity.cDefine3     = drHead["cDefine3"].ToString();
                entity.cMemo        = drHead["cMemo"].ToString();
                entity.Details      = listBody;
            }
            return(entity);
        }
Esempio n. 3
0
        public string DeleteModels(string UserCode, string CipherPassword, int ModelType,
                                   string StrAccID, string Act, string Entity)
        {
            string plainPassword = DefineEncryptDecrypt.Decrypt(CipherPassword);
            int    AccYear       = U8BllBase.GetBeginYear(StrAccID);

            if (AccYear == 0)
            {
                return(ControllerHelp.GetReturnStr(0, string.Format("没有找到账套号:{0}", StrAccID)));
            }
            int        success = 0;
            ModelsType mt      = (ModelsType)ModelType;

            switch (mt)
            {
            case ModelsType.RdRecord01:    //采购入库单
            {
                if (Act == "delete")
                {
                    EntityRdRecord01Head entity = JsonConvert.DeserializeObject <EntityRdRecord01Head>(Entity);
                    RdRecord01Bll        bll    = new RdRecord01Bll(StrAccID, AccYear, UserCode, plainPassword);
                    var result = bll.DelRdRecord01(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                    return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                }
                break;
            }

            case ModelsType.DispatchList2:     //发货单
                if (Act == "delete")
                {
                    EntityDispatchListHead entity = JsonConvert.DeserializeObject <EntityDispatchListHead>(Entity);
                    DispatchListBll        bll    = new DispatchListBll(StrAccID, AccYear, UserCode, plainPassword);
                    var result = bll.DelDispatchList(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                    return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                }
                break;
            }
            return(ControllerHelp.GetReturnStr(0, "DeleteModels中没有找到可对应的操作项"));
        }
Esempio n. 4
0
        public string InsertDispatchList(EntityDispatchListHead DispatchListHead)
        {
            int?DispatchListHeadID;

            #region 验证
            if (DispatchListHead == null || DispatchListHead.Details == null || DispatchListHead.Details.Count == 0)
            {
                throw new JRException("新增失败!没有数据!");
            }

            CreateDHColumn("DispatchLists");

            #endregion

            // 得到主表ID和从表ID
            int detailCount = DispatchListHead.Details.Count;
            int head_id     = 0;
            int body_end_Id = 0;
            GetId("00", "DISPATCH", detailCount, out head_id, out body_end_Id);

            string         sql  = string.Format(@"
                                insert into DispatchList(DLID,cVouchType,cSTCode,dDate,cDepCode,cexch_name,
                                iExchRate,bFirst,bReturnFlag,bSettleAll,iVTid,cCusCode,cBusType,cDLCode,cSOCode,
                                cDefine1,cMaker,cCusName,cSysBarCode,
                                iNetLock,ioutgolden,bCredit,ireturncount,bsigncreate,
                                bcashsale,bmustbook,bneedbill,baccswitchflag,bsaleoutcreatebill,iTaxRate,cDefine3,cMemo,cinvoicecompany,cDefine8,ccusperson,cShipAddress,cDefine14
                                )VALUES(@DLID,@cVouchType,@cSTCode,@dDate,@cDepCode,@cexch_name,
                                @iExchRate,@bFirst,@bReturnFlag,@bSettleAll,@iVTid,@cCusCode,@cBusType,@cDLCode,@cSOCode,
                                @cDefine1,@cMaker,@cCusName,@cSysBarCode,
                                null,null,0,null,0,
                                0,0,1,0,0,@iTaxRate,@cDefine3,left(@cMemo,255),@cCusCode,@cDefine8,@ccusperson,@cShipAddress,@cDefine14
                                )");
            SqlParameter[] para =
            {
                new SqlParameter("@cVouchType",   GetDBValue(DispatchListHead.cVouchType)),
                new SqlParameter("@cSTCode",      GetDBValue(DispatchListHead.cSTCode)),
                new SqlParameter("@dDate",        DispatchListHead.dDate.ToShortDateString()),
                new SqlParameter("@cDepCode",     DispatchListHead.cDepCode),
                new SqlParameter("@cexch_name",   GetDBValue(DispatchListHead.cexch_name)),
                new SqlParameter("@iExchRate",    DispatchListHead.iExchRate),
                new SqlParameter("@bFirst",       DispatchListHead.bFirst),
                new SqlParameter("@bReturnFlag",  DispatchListHead.bReturnFlag),
                new SqlParameter("@bSettleAll",   DispatchListHead.bSettleAll),
                new SqlParameter("@iVTid",        DispatchListHead.iVTid),
                new SqlParameter("@cCusCode",     DispatchListHead.cCusCode),
                new SqlParameter("@cBusType",     GetDBValue(DispatchListHead.cBusType)),
                new SqlParameter("@cDLCode",      DispatchListHead.cDLCode),
                new SqlParameter("@cSOCode",      GetDBValue(DispatchListHead.cSOCode)),
                new SqlParameter("@cDefine1",     GetDBValue(DispatchListHead.cDefine1)),
                new SqlParameter("@cMaker",       GetDBValue(DispatchListHead.cMaker)),
                new SqlParameter("@cCusName",     GetDBValue(DispatchListHead.cCusName)),
                new SqlParameter("@cSysBarCode",  GetDBValue(DispatchListHead.cSysBarCode)),
                new SqlParameter("@DLID",         head_id),
                new SqlParameter("@iTaxRate",     DispatchListHead.Details[0].iTaxRate),
                new SqlParameter("@cDefine3",     GetDBValue(DispatchListHead.cDefine3)),                 //计入任务
                new SqlParameter("@cMemo",        GetDBValue(DispatchListHead.cMemo)),
                new SqlParameter("@cDefine8",     GetDBValue(DispatchListHead.cDefine8)),
                new SqlParameter("@ccusperson",   GetDBValue(DispatchListHead.ccusperson)),
                new SqlParameter("@cShipAddress", GetDBValue(DispatchListHead.cShipAddress)),
                new SqlParameter("@cDefine14",    GetDBValue(DispatchListHead.cDefine14)),
            };
            int headCount = this.DB_SqlHelper.ExecuteNonQuery(sql, para);
            if (headCount > 0)
            {
                try
                {
                    List <ExecuteHelp> sqlList = new List <ExecuteHelp>();

                    DispatchListHeadID = GetDispatchListID(DispatchListHead.cDLCode);
                    if (DispatchListHeadID == null)
                    {
                        throw new JRException("表头新增失败!");
                    }

                    string getCurrentStockSql = GetCurrentStockSql("Dis");
                    // 组装SQL语句
                    for (int i = 0; i < detailCount; i++)
                    {
                        EntityDispatchListBody body = DispatchListHead.Details[i];

                        string bodySql = string.Format(@"
                                    insert into DispatchLists(bcosting,DLID,cInvCode,bSettleAll,iDLsID,bQANeedCheck,bQAUrgency,bQAChecking,bQAChecked,
                                    cWhCode,iQuantity,iUnitPrice,
                                    iSum,iTaxRate,iTaxUnitPrice,iTax,iNatUnitPrice,iNatMoney,
                                    iNatTax,iNatSum,iNatDisCount,iDisCount,
                                    iQuotedPrice,cInvName,iMoney,KL,KL2,fSaleCost,fSalePrice,irowno,cbSysBarCode,
                                    iCorID,iNum,iSettleNum,iSettleQuantity,iBatch,TBQuantity,iSOsID,fOutQuantity,
                                    fOutNum,fEnSettleQuan,fEnSettleSum,iSettlePrice,cMassUnit,iQAQuantity,iQANum,fsumsignquantity,
                                    fsumsignnum,fcusminprice,iExpiratDateCalcu,bneedsign,bsignover,bneedloss,
                                    frlossqty,bsaleprice,bgift,bmpforderclosed,bIAcreatebill,DHID,cSoCode,cBatch,cDefine28
                                    )
                                    VALUES(@bcosting,@DLID,@cInvCode,@bSettleAll,@iDLsID,@bQANeedCheck,@bQAUrgency,@bQAChecking,@bQAChecked,
                                    @cWhCode,@iQuantity,@iUnitPrice,
                                    @iSum,@iTaxRate,@iTaxUnitPrice,@iTax,@iNatUnitPrice,@iNatMoney,
                                    @iNatTax,@iNatSum,@iNatDisCount,@iDisCount,
                                    @iQuotedPrice,@cInvName,@iMoney,@KL,@KL2,@fSaleCost,@fSalePrice,@irowno,@cbSysBarCode,
                                    null,null,null,null,null,0,null,null,
                                    null,null,null,0,0,0,0,null,
                                    null,0,0,0,0,0,
                                    0,1,0,0,0,@DHID,@cSOCode,@cBatch,@cDefine28
                                    );
                                    {0}
                                    IF (@bReturnFlag=0 AND ISNULL(@cSOCode,'') <>'')
                                    BEGIN
                                    UPDATE  SO_SODetails SET iFHQuantity=isnull(iFHQuantity,0)+@iQuantity,iFHMoney=isnull(iFHMoney,0)+@iSum  WHERE cSOCode=@cSOCode and cInvCode=@cInvCode and DHID=@DHID
                                    UPDATE  a SET  a.iSOsID=b.iSOsID FROM   DispatchLists a inner join SO_SODetails b on a.cSOCode=b.cSOCode and a.cInvCode=b.cInvCode and a.DHID=b.DHID WHERE  a.cSOCode=@cSOCode
                                    END
                                    ", getCurrentStockSql);

                        SqlParameter[] bodyPara =
                        {
                            new SqlParameter("@bcosting",      body.bcosting),
                            new SqlParameter("@DLID",          DispatchListHeadID),
                            new SqlParameter("@cInvCode",      body.cInvCode),
                            new SqlParameter("@bSettleAll",    body.bSettleAll),
                            new SqlParameter("@iDLsID",        (body_end_Id - detailCount + i + 1)),
                            new SqlParameter("@bQANeedCheck",  body.bQANeedCheck),
                            new SqlParameter("@bQAUrgency",    body.bQAUrgency),
                            new SqlParameter("@bQAChecking",   body.bQAChecking),
                            new SqlParameter("@bQAChecked",    body.bQAChecked),
                            new SqlParameter("@cWhCode",       GetDBValue(body.cWhCode)),
                            new SqlParameter("@iQuantity",     body.iQuantity),
                            new SqlParameter("@iUnitPrice",    body.iUnitPrice),
                            new SqlParameter("@DHID",          GetDBValue(body.DHID)),
                            new SqlParameter("@iSum",          ConvertToDecimal(body.iSum)),
                            new SqlParameter("@iTaxRate",      body.iTaxRate),
                            new SqlParameter("@iTaxUnitPrice", body.iTaxUnitPrice),
                            new SqlParameter("@iTax",          body.iTax),
                            new SqlParameter("@iNatUnitPrice", body.iNatUnitPrice),
                            new SqlParameter("@iNatMoney",     body.iNatMoney),
                            new SqlParameter("@iNatTax",       body.iNatTax),
                            new SqlParameter("@iNatSum",       body.iNatSum),
                            new SqlParameter("@iNatDisCount",  body.iNatDisCount),
                            new SqlParameter("@iDisCount",     body.iDisCount),
                            new SqlParameter("@iQuotedPrice",  ConvertToDecimal(body.iQuotedPrice)),
                            new SqlParameter("@cInvName",      GetDBValue(body.cInvName)),
                            new SqlParameter("@KL",            body.KL),
                            new SqlParameter("@KL2",           body.KL2),
                            new SqlParameter("@iMoney",        body.iMoney),
                            new SqlParameter("@fSaleCost",     body.fSaleCost),
                            new SqlParameter("@fSalePrice",    body.fSalePrice),
                            new SqlParameter("@irowno",        body.iRowNo),
                            new SqlParameter("@cbSysBarCode",  body.cbSysBarCode),
                            new SqlParameter("@bReturnFlag",   DispatchListHead.bReturnFlag),
                            new SqlParameter("@cSOCode",       GetDBValue(DispatchListHead.cSOCode)),
                            new SqlParameter("@cBatch",        GetDBValue(body.cBatch)),
                            new SqlParameter("@cDefine28",     GetDBValue(body.cDefine28))
                        };
                        sqlList.Add(new ExecuteHelp()
                        {
                            SQL = bodySql, Parameters = bodyPara
                        });
                    }
                    // 执行SQL
                    int bodyCount = this.DB_SqlHelper.ExecuteNonQuery(sqlList);
                }
                catch (Exception ex)
                {
                    // 表体执行错误,表头也要回滚
                    DeleteDispatchList(DispatchListHead.cDLCode);

                    throw ex;
                }
            }
            else
            {
                throw new JRException("表头新增失败!");
            }

            return(DispatchListHeadID == null ? null : DispatchListHeadID.ToString());
        }
Esempio n. 5
0
        /// <summary>
        /// 新增退货单
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="PlainPassword"></param>
        /// <param name="StrAccID"></param>
        /// <param name="AccYear"></param>
        /// <param name="Act"></param>
        /// <param name="Kind">0:普通销售 1:委托代销</param>
        /// <param name="entity"></param>
        /// <param name="success"></param>
        /// <returns></returns>
        public string AddDispatchList(string UserCode, string PlainPassword,
                                      string StrAccID, int AccYear, string Act, int Kind, EntityDispatchListHead entity, out int success)
        {
            success = 0;

            DispatchListBll bll = new DispatchListBll(StrAccID, AccYear, UserCode, PlainPassword);

            // 必填项验证
            string msg = "";

            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }
            foreach (EntityDispatchListBody entitybody in entity.Details)
            {
                if (!entity.CheckEntity(out msg))
                {
                    return(msg);
                }
            }
            #region 验证

            if (bll.GetGlmendFlag(entity.dDate.Year, entity.dDate.Month, "bflag_SA") == true)
            {
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cDLCode));
            }

            // 客户编号
            string cusName = bll.GetCustomerName(entity.cCusCode);

            if (string.IsNullOrWhiteSpace(cusName))
            {
                return(string.Format("U8中不存在客户编号:{0}!", entity.cCusCode));
            }
            entity.cCusName = cusName;

            // 部门
            string deptName = bll.GetDepartmentName(entity.cDepCode);
            if (string.IsNullOrWhiteSpace(deptName))
            {
                return(string.Format("U8中不存在部门编码:{0},或者部门编码非末级!", entity.cDepCode));
            }
            //销售类型
            if (string.IsNullOrWhiteSpace(GetStName(entity.cSTCode)))
            {
                return(string.Format("U8中不存在销售类型编码:{0}!", entity.cSTCode));
            }

            if (GetDispatchList(entity.cDLCode) != 0)
            {
                return(string.Format("U8中已存在该退货单号{0}!", entity.cDLCode));
            }

            #endregion

            if (entity.Details == null || entity.Details.Count == 0)
            {
                return("表体中存货信息不能为空,至少要有一条记录!");
            }

            var inventorys = GetInventorys("'" + string.Join("','", entity.Details.Select(p => p.cInvCode).Distinct()) + "'");

            for (int i = 0; i < entity.Details.Count; i++)
            {
                EntityDispatchListBody body = entity.Details[i];

                #region 验证单据明细
                var invInfo = inventorys.FirstOrDefault(p => p.cInvCode == body.cInvCode);
                // 存货编号
                string invName = bll.GetInventoryName(body.cInvCode);
                if (invInfo == null)
                {
                    return(string.Format("U8中不存在存货编码:{0}!", body.cInvCode));
                }

                if (body.iQuantity > 0)
                {
                    return("退货数量不能大于0!");
                }

                if (body.iQuantity != 0 && body.iSum > 0)
                {
                    return("退货单价税合计不能大于0");
                }
                if (!string.IsNullOrWhiteSpace(body.cBatch) && bll.GetInventoryName(body.cInvCode, 4) == "0")
                {
                    return(string.Format("U8中存货编码:{0}未启用批次管理,批次信息必须为空!", body.cInvCode));
                }
                if (string.IsNullOrWhiteSpace(body.cBatch) && bll.GetInventoryName(body.cInvCode, 4) == "1")
                {
                    body.cBatch = bll.GetInvBatch(body.cWhCode, body.cInvCode);
                    if (string.IsNullOrWhiteSpace(body.cBatch))
                    {
                        return(string.Format("U8中存货编码:{0}启用批次管理,批次信息不能为空!", body.cInvCode));
                    }
                }
                body.cInvName = invName;
                int bInvType = GetbInvType(body.cInvCode);
                if (body.iQuantity == 0 && bInvType == 0)
                {
                    return(string.Format("非折扣属性商品发货数量不能等于0"));
                }

                #endregion

                #region 单据明细计算
                body.bcosting = 1;//标志 是否记账
                if (bInvType == 1)
                {
                    body.cWhCode = null; body.bcosting = 0; body.iQuantity = 0; body.iQuotedPrice = 0;
                }
                body.iRowNo = (i + 1);
                body.KL     = 100;
                //当数量为正数时,求其绝对值转换为负数
                if (body.iQuantity > 0)
                {
                    body.iQuantity = -body.iQuantity;
                }
                body.bSettleAll   = 0; //结算标志
                body.bQAChecked   = 0; //是否报险
                body.bQAUrgency   = 0; //是否急料
                body.bQAChecking  = 0; //是否再检
                body.bQAChecked   = 0; //是否报险
                body.bQANeedCheck = 0; //是否质检
                decimal isum = body.iSum.HasValue ? body.iSum.Value : 0;
                body.cbSysBarCode  = string.Format("||SA03|{0}|{1}", entity.cDLCode, body.iRowNo);
                body.iTaxUnitPrice = body.iQuantity == 0 ? 0 : isum / body.iQuantity;
                body.iUnitPrice    = body.iQuantity == 0 ? 0 : Math.Round(body.iTaxUnitPrice / ((body.iTaxRate / 100) + 1), 2);
                body.iMoney        = Math.Round(isum / ((body.iTaxRate / 100) + 1), 2);
                body.iTax          = isum - body.iMoney;
                body.KL2           = body.iQuotedPrice == 0 || !body.iQuotedPrice.HasValue ? 100 : (isum / (body.iQuotedPrice.Value * body.iQuantity)) * 100;
                body.fSaleCost     = body.fSaleCost != 0 ? body.fSaleCost : bll.GetSA_InvPrice(body.cInvCode);
                body.fSalePrice    = body.fSaleCost * body.iQuantity;
                body.iDisCount     = body.iQuotedPrice == 0 || !body.iQuotedPrice.HasValue ? 0 : body.iQuotedPrice.Value * body.iQuantity - isum;
                body.iNatMoney     = body.iMoney;
                body.iNatSum       = isum;
                body.iNatTax       = body.iTax;
                body.iNatUnitPrice = body.iUnitPrice;
                body.iNatDisCount  = body.iDisCount;

                #endregion
            }
            //设置默认值
            entity.bFirst      = 0;                           //销售期初标志
            entity.bReturnFlag = 1;                           //退货标志
            entity.bSettleAll  = 0;                           //结算标志
            entity.iExchRate   = 1;                           //汇率
            entity.cBusType    = Kind == 0 ? "普通销售" : "委托代销"; // 业务类型
            entity.cexch_name  = "人民币";                       //币种名称
            entity.cVouchType  = Kind == 0 ? "05" : "06";     //单据类型编码
            entity.iVTid       = Kind == 0 ? 75 : 51;         //单据模板号
            entity.cSysBarCode = Kind == 0 ? string.Format("||SA03|{0}", entity.cDLCode) : string.Format("||SA54|{0}", entity.cDLCode);
            entity.cMaker      = bll.GetUserName(UserCode);

            string id = string.Empty;
            id      = bll.InsertDispatchList(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;
            return(id);
        }
Esempio n. 6
0
        public string AddModels(string UserCode, string CipherPassword, int ModelType,
                                string StrAccID, string Act, string Entity)
        {
            //Entity = System.Web.HttpUtility.UrlDecode(Entity);
            string plainPassword = DefineEncryptDecrypt.Decrypt(CipherPassword);
            int    AccYear       = U8BllBase.GetBeginYear(StrAccID);

            if (AccYear == 0)
            {
                return(ControllerHelp.GetReturnStr(0, string.Format("没有找到账套号:{0}", StrAccID)));
            }
            int        success = 0;
            ModelsType mt      = (ModelsType)ModelType;

            switch (mt)
            {
            case ModelsType.Sale:     // 销售订单
                lock (SaleLock)
                {
                    if (Act == "add")
                    {
                        EntitySaleHead entity = JsonConvert.DeserializeObject <EntitySaleHead>(Entity);
                        SoMainBll      bll    = new SoMainBll(StrAccID, AccYear, UserCode, plainPassword);
                        var            result = bll.AddSale(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.RdRecord09:     // 配送出库单(其他出库单)
                lock (RdRecord09Lock)
                {
                    if (Act == "add")
                    {
                        EntityRdRecord09Head entity = JsonConvert.DeserializeObject <EntityRdRecord09Head>(Entity);
                        RdRecord09Bll        bll    = new RdRecord09Bll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddRdRecord09(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.DispatchList1:    //销售退货单
            case ModelsType.DispatchList4:    //委托代销退货单
                lock (DispatchList1Lock)
                {
                    if (Act == "add")
                    {
                        EntityDispatchListHead entity = JsonConvert.DeserializeObject <EntityDispatchListHead>(Entity);
                        DispatchListBll        bll    = new DispatchListBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddDispatchList(UserCode, plainPassword, StrAccID, AccYear, Act, ModelsType.DispatchList1 == mt ? 0 : 1, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.DispatchList2:    //销售发货单
            case ModelsType.DispatchList3:    //委托代销发货单
                lock (DispatchList2Lock)
                {
                    if (Act == "add")
                    {
                        EntityDispatchListHead entity = JsonConvert.DeserializeObject <EntityDispatchListHead>(Entity);
                        DispatchListBll        bll    = new DispatchListBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddDispatchList(UserCode, plainPassword, ModelType, StrAccID, AccYear, Act, ModelsType.DispatchList2 == mt ? 0 : 1, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.Ap_CloseBill:    //收款单
                lock (Ap_CloseBillLock)
                {
                    if (Act == "add")
                    {
                        EntityAp_CloseBillHead entity = JsonConvert.DeserializeObject <EntityAp_CloseBillHead>(Entity);
                        Ap_CloseBillBll        bll    = new Ap_CloseBillBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddAp_CloseBill(UserCode, plainPassword, StrAccID, AccYear, Act, ModelType, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.Ap_Vouch:    //其他应付款
                lock (Ap_VouchLock)
                {
                    if (Act == "add")
                    {
                        EntityAp_VouchHead entity = JsonConvert.DeserializeObject <EntityAp_VouchHead>(Entity);
                        Ap_VouchBll        bll    = new Ap_VouchBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddAp_Vouch(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.PO_Pomain:    //采购订单
                lock (PO_PomainLock)
                {
                    if (Act == "add")
                    {
                        EntityPO_Pomain entity = JsonConvert.DeserializeObject <EntityPO_Pomain>(Entity);
                        PO_PomainBll    bll    = new PO_PomainBll(StrAccID, AccYear, UserCode, plainPassword);
                        var             result = bll.AddPO_Pomain(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.RdRecord01:    //采购入库单
                lock (RdRecord01Lock)
                {
                    if (Act == "add")
                    {
                        EntityRdRecord01Head entity = JsonConvert.DeserializeObject <EntityRdRecord01Head>(Entity);
                        RdRecord01Bll        bll    = new RdRecord01Bll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddRdRecord01(UserCode, plainPassword, StrAccID, AccYear, Act, 0, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.PayAp_CloseBill:     //付款单
                lock (PayAp_CloseBillLock)
                {
                    if (Act == "add")
                    {
                        EntityAp_CloseBillHead entity = JsonConvert.DeserializeObject <EntityAp_CloseBillHead>(Entity);
                        Ap_CloseBillBll        bll    = new Ap_CloseBillBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddAp_CloseBill(UserCode, plainPassword, StrAccID, AccYear, Act, ModelType, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.ST_AppTransVouch:     //调拨申请单
                lock (ST_AppTransVouchLock)
                {
                    if (Act == "add")
                    {
                        EntityST_AppTransVouch entity = JsonConvert.DeserializeObject <EntityST_AppTransVouch>(Entity);
                        ST_AppTransVouchBll    bll    = new ST_AppTransVouchBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddST_AppTransVouch(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.TransVouch:     //调拨单
                lock (TransVouchLock)
                {
                    if (Act == "add")
                    {
                        EntityTransVouch entity = JsonConvert.DeserializeObject <EntityTransVouch>(Entity);
                        TransVouchBll    bll    = new TransVouchBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddTransVouch(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.Vendor:     //供应商
                lock (VendorLock)
                {
                    if (Act == "add")
                    {
                        EntityVendor entity = JsonConvert.DeserializeObject <EntityVendor>(Entity);
                        VendorBll    bll    = new VendorBll(StrAccID, AccYear, UserCode, plainPassword);
                        var          result = bll.AddVendor(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.CheckVouch:     //盘点单
                lock (VendorLock)
                {
                    if (Act == "add")
                    {
                        EntityCheckVouchHead entity = JsonConvert.DeserializeObject <EntityCheckVouchHead>(Entity);
                        CheckVouchBll        bll    = new CheckVouchBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddCheckVouch(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.InventoryClass:     //存货分类
                lock (InventoryClassLock)
                {
                    if (Act == "add")
                    {
                        EntityInventoryClass entity = JsonConvert.DeserializeObject <EntityInventoryClass>(Entity);
                        InventoryClassBll    bll    = new InventoryClassBll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddInventoryClass(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.Inventory:     //存货档案
                lock (InventoryLock)
                {
                    if (Act == "add")
                    {
                        EntityInventory entity = JsonConvert.DeserializeObject <EntityInventory>(Entity);
                        InventoryBll    bll    = new InventoryBll(StrAccID, AccYear, UserCode, plainPassword);
                        var             result = bll.AddInventory(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.WareHouse:     //仓库档案
                lock (WareHouseLock)
                {
                    if (Act == "add")
                    {
                        EntityWareHouse entity = JsonConvert.DeserializeObject <EntityWareHouse>(Entity);
                        WareHouseBll    bll    = new WareHouseBll(StrAccID, AccYear, UserCode, plainPassword);
                        var             result = bll.AddWareHouse(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.Customer:     //客户档案
                lock (CustomerLock)
                {
                    if (Act == "add")
                    {
                        EntityCustomer entity = JsonConvert.DeserializeObject <EntityCustomer>(Entity);
                        CustomerBll    bll    = new CustomerBll(StrAccID, AccYear, UserCode, plainPassword);
                        var            result = bll.AddCustomer(UserCode, plainPassword, StrAccID, AccYear, Act, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }

            case ModelsType.RdRecord01T:    //红字采购入库单
                lock (RdRecord01TLock)
                {
                    if (Act == "add")
                    {
                        EntityRdRecord01Head entity = JsonConvert.DeserializeObject <EntityRdRecord01Head>(Entity);
                        RdRecord01Bll        bll    = new RdRecord01Bll(StrAccID, AccYear, UserCode, plainPassword);
                        var result = bll.AddRdRecord01(UserCode, plainPassword, StrAccID, AccYear, Act, 1, entity, out success);
                        return(ControllerHelp.GetReturnStr(success, StrAccID + '_' + result));
                    }
                    break;
                }
            }

            return(ControllerHelp.GetReturnStr(0, "AddModels中没有找到可对应的操作项"));
        }
Esempio n. 7
0
        public string GetModels(string UserCode, string CipherPassword, int ModelType,
                                string StrAccID, string Act, string Entity, string dModifyDate)
        {
            //Entity = System.Web.HttpUtility.UrlDecode(Entity);
            string plainPassword = DefineEncryptDecrypt.Decrypt(CipherPassword);
            int    AccYear       = U8BllBase.GetBeginYear(StrAccID);

            if (AccYear == 0)
            {
                return(ControllerHelp.GetReturnStr(0, string.Format("没有找到账套号{0}", StrAccID)));
            }
            ModelsType mt  = (ModelsType)ModelType;
            string     msg = "";

            switch (mt)
            {
            case ModelsType.CurrentStock:     // 库存量查询
                if (Act == "get")
                {
                    EntityCurrentStock        entity = JsonConvert.DeserializeObject <EntityCurrentStock>(Entity);
                    CurrentStockBll           bll    = new CurrentStockBll(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntityCurrentStock> list   = bll.GetCurrentStock(entity, out msg);
                    return(ControllerHelp.GetReturnStr(string.IsNullOrWhiteSpace(msg) ? 1 : 0, "", list));
                }
                break;

            case ModelsType.Sale:     // 查询销售订单是否存在 1表示不存在,2表示存在
                if (Act == "query")
                {
                    SoMainBll      bll    = new SoMainBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntitySaleHead entity = JsonConvert.DeserializeObject <EntitySaleHead>(Entity);
                    int            num    = bll.QuerySale(entity.cSOCode);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.DispatchList1:     //退货单 1表示不存在,2表示存在
                if (Act == "query")
                {
                    DispatchListBll        bll    = new DispatchListBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityDispatchListHead entity = JsonConvert.DeserializeObject <EntityDispatchListHead>(Entity);
                    int num = bll.QueryDispatchList(entity.cDLCode);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.DispatchList2:     //发货单 1表示不存在,2表示存在
                if (Act == "query")
                {
                    DispatchListBll        bll    = new DispatchListBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityDispatchListHead entity = JsonConvert.DeserializeObject <EntityDispatchListHead>(Entity);
                    int num = bll.QueryDispatchList(entity.cDLCode);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.RdRecord09:     // 配送出库单(其他出库单) 1表示不存在,2表示存在
                if (Act == "query")
                {
                    RdRecord09Bll        bll    = new RdRecord09Bll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityRdRecord09Head entity = JsonConvert.DeserializeObject <EntityRdRecord09Head>(Entity);
                    int num = bll.QueryRdRecord09(entity.cCode);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.Ap_CloseBill:     //收款单(汇款通知单)1表示不存在,2表示存在
                if (Act == "query")
                {
                    Ap_CloseBillBll        bll    = new Ap_CloseBillBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityAp_CloseBillHead entity = JsonConvert.DeserializeObject <EntityAp_CloseBillHead>(Entity);
                    int num = bll.QueryAp_CloseBill(entity.cVouchID);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.PayAp_CloseBill:     //付款单(汇款通知单)1表示不存在,2表示存在
                if (Act == "query")
                {
                    Ap_CloseBillBll        bll    = new Ap_CloseBillBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityAp_CloseBillHead entity = JsonConvert.DeserializeObject <EntityAp_CloseBillHead>(Entity);
                    int num = bll.QueryAp_CloseBill(entity.cVouchID);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.ReturnAnalysis:     //退货分析表查询
                if (Act == "get")
                {
                    ReturnAnalysisBll                 bll    = new ReturnAnalysisBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityReturnAnalysisRQC           entity = JsonConvert.DeserializeObject <EntityReturnAnalysisRQC>(Entity);
                    List <EntityReturnAnalysisReport> list   = bll.GetReturnAnalysis(entity);
                    return(ControllerHelp.GetReturnStr(1, "", list));
                }
                break;

            case ModelsType.Customer:    //客户档案
                if (Act == "get")
                {
                    U8BllBase             bll      = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    EntityCustomer        entity   = JsonConvert.DeserializeObject <EntityCustomer>(Entity);
                    List <EntityCustomer> customer = bll.GetCustomer(entity.cCusCode);
                    return(ControllerHelp.GetReturnStr(1, "", customer));
                }
                break;

            case ModelsType.Vendor:    //供应商档案
                if (Act == "get")
                {
                    U8BllBase           bll    = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntityVendor> vendor = bll.GetVendor();
                    return(ControllerHelp.GetReturnStr(1, "", vendor));
                }
                break;

            case ModelsType.PurchaseType:    //采购类型
                if (Act == "get")
                {
                    U8BllBase bll = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntityPurchaseType> purchasetype = bll.GetPurchaseType();
                    return(ControllerHelp.GetReturnStr(1, "", purchasetype));
                }
                break;

            case ModelsType.Inventory:    //存货档案
                if (Act == "get")
                {
                    U8BllBase bll = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntityInventory> inventory = new List <EntityInventory>();
                    if (string.IsNullOrWhiteSpace(dModifyDate))
                    {
                        inventory = bll.GetInventory();
                    }
                    else
                    {
                        inventory = bll.GetInventory(Convert.ToDateTime(dModifyDate));
                    }
                    return(ControllerHelp.GetReturnStr(1, "", inventory));
                }
                break;

            case ModelsType.WareHouse:    //仓库档案(入库仓库)
                if (Act == "get")
                {
                    U8BllBase bll = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntityWareHouse> warehouse = bll.GetWareHouse();
                    return(ControllerHelp.GetReturnStr(1, "", warehouse));
                }
                break;

            case ModelsType.rd_Style:    //入库类别档案
                if (Act == "get")
                {
                    U8BllBase             bll      = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <Entityrd_Style> rd_style = bll.Getrd_Style();
                    return(ControllerHelp.GetReturnStr(1, "", rd_style));
                }
                break;

            case ModelsType.SettleStyle:    //结算方式
                if (Act == "get")
                {
                    U8BllBase bll = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    List <EntitySettleStyle> settlestyle = bll.GetSettleStyle();
                    return(ControllerHelp.GetReturnStr(1, "", settlestyle));
                }
                break;

            case ModelsType.CustomerProperty:    //经营属性
                if (Act == "get")
                {
                    U8BllBase bll      = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                    string    cuscode  = Entity;
                    var       customer = bll.GetCustomerProperty(cuscode);
                    return(ControllerHelp.GetReturnStr(1, "", customer));
                }
                break;

            case ModelsType.InventoryPrice:    //存货入库含税单价
                if (Act == "get")
                {
                    if (!string.IsNullOrWhiteSpace(Entity))
                    {
                        U8BllBase            bll    = new U8BllBase(StrAccID, AccYear, UserCode, plainPassword);
                        EntityInventoryPrice entity = JsonConvert.DeserializeObject <EntityInventoryPrice>(Entity);
                        var inventoryPrice          = bll.GetInventoryPrice(entity.cVenCode, entity.cInvCode);
                        return(ControllerHelp.GetReturnStr(1, "", inventoryPrice));
                    }
                }
                break;

            case ModelsType.PO_Pomain:     //采购订单
                if (Act == "query")
                {
                    PO_PomainBll    bll    = new PO_PomainBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityPO_Pomain entity = JsonConvert.DeserializeObject <EntityPO_Pomain>(Entity);
                    int             num    = bll.GetPO_Pomain(entity.cPOID);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.RdRecord01:     //采购入库单
                if (Act == "query")
                {
                    RdRecord01Bll        bll    = new RdRecord01Bll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityRdRecord01Head entity = JsonConvert.DeserializeObject <EntityRdRecord01Head>(Entity);
                    int num = bll.GetRdRecord01(entity.cCode);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;

            case ModelsType.Ap_Vouch:     //其他应付单
                if (Act == "query")
                {
                    Ap_VouchBll        bll    = new Ap_VouchBll(StrAccID, AccYear, UserCode, plainPassword);
                    EntityAp_VouchHead entity = JsonConvert.DeserializeObject <EntityAp_VouchHead>(Entity);
                    int num = bll.GetAp_Vouch(entity.cVouchID);
                    if (num == 0)
                    {
                        return(ControllerHelp.GetReturnStr(1, "new"));
                    }
                    else
                    {
                        return(ControllerHelp.GetReturnStr(2, "old"));
                    }
                }
                break;
            }

            return(ControllerHelp.GetReturnStr(0, "GetModels(查询)中没有找到可对应的操作项"));
        }