コード例 #1
0
ファイル: Form1.cs プロジェクト: Core130/jr
        private void bt_getapvouch_Click(object sender, EventArgs e)
        {
            EntityAp_VouchHead doc = new EntityAp_VouchHead();

            doc.cVouchID  = tx_cCode.Text == "" ? "1" : tx_cCode.Text;
            textBox1.Text = QueryCode(8011, JsonConvert.SerializeObject(doc));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Core130/jr
        private void bt_apvouch_Click(object sender, EventArgs e)
        {
            EntityAp_VouchHead doc = new EntityAp_VouchHead();

            doc.cVouchID   = "PL00820161100006";
            doc.dVouchDate = DateTime.Parse("2018-04-09");
            doc.cDwCode    = "SZ0053";
            doc.iAmount_f  = 888;
            doc.cDigest    = "234";
            List <EntityAp_VouchBody> list = new List <EntityAp_VouchBody>();

            list.Add(new EntityAp_VouchBody
            {
                iAmount_f = 888,
                cCode     = "1801",
                cDigest   = "123",
            }
                     );
            doc.Details = list;
            string entity = JsonConvert.SerializeObject(doc);

            string postUrl = string.Format(@"{0}={1}&ModelType=8011", addpara, entity);
            string result  = SendHttpRequest(addurl, postUrl, "POST");

            textBox1.Text = result;
        }
コード例 #3
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中没有找到可对应的操作项"));
        }
コード例 #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(查询)中没有找到可对应的操作项"));
        }
コード例 #5
0
ファイル: Ap_VouchBll.cs プロジェクト: Core130/jr
        /// <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 AddAp_Vouch(string UserCode, string PlainPassword,
                                  string StrAccID, int AccYear, string Act, EntityAp_VouchHead entity, out int success)
        {
            success = 0;
            Ap_VouchBll bll = new Ap_VouchBll(StrAccID, AccYear, UserCode, PlainPassword);

            #region 验证
            // 必填项验证
            string msg = "";
            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }
            foreach (EntityAp_VouchBody entitybody in entity.Details)
            {
                if (!entitybody.CheckEntity(out msg))
                {
                    return(msg);
                }
            }

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

            if (!string.IsNullOrEmpty(entity.cDwCode))
            {
                string vendorname = bll.GetVendorName(entity.cDwCode);
                if (string.IsNullOrEmpty(vendorname))
                {
                    return(string.Format("U8中不存在供应商编号:{0}!", entity.cDwCode));
                }
            }

            #endregion
            #region 表头
            entity.cLink       = "P0" + entity.cVouchID;
            entity.cVouchType  = "P0";
            entity.cexch_name  = entity.cexch_name == null ? "人民币" : entity.cexch_name;//币种名称
            entity.iRAmount    = entity.iAmount_f;
            entity.iAmount     = entity.iAmount_f;
            entity.iRAmount_f  = entity.iAmount_f;
            entity.cFlag       = "AP"; // 应收应付标志 AP为应付,AR为应收
            entity.VT_ID       = 8056; // 单据模板号
            entity.iClosesID   = 0;
            entity.iCoClosesID = 0;
            entity.iExchRate   = 1;
            entity.bd_c        = 0;
            entity.cOperator   = entity.cOperator == null?bll.GetUserName(UserCode) : entity.cOperator;

            entity.cSysBarCode = string.Format("||app0|{0}", entity.cVouchID);

            #endregion
            //表体
            foreach (EntityAp_VouchBody item in entity.Details)
            {
                if (!string.IsNullOrWhiteSpace(item.cCode))
                {
                    string cCode = GetcCode(item.cCode, entity.dVouchDate.Year);
                    if (string.IsNullOrWhiteSpace(cCode))
                    {
                        return(string.Format("U8中不存在科目编码:{0},或者非末级科目!", item.cCode));
                    }
                }
                item.cDwCode    = entity.cDwCode;
                item.iAmount    = item.iAmount_f;
                item.iExchRate  = entity.iExchRate;
                item.cLink      = entity.cLink;
                item.cexch_name = entity.cexch_name;
            }
            string id = bll.InsertAp_Vouch(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;
            return(id);
        }
