Esempio n. 1
0
        /// <summary>
        /// 库存量查询
        /// </summary>
        /// <param name="cInvCode"></param>
        /// <param name="cWhCode"></param>
        /// <returns></returns>
        public List <EntityCurrentStock> GetCurrentStock(EntityCurrentStock entity, out string msg)
        {
            msg = "";
            List <EntityCurrentStock> list = new List <EntityCurrentStock>();

            if (string.IsNullOrEmpty(entity.cInvCode) && string.IsNullOrEmpty(entity.cWhCode))
            {
                msg = "参数传递有误!存货编号和仓库编号不能同时为空";
                return(list);
            }

            string sql = @"select I.cInvCode,cWhCode,cBatch,(CASE WHEN bInvBatch=1 THEN  CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE 
                            ISNULL(iQuantity,0)- IsNull(fStopQuantity,0) END  + ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) ELSE  
                            CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0)- IsNull(fStopQuantity,0) END  + 
                            ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) END) AS iQuantity 
                            from v_ST_currentstockForReport  CS inner join dbo.Inventory I ON I.cInvCode = CS.cInvCode  where 1= 1";

            if (!string.IsNullOrWhiteSpace(entity.cInvCode))
            {
                //sql += string.Format(" and cInvCode = '{0}'", entity.cInvCode);
                sql += string.Format(" and I.cInvCode in ('{0}')", entity.cInvCode.Replace(",", "','"));
            }
            if (!string.IsNullOrWhiteSpace(entity.cWhCode))
            {
                //sql += string.Format(" and cWhCode = '{0}'" ,entity.cWhCode);
                sql += string.Format(" and cWhCode in ('{0}')", entity.cWhCode.Replace(",", "','"));
            }

            SqlDataReader datareader = DB_SqlHelper.ExecuteReader(CommandType.Text, sql, null);

            while (datareader.Read())
            {
                EntityCurrentStock ecs = new EntityCurrentStock();
                ecs.cInvCode  = datareader["cInvCode"].ToString();
                ecs.cWhCode   = datareader["cWhCode"].ToString();
                ecs.cBatch    = datareader["cBatch"].ToString();
                ecs.iQuantity = Convert.ToInt32(datareader["iQuantity"]);
                list.Add(ecs);
            }
            return(list);
        }
Esempio n. 2
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>
        /// <returns></returns>
        public string AddCheckVouch(string UserCode, string PlainPassword,
                                    string StrAccID, int AccYear, string Act, EntityCheckVouchHead entity, out int success)
        {
            success = 0;
            CheckVouchBll bll = new CheckVouchBll(StrAccID, AccYear, UserCode, PlainPassword);

            #region 验证

            // 字段必填项验证
            string msg = "";
            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }

            foreach (EntityCheckVouchBody entitybody in entity.Details)
            {
                if (!entitybody.CheckEntity(out msg))
                {
                    return(msg);
                }
            }
            if (bll.GetGlmendFlag(entity.dCVDate.Year, entity.dCVDate.Month, "bflag_ST") == true)
            {
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cCVCode));
            }
            // 仓库
            string warehouseName = GetWarehouseName(entity.cWhCode);
            if (string.IsNullOrWhiteSpace(warehouseName))
            {
                return(string.Format("U8中不存在仓库编码:{0}!", entity.cWhCode));
            }
            entity.cORdCode = GetRdCode(18, 0);
            entity.cIRdCode = GetRdCode(18, 1);
            // 出库类别编码
            if (string.IsNullOrWhiteSpace(entity.cORdCode) || string.IsNullOrWhiteSpace(GetRdStyleName(entity.cORdCode)))
            {
                return(string.Format("U8中不存在收发类别编码:{0}!", entity.cORdCode));
            }
            // 入库类别编码
            if (string.IsNullOrWhiteSpace(entity.cIRdCode) && string.IsNullOrWhiteSpace(GetRdStyleName(entity.cIRdCode, 1)))
            {
                return(string.Format("U8中不存在收发类别编码:{0}!", entity.cIRdCode));
            }
            #endregion

            entity.cSysbarCode = "||st18|" + entity.cCVCode;
            //获取存货档案信息
            var inventorys = GetInventorys("'" + string.Join("','", entity.Details.Select(p => p.cInvCode).Distinct()) + "'");
            //获取库存信息
            EntityCurrentStock xclEntity = new EntityCurrentStock();
            xclEntity.cWhCode  = entity.cWhCode;
            xclEntity.cInvCode = string.Join(",", entity.Details.Select(p => p.cInvCode).Distinct());
            CurrentStockBll csBll  = new CurrentStockBll(StrAccID, AccYear, UserCode, PlainPassword);
            var             csData = csBll.GetCurrentStock(xclEntity, out msg);

            for (int i = 0; i < entity.Details.Count; i++)
            {
                EntityCheckVouchBody body = entity.Details[i];
                #region 验证单据明细

                var invInfo = inventorys.FirstOrDefault(p => p.cInvCode == body.cInvCode);
                // 存货编号
                if (invInfo == null)
                {
                    return(string.Format("U8中不存在存货编码:{0}!", body.cInvCode));
                }

                if (!string.IsNullOrWhiteSpace(body.cBatch) && invInfo.bInvBatch == "0")
                {
                    return(string.Format("U8中存货编码:{0}未启用批次管理,批次信息必须为空!", body.cInvCode));
                }
                if (string.IsNullOrWhiteSpace(body.cBatch) && invInfo.bInvBatch == "1")
                {
                    return(string.Format("U8中存货编码:{0}启用批次管理,批次信息不能为空!", body.cInvCode));
                }
                // int bInvType = GetbInvType(body.cInvCode);

                if (body.iCVCQuantity < 0)
                {
                    return(string.Format("盘点数量不能为小于0!"));
                }


                #endregion

                #region 明细栏目计算
                body.iCVQuantity    = csData.Where(p => p.cInvCode == body.cInvCode).Sum(p => p.iQuantity);
                body.iAdInQuantity  = 0;
                body.iAdOutQuantity = 0;
                body.iActualWaste   = 0; //盈亏比例%:=盈亏数量/账面调整数*100

                #endregion
            }

            // 设置默认值
            entity.cMaker = string.IsNullOrWhiteSpace(entity.cMaker) ? bll.GetUserName(UserCode) : entity.cMaker;

            string id = InsertCheckVouch(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;;
            return(id);
        }
