private void bt_TransVouch_Click(object sender, EventArgs e) { EntityTransVouch doc = new EntityTransVouch(); doc.cTvCode = "TSZ170700000001"; doc.dTvDate = DateTime.Parse("2017-7-01"); doc.cOutWhCode = "K001"; doc.cInWhCode = "HK005"; doc.cOutDepCode = "SZ110101"; doc.cInDepCode = "SZ110101"; doc.cCusCode = "0204001"; //doc.cOutRdCode = "20"; //doc.cInRdCode = "03"; doc.cMaker = ""; doc.cTvMemo = "测试接口"; List <EntityTransVouchBody> list = new List <EntityTransVouchBody>(); list.Add(new EntityTransVouchBody { cInvCode = "1020208009", iTvQuantity = 10, iTvaCost = 12, iTvaPrice = 120, cDefine26 = 118, cDefine27 = 1180 }); list.Add(new EntityTransVouchBody { cInvCode = "1020208010", iTvQuantity = 10, iTvaCost = 10, iTvaPrice = 100, cDefine26 = 128, cDefine27 = 1280 }); doc.Details = list; string entity = JsonConvert.SerializeObject(doc); string postUrl = string.Format(@"{0}={1}&ModelType=8021", addpara, entity); string result = SendHttpRequest(addurl, postUrl, "POST"); textBox1.Text = result; }
public string InsertTransVouch(EntityTransVouch Head) { // 得到主表ID和从表ID int detailCount = Head.Details.Count; int head_id = 0; int body_end_Id = 0; GetId("00", "tr", detailCount, out head_id, out body_end_Id); string cSysBarCode = "||st12|" + Head.cTvCode; string sql = string.Format(@" insert into TransVouch(ctvcode,dtvdate,cowhcode,ciwhcode,codepcode,cidepcode,cpersoncode,cirdcode,cordcode,ctvmemo,cdefine1,cdefine2,cdefine3,cdefine4,cdefine5, cdefine6,cdefine7,cdefine8,cdefine9,cdefine10,caccounter,cmaker,id,vt_id,cverifyperson,dverifydate,cpspcode,cmpocode,iquantity,btransflag,cdefine11,cdefine12, cdefine13,cdefine14,cdefine15,cdefine16,iproorderid,cordertype,ctranrequestcode,cversion,bomid,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10, csource,itransflag,cmodifyperson,dmodifydate,dnmaketime,dnmodifytime,dnverifytime,ireturncount,iverifystate,iswfcontrolled,cbustype,csourcecodels,iprintcount, csourceguid,csysbarcode,ccurrentauditor) Values (@ctvcode,@dtvdate,@cowhcode,@ciwhcode,@codepcode,@cidepcode,Null,@cirdcode,@cordcode,@ctvmemo,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,@cmaker, @id,89,Null,Null,Null,Null,0,Null,@cdefine11,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,N'1',N'正向',Null, Null,getdate(),Null ,Null ,Null,Null,0,Null,Null,0,Null,@csysbarcode,Null) "); SqlParameter[] para = { new SqlParameter("@ctvcode", Head.cTvCode), new SqlParameter("@dtvdate", Head.dTvDate.ToShortDateString()), new SqlParameter("@cowhcode", Head.cOutWhCode), new SqlParameter("@ciwhcode", Head.cInWhCode), new SqlParameter("@codepcode", Head.cOutDepCode), new SqlParameter("@cidepcode", Head.cInDepCode), new SqlParameter("@cirdcode", GetDBValue(Head.cInRdCode)), new SqlParameter("@cordcode", GetDBValue(Head.cOutRdCode)), new SqlParameter("@ctvmemo", GetDBValue(Head.cTvMemo)), new SqlParameter("@cmaker", Head.cMaker), new SqlParameter("@id", head_id), new SqlParameter("@csysbarcode", cSysBarCode), new SqlParameter("@cdefine11", Head.cCusCode), }; int headCount = this.DB_SqlHelper.ExecuteNonQuery(sql, para); if (headCount > 0) { try { List <ExecuteHelp> sqlList = new List <ExecuteHelp>(); // 组装SQL语句 for (int i = 0; i < detailCount; i++) { EntityTransVouchBody body = Head.Details[i]; string bodySql = string.Format(@" Insert Into TransVouchs(ctvcode,cinvcode,rdsid,itvnum,itvquantity,itvacost,itvaprice,itvpcost,itvpprice,ddisdate,cfree1,cfree2,cdefine22,cdefine23,cdefine24, cdefine25,cdefine26,cdefine27,citemcode,citem_class,fsalecost,fsaleprice,cname,citemcname,autoid,id,imassdate,cbarcode,cassunit,cfree3,cfree4,cfree5,cfree6,cfree7, cfree8,cfree9,cfree10,cdefine28,cdefine29,cdefine30,cdefine31,cdefine32,cdefine33,cdefine34,cdefine35,cdefine36,cdefine37,impoids,cbvencode,cinvouchcode,dmadedate, cmassunit,itrids,issotype,issodid,idsotype,idsodid,bcosting,cvmivencode,cinposcode,coutposcode,iinvsncount,iinvexchrate,comcode,cmocode,invcode,imoseq,iomids,imoids, corufts,iexpiratdatecalcu,cexpirationdate,dexpirationdate,cbatchproperty1,cbatchproperty2,cbatchproperty3,cbatchproperty4,cbatchproperty5,cbatchproperty6, cbatchproperty7,cbatchproperty8,cbatchproperty9,cbatchproperty10,cciqbookcode,cbmemo,irowno,strowguid,cinvouchtype,cbsourcecodels,cmolotcode,cinvoucherlineid, cinvouchercode,cinvouchertype,cbsysbarcode,cTVBatch) Values (@ctvcode,@cinvcode,Null,Null,@itvquantity,@itvacost,@itvaprice,Null,Null,Null,Null,Null,Null,Null,Null,Null,@cdefine26,@cdefine27,Null,Null,0,0,Null, Null,@autoid,@id,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null, Null,Null,Null,1,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,0,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,1,Null,Null,Null, Null,Null,Null,Null,@cbsysbarcode,@cTVBatch); Update CurrentStock set fTransInQuantity = fTransInQuantity + @itvquantity where cWhCode = @ciwhcode and cInvCode = @cinvcode and isnull(cBatch,'') = isnull(@cTVBatch,''); Update CurrentStock set fTransOutQuantity = fTransOutQuantity + @itvquantity where cWhCode = @cowhcode and cInvCode = @cinvcode and isnull(cBatch,'') = isnull(@cTVBatch,''); "); SqlParameter[] bodyPara = { new SqlParameter("@ctvcode", Head.cTvCode), new SqlParameter("@cinvcode", body.cInvCode), new SqlParameter("@itvquantity", body.iTvQuantity), new SqlParameter("@itvacost", body.iTvaCost), new SqlParameter("@itvaprice", body.iTvaPrice), new SqlParameter("@autoid", body_end_Id - detailCount + i + 1), new SqlParameter("@id", head_id), new SqlParameter("@cdefine26", body.cDefine26), new SqlParameter("@cdefine27", body.cDefine27), new SqlParameter("@irowno", i + 1), new SqlParameter("@cbsysbarcode", cSysBarCode + "|" + (i + 1)), new SqlParameter("@cowhcode", Head.cOutWhCode), new SqlParameter("@ciwhcode", Head.cInWhCode), new SqlParameter("@cTVBatch", GetDBValue(body.cBatch)), }; sqlList.Add(new ExecuteHelp() { SQL = bodySql, Parameters = bodyPara }); } // 执行SQL int bodyCount = this.DB_SqlHelper.ExecuteNonQuery(sqlList); } catch (Exception ex) { // 表体执行错误,表头也要回滚 DeleteTransVouch(Head.cTvCode); throw ex; } } else { throw new JRException("调拨单新增失败!"); } return(head_id == 0 ? null : head_id.ToString()); }
public string AddTransVouch(string UserCode, string PlainPassword, string StrAccID, int AccYear, string Act, EntityTransVouch entity, out int success) { success = 0; TransVouchBll bll = new TransVouchBll(StrAccID, AccYear, UserCode, PlainPassword); #region 验证 if (entity == null || entity.Details == null || entity.Details.Count == 0) { throw new JRException("调拨单新增失败!没有数据!"); } // 字段必填项验证 string msg = ""; if (!entity.CheckEntity(out msg)) { return(msg); } foreach (EntityTransVouchBody entitybody in entity.Details) { if (!entitybody.CheckEntity(out msg)) { return(msg); } } if (bll.GetGlmendFlag(entity.dTvDate.Year, entity.dTvDate.Month, "bflag_ST") == true) { return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cTvCode)); } // 调出仓库 if (string.IsNullOrWhiteSpace(GetWarehouseName(entity.cOutWhCode))) { return(string.Format("U8中不存在仓库编码:{0}!", entity.cOutWhCode)); } // 调入仓库 if (string.IsNullOrWhiteSpace(GetWarehouseName(entity.cInWhCode))) { return(string.Format("U8中不存在仓库编码:{0}!", entity.cInWhCode)); } //调出部门 if (string.IsNullOrWhiteSpace(GetDepartmentName(entity.cOutDepCode))) { return(string.Format("U8中不存在部门编码:{0},或者部门编码非末级!", entity.cOutDepCode)); } //调入部门 if (string.IsNullOrWhiteSpace(GetDepartmentName(entity.cInDepCode))) { return(string.Format("U8中不存在部门编码:{0},或者部门编码非末级!", entity.cInDepCode)); } entity.cOutRdCode = GetRdCode(12, 0); entity.cInRdCode = GetRdCode(12, 1); // 出库类别编码 if (string.IsNullOrWhiteSpace(entity.cOutRdCode) || string.IsNullOrWhiteSpace(GetRdStyleName(entity.cOutRdCode))) { return(string.Format("U8中不存在收发类别编码:{0}!", entity.cOutRdCode)); } // 入库类别编码 if (string.IsNullOrWhiteSpace(entity.cInRdCode) || string.IsNullOrWhiteSpace(GetRdStyleName(entity.cInRdCode, 1))) { return(string.Format("U8中不存在收发类别编码:{0}!", entity.cInRdCode)); } // 客户 string cusName = GetCustomerName(entity.cCusCode); if (string.IsNullOrWhiteSpace(cusName)) { return(string.Format("U8中不存在客户编号:{0}!", entity.cCusCode)); } int num = 0; string cmdText = "select count(*) as Num from TransVouch where ctvcode=@ctvcode"; SqlParameter[] paras = { new SqlParameter("@ctvcode", entity.cTvCode) }; DataTable dt = this.DB_SqlHelper.ExecuteDataTable(cmdText, paras); if (dt != null && dt.Rows.Count > 0) { num = int.Parse(dt.Rows[0]["Num"].ToString()); } if (num > 0) { throw new JRException("数据传递有误,ERP中已存在该调拨单号!"); } var inventorys = GetInventorys("'" + string.Join("','", entity.Details.Select(p => p.cInvCode).Distinct()) + "'"); for (int i = 0; i < entity.Details.Count; i++) { EntityTransVouchBody body = entity.Details[i]; 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)); } if (body.iTvQuantity == 0) { return(string.Format("申请数量不能为0!")); } if (body.iTvaCost * body.iTvQuantity != body.iTvaPrice || body.iTvQuantity * body.cDefine26 != body.cDefine27) { return(string.Format("存货编码:{0}金额异常!", body.cInvCode)); } } #endregion entity.cMaker = string.IsNullOrWhiteSpace(entity.cMaker) ? GetUserName(UserCode) : entity.cMaker; string id = InsertTransVouch(entity); success = string.IsNullOrWhiteSpace(id) ? 0 : 1; return(id); }
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中没有找到可对应的操作项")); }