コード例 #6
0
ファイル: Ap_VouchBll.cs プロジェクト: Core130/jr
        public string InsertAp_Vouch(EntityAp_VouchHead Ap_VouchHead)
        {
            string Ap_VouchHeadID = string.Empty;

            if (Ap_VouchHead == null)
            {
                throw new JRException("其他应付单新增失败!没有数据!");
            }
            #region 验证
            int num = GetAp_Vouch(Ap_VouchHead.cVouchID);
            if (num > 0)
            {
                throw new JRException(string.Format("单号为:{0}已经生成其他应付单!", Ap_VouchHead.cVouchID));
            }
            #endregion

            int detailCount = Ap_VouchHead.Details.Count;

            int head_id     = 0;
            int body_end_Id = 0;
            GetId("00", "RP", detailCount, out head_id, out body_end_Id);
            //int autoid = GetAutoID() + 1;
            string         sql  = string.Format(@"insert into Ap_Vouch(cLink,cVouchType,cVouchID,dVouchDate,cDwCode,cexch_name,
                                         iRAmount,iAmount,iAmount_f,iRAmount_f,cFlag,VT_ID,iClosesID,
                                         iCoClosesID,iExchRate,bd_c,cOperator,dcreatesystime,Auto_ID,cSysBarCode,cDigest)
                                         values
                                         (@cLink,@cVouchType,@cVouchID,@dVouchDate,@cDwCode,@cexch_name,
                                         @iRAmount,@iAmount,@iAmount_f,@iRAmount_f,@cFlag,@VT_ID,@iClosesID,
                                         @iCoClosesID,@iExchRate,@bd_c,@cOperator,@dcreatesystime,@Auto_ID,@cSysBarCode,@cDigest)");
            SqlParameter[] para =
            {
                new SqlParameter("@cLink",          Ap_VouchHead.cLink),
                new SqlParameter("@cVouchType",     Ap_VouchHead.cVouchType),
                new SqlParameter("@cVouchID",       Ap_VouchHead.cVouchID),
                new SqlParameter("@dVouchDate",     Ap_VouchHead.dVouchDate.ToShortDateString()),
                new SqlParameter("@cDwCode",        Ap_VouchHead.cDwCode),
                new SqlParameter("@cexch_name",     Ap_VouchHead.cexch_name),
                new SqlParameter("@iRAmount",       Ap_VouchHead.iRAmount),
                new SqlParameter("@iAmount",        Ap_VouchHead.iAmount),
                new SqlParameter("@iAmount_f",      Ap_VouchHead.iAmount_f),
                new SqlParameter("@iRAmount_f",     Ap_VouchHead.iRAmount_f),
                new SqlParameter("@cFlag",          Ap_VouchHead.cFlag),
                new SqlParameter("@VT_ID",          Ap_VouchHead.VT_ID),
                new SqlParameter("@iClosesID",      Ap_VouchHead.iClosesID),
                new SqlParameter("@iCoClosesID",    Ap_VouchHead.iCoClosesID),
                new SqlParameter("@iExchRate",      Ap_VouchHead.iExchRate),
                new SqlParameter("@bd_c",           Ap_VouchHead.bd_c),
                new SqlParameter("@cOperator",      Ap_VouchHead.cOperator),
                new SqlParameter("@dcreatesystime", DateTime.Now),
                new SqlParameter("@Auto_ID",        head_id),
                new SqlParameter("@cSysBarCode",    Ap_VouchHead.cSysBarCode),
                new SqlParameter("@cDigest",        GetDBValue(Ap_VouchHead.cDigest)),
            };
            int headCount = this.DB_SqlHelper.ExecuteNonQuery(sql, para);
            if (headCount > 0)
            {
                try
                {
                    List <ExecuteHelp> sqlList = new List <ExecuteHelp>();
                    Ap_VouchHeadID = GetAp_VouchHeadID(Ap_VouchHead.cVouchID);
                    if (Ap_VouchHeadID == null)
                    {
                        throw new JRException("其他应付单表头新增失败!");
                    }
                    for (int i = 0; i < detailCount; i++)
                    {
                        EntityAp_VouchBody body     = Ap_VouchHead.Details[i];
                        string             bodySql  = string.Format(@"insert into Ap_Vouchs(cLink,cexch_name,cDwCode,iExchRate,bd_c,iAmount,iAmount_f,cDigest,cCode)
                                                 values
                                                 (@cLink,@cexch_name,@cDwCode,@iExchRate,@bd_c,@iAmount,@iAmount_f,@cDigest,@cCode)");
                        SqlParameter[]     bodyPara =
                        {
                            new SqlParameter("@cLink",      body.cLink),
                            new SqlParameter("@cexch_name", body.cexch_name),
                            new SqlParameter("@cDwCode",    body.cDwCode),
                            new SqlParameter("@iExchRate",  body.iExchRate),
                            new SqlParameter("@bd_c",                              1),
                            new SqlParameter("@iAmount",    body.iAmount),
                            new SqlParameter("@iAmount_f",  body.iAmount_f),
                            new SqlParameter("@cDigest",    GetDBValue(body.cDigest)),
                            new SqlParameter("@cCode",      GetDBValue(body.cCode)),
                        };
                        sqlList.Add(new ExecuteHelp()
                        {
                            SQL = bodySql, Parameters = bodyPara
                        });
                    }

                    int bodyCount = this.DB_SqlHelper.ExecuteNonQuery(sqlList);
                }
                catch (Exception ex)
                {
                    DeleteAp_Vouch(Ap_VouchHead.cVouchID);
                    throw ex;
                }
            }
            else
            {
                throw new JRException("其他应付单表头新增失败!");
            }
            return(Ap_VouchHeadID == null ? null : Ap_VouchHeadID.ToString());
        }