Esempio n. 3
0
        /// <summary>
        /// 新增发货单
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="PlainPassword"></param>
        /// <param name="ModelType"></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, int ModelType,
                                      string StrAccID, int AccYear, string Act, int Kind, EntityDispatchListHead entity, out int success)
        {
            success = 0;
            DispatchListBll bll = new DispatchListBll(StrAccID, AccYear, UserCode, PlainPassword);

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

            #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("表体中存货信息不能为空,至少要有一条记录!");
            }


            // 必填项验证
            string msg = "";
            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }
            foreach (EntityDispatchListBody entitybody in entity.Details)
            {
                if (!entitybody.CheckEntity(out msg))
                {
                    return(msg);
                }
            }
            //获取存货档案信息
            var inventorys = GetInventorys("'" + string.Join("','", entity.Details.Select(p => p.cInvCode).Distinct()) + "'");
            //获取库存信息
            EntityCurrentStock xclEntity = new EntityCurrentStock();
            xclEntity.cWhCode  = string.Join(",", entity.Details.Select(p => p.cWhCode).Distinct());
            xclEntity.cInvCode = string.Join(",", entity.Details.Select(p => p.cInvCode).Distinct());
            CurrentStockBll csBll  = new CurrentStockBll(StrAccID, AccYear, UserCode, PlainPassword);
            var             csData = csBll.GetCurrentStock(xclEntity, out msg);

            for (int i = 0; i < entity.Details.Count; i++)
            {
                EntityDispatchListBody body = entity.Details[i];
                var invInfo = inventorys.FirstOrDefault(p => p.cInvCode == body.cInvCode);

                #region 验证

                // 存货编号
                if (invInfo == null)
                {
                    return(string.Format("U8中不存在存货编码:{0}!", body.cInvCode));
                }

                if (body.iQuantity < 0)
                {
                    return("发货数量不能小于0!");
                }

                if (body.iQuantity != 0 && body.iSum < 0)  //折扣类存货数量为0,金额为负数
                {
                    return("发货单价税合计不能小于0!");
                }
                if (!string.IsNullOrWhiteSpace(body.cBatch) && invInfo.bInvBatch == "0")
                {
                    return(string.Format("U8中存货编码:{0}未启用批次管理,批次信息必须为空!", body.cInvCode));
                }
                if (string.IsNullOrWhiteSpace(body.cBatch) && invInfo.bInvBatch == "1")
                {
                    body.cBatch = bll.GetInvBatch(body.cWhCode, body.cInvCode);
                    if (string.IsNullOrWhiteSpace(body.cBatch))
                    {
                        return(string.Format("U8中存货编码:{0}启用批次管理,批次信息不能为空!", body.cInvCode));
                    }
                }
                body.cInvName = invInfo.cInvName;
                int bInvType = Convert.ToInt32(invInfo.bInvType);
                if (body.iQuantity == 0 && invInfo.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;

                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("||SA01|{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
            }
            string id = string.Empty;
            if (!string.IsNullOrEmpty(entity.cSOCode))
            {
                int count = 0;
                count = GetSoMain(entity.cSOCode);
                if (count <= 0)
                {
                    return(string.Format("销售订单号{0}在U8中不存在!", entity.cSOCode));
                }
            }

            id      = bll.InsertDispatchList(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;
            return(id);
        }
Esempio n. 4
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(查询)中没有找到可对应的操作项"));
        }
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="entity"></param>
        /// <returns></returns>
        public string AddRdRecord09(string UserCode, string PlainPassword,
                                    string StrAccID, int AccYear, string Act, EntityRdRecord09Head entity, out int success)
        {
            success = 0;
            RdRecord09Bll bll = new RdRecord09Bll(StrAccID, AccYear, UserCode, PlainPassword);

            #region 验证
            // 字段必填项验证
            string msg = "";
            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }

            foreach (EntityRdRecord09Body entitybody in entity.Details)
            {
                if (!entitybody.CheckEntity(out msg))
                {
                    return(msg);
                }
            }

            if (bll.GetGlmendFlag(entity.dDate.Year, entity.dDate.Month, "bflag_ST") == true)
            {
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cCode));
            }
            // 部门
            string deptName = GetDepartmentName(entity.cDepCode);
            if (string.IsNullOrWhiteSpace(deptName))
            {
                return(string.Format("U8中不存在部门编码:{0},或者部门编码非末级!", entity.cDepCode));
            }
            entity.cDefine11 = deptName;

            // 仓库
            string warehouseName = bll.GetWarehouseName(entity.cWhCode);
            if (string.IsNullOrWhiteSpace(warehouseName))
            {
                return(string.Format("U8中不存在仓库编码:{0}!!", entity.cWhCode));
            }

            // 收发类别编码
            if (string.IsNullOrWhiteSpace(bll.GetRdStyleName(entity.cRdCode)))
            {
                return(string.Format("U8中不存在收发类别编码:{0}!", entity.cRdCode));
            }

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

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

            string msg1 = "";
            for (int i = 0; i < entity.Details.Count; i++)
            {
                EntityRdRecord09Body body = entity.Details[i];
                #region 验证单据明细
                // 存货编号
                string invName = bll.GetInventoryName(body.cInvCode);
                if (string.IsNullOrWhiteSpace(invName))
                {
                    return(string.Format("U8中不存在存货编码:{0}!", body.cInvCode));
                }
                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")
                {
                    return(string.Format("U8中存货编码:{0}启用批次管理,批次信息不能为空!", body.cInvCode));
                }
                ;
                if (body.iQuantity == 0)
                {
                    return(string.Format("U8中存货编码:{0}数量不能等于0!", body.cInvCode));
                }
                // 可用量验证

                EntityCurrentStock xclEntity = new EntityCurrentStock();
                xclEntity.cInvCode = body.cInvCode;
                xclEntity.cWhCode  = entity.cWhCode;
                CurrentStockBll csBll  = new CurrentStockBll(StrAccID, AccYear, UserCode, PlainPassword);
                var             csData = csBll.GetCurrentStock(xclEntity, out msg).Sum(p => p.iQuantity);
                if (csData < body.iQuantity)
                {
                    msg   = (string.Format("存货编码:{0}可用量不足,当前可用量为:{1};", body.cInvCode, csData));
                    msg1 += msg;
                }
                #endregion

                #region 明细栏目计算
                body.iUnitCost    = bll.GetInvSPrice(body.cInvCode);
                body.iAPrice      = body.iUnitCost * body.iQuantity;
                body.irowno       = (i + 1);
                body.cDefine22    = string.IsNullOrEmpty(body.cDefine22) ? bll.GetInventoryName(body.cInvCode, 2) : body.cDefine22;
                body.cDefine23    = string.IsNullOrEmpty(body.cDefine23) ? bll.GetInventoryName(body.cInvCode, 3) : body.cDefine23;
                body.cbsysbarcode = string.Format("||st09|{0}|{1}", entity.cCode, body.irowno);
                body.iFlag        = 0;//标志
                #endregion
            }
            if (msg1 != "")
            {
                return(msg1);
            }


            //设置默认值
            entity.bRdFlag     = 0;    //收发标志
            entity.blsSTQc     = 0;    //库存期初标志
            entity.cVouchType  = "09"; //单据类型编码
            entity.cSource     = "库存"; //单据来源
            entity.bTransFlag  = 0;    //是否传递
            entity.cMaker      = string.IsNullOrWhiteSpace(entity.cMaker) ? bll.GetUserName(UserCode) : entity.cMaker;
            entity.cBusType    = "其他出库";
            entity.VT_ID       = 85;
            entity.bOMFirst    = 0;
            entity.dnmaketime  = entity.dDate;
            entity.cDefine11   = cusName;
            entity.csysbarcode = string.Format("st09|{0}", entity.cCode);

            string id = bll.InsertRdRecord09(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;
            return(id);
        }