/// <summary> /// 创建工作ID /// </summary> /// <param name="frmID">表单ID</param> /// <param name="userNo">用户编号</param> /// <param name="htParas">参数</param> /// <returns>一个新的WorkID</returns> public static Int64 CreateBlankBillID(string frmID, string userNo, Hashtable htParas) { GenerBill gb = new GenerBill(); int i = gb.Retrieve(GenerBillAttr.FrmID, frmID, GenerBillAttr.Starter, userNo, GenerBillAttr.BillState, 0); if (i == 1) { return(gb.WorkID); } FrmBill fb = new FrmBill(frmID); gb.WorkID = BP.DA.DBAccess.GenerOID("WorkID"); gb.BillState = BillState.None; //初始化状态. gb.Starter = BP.Web.WebUser.No; gb.StarterName = BP.Web.WebUser.Name; gb.FrmName = fb.Name; //单据名称. gb.FrmID = fb.No; //单据ID gb.FK_FrmTree = fb.FK_FormTree; //单据类别. gb.RDT = BP.DA.DataType.CurrentDataTime; gb.NDStep = 1; gb.NDStepName = "启动"; //创建rpt. BP.WF.Data.GERpt rpt = new BP.WF.Data.GERpt(frmID); //设置标题. if (fb.EntityType == EntityType.FrmBill) { gb.Title = Dev2Interface.GenerTitle(fb.TitleRole, rpt); gb.BillNo = BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, gb.WorkID, null, frmID); } if (fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict) { rpt.EnMap.CodeStruct = fb.EnMap.CodeStruct; gb.BillNo = rpt.GenerNewNoByKey("BillNo"); // BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, gb.WorkID, null, frmID); gb.Title = ""; } gb.DirectInsert(); //执行插入. //更新基础的数据到表单表. // rpt = new BP.WF.Data.GERpt(frmID); rpt.SetValByKey("BillState", (int)gb.BillState); rpt.SetValByKey("Starter", gb.Starter); rpt.SetValByKey("StarterName", gb.StarterName); rpt.SetValByKey("RDT", gb.RDT); rpt.SetValByKey("Title", gb.Title); rpt.SetValByKey("BillNo", gb.BillNo); rpt.OID = gb.WorkID; rpt.InsertAsOID(gb.WorkID); return(gb.WorkID); }
/// <summary> /// 保存 /// </summary> /// <param name="frmID">表单ID</param> /// <param name="workID">工作ID</param> /// <returns>返回保存结果</returns> public static string SaveWork(string frmID, Int64 workID) { FrmBill fb = new FrmBill(frmID); GenerBill gb = new GenerBill(); gb.WorkID = workID; int i = gb.RetrieveFromDBSources(); if (i == 0) { return(""); } gb.BillState = BillState.Editing; //创建rpt. BP.WF.Data.GERpt rpt = new BP.WF.Data.GERpt(gb.FrmID, workID); if (fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict) { gb.Title = rpt.Title; gb.Update(); return("保存成功..."); } //单据编号. if (DataType.IsNullOrEmpty(gb.BillNo) == true && !(fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict)) { gb.BillNo = BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, workID, null, fb.PTable); //更新单据里面的billNo字段. if (DBAccess.IsExitsTableCol(fb.PTable, "BillNo") == true) { DBAccess.RunSQL("UPDATE " + fb.PTable + " SET BillNo='" + gb.BillNo + "' WHERE OID=" + workID); } } //标题. if (DataType.IsNullOrEmpty(gb.Title) == true && !(fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict)) { gb.Title = Dev2Interface.GenerTitle(fb.TitleRole, rpt); //更新单据里面的 Title 字段. if (DBAccess.IsExitsTableCol(fb.PTable, "Title") == true) { DBAccess.RunSQL("UPDATE " + fb.PTable + " SET Title='" + gb.Title + "' WHERE OID=" + workID); } } gb.Update(); //把通用的字段更新到数据库. rpt.Title = gb.Title; rpt.BillNo = gb.BillNo; rpt.Update(); return("保存成功..."); }