/// <summary> /// 设置父子关系. /// </summary> /// <returns></returns> public string RefBill_Done() { try { string frmID = this.GetRequestVal("FrmID"); Int64 workID = this.GetRequestValInt64("WorkID"); GERpt rpt = new GERpt(frmID, workID); string pFrmID = this.GetRequestVal("PFrmID"); Int64 pWorkID = this.GetRequestValInt64("PWorkID"); //把数据copy到当前的子表单里. GERpt rptP = new GERpt(pFrmID, pWorkID); rpt.Copy(rptP); rpt.PWorkID = pWorkID; rpt.SetValByKey("PFrmID", pFrmID); rpt.Update(); //更新控制表,设置父子关系. GenerBill gbill = new GenerBill(workID); gbill.PFrmID = pFrmID; gbill.PWorkID = pWorkID; gbill.Update(); return("执行成功"); } catch (Exception ex) { return("err@" + ex.Message); } }
/// <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("保存成功..."); }
/// <summary> /// 保存 /// </summary> /// <param name="frmID">表单ID</param> /// <param name="workID">工作ID</param> /// <returns>返回保存结果</returns> public static string SaveAsDraft(string frmID, Int64 workID) { GenerBill gb = new GenerBill(workID); if (gb.BillState != BillState.None) { return("err@只有在None的模式下才能保存草稿。"); } if (gb.BillState != BillState.Editing) { gb.BillState = BillState.Editing; gb.Update(); } return("保存成功..."); }
/// <summary> /// 查询初始化 /// </summary> /// <returns></returns> public string SearchData_Init() { DataSet ds = new DataSet(); string sql = ""; string tSpan = this.GetRequestVal("TSpan"); if (tSpan == "") { tSpan = null; } #region 1、获取时间段枚举/总数. SysEnums ses = new SysEnums("TSpan"); DataTable dtTSpan = ses.ToDataTableField(); dtTSpan.TableName = "TSpan"; ds.Tables.Add(dtTSpan); GenerBill gb = new GenerBill(); gb.CheckPhysicsTable(); sql = "SELECT TSpan as No, COUNT(WorkID) as Num FROM Frm_GenerBill WHERE FrmID='" + this.FrmID + "' AND Starter='" + WebUser.No + "' AND BillState >= 1 GROUP BY TSpan"; DataTable dtTSpanNum = BP.DA.DBAccess.RunSQLReturnTable(sql); foreach (DataRow drEnum in dtTSpan.Rows) { string no = drEnum["IntKey"].ToString(); foreach (DataRow dr in dtTSpanNum.Rows) { if (dr["No"].ToString() == no) { drEnum["Lab"] = drEnum["Lab"].ToString() + "(" + dr["Num"] + ")"; break; } } } #endregion #region 2、处理流程类别列表. sql = " SELECT A.BillState as No, B.Lab as Name, COUNT(WorkID) as Num FROM Frm_GenerBill A, Sys_Enum B "; sql += " WHERE A.BillState=B.IntKey AND B.EnumKey='BillState' AND A.Starter='" + WebUser.No + "' AND BillState >=1"; if (tSpan.Equals("-1") == false) { sql += " AND A.TSpan=" + tSpan; } sql += " GROUP BY A.BillState, B.Lab "; DataTable dtFlows = BP.DA.DBAccess.RunSQLReturnTable(sql); if (SystemConfig.AppCenterDBType == DBType.Oracle || SystemConfig.AppCenterDBType == DBType.PostgreSQL) { dtFlows.Columns[0].ColumnName = "No"; dtFlows.Columns[1].ColumnName = "Name"; dtFlows.Columns[2].ColumnName = "Num"; } dtFlows.TableName = "Flows"; ds.Tables.Add(dtFlows); #endregion #region 3、处理流程实例列表. string sqlWhere = ""; sqlWhere = "(1 = 1)AND Starter = '" + WebUser.No + "' AND BillState >= 1"; if (tSpan.Equals("-1") == false) { sqlWhere += "AND (TSpan = '" + tSpan + "') "; } if (this.FK_Flow != null) { sqlWhere += "AND (FrmID = '" + this.FrmID + "') "; } else { // sqlWhere += ")"; } sqlWhere += "ORDER BY RDT DESC"; string fields = " WorkID,FrmID,FrmName,Title,BillState, Starter, StarterName,Sender,RDT "; if (SystemConfig.AppCenterDBType == DBType.Oracle) { sql = "SELECT " + fields + " FROM (SELECT * FROM Frm_GenerBill WHERE " + sqlWhere + ") WHERE rownum <= 50"; } else if (SystemConfig.AppCenterDBType == DBType.MSSQL) { sql = "SELECT TOP 50 " + fields + " FROM Frm_GenerBill WHERE " + sqlWhere; } else if (SystemConfig.AppCenterDBType == DBType.MySQL || SystemConfig.AppCenterDBType == DBType.PostgreSQL) { sql = "SELECT " + fields + " FROM Frm_GenerBill WHERE " + sqlWhere + " LIMIT 50"; } DataTable mydt = BP.DA.DBAccess.RunSQLReturnTable(sql); if (SystemConfig.AppCenterDBType == DBType.Oracle || SystemConfig.AppCenterDBType == DBType.PostgreSQL) { mydt.Columns[0].ColumnName = "WorkID"; mydt.Columns[1].ColumnName = "FrmID"; mydt.Columns[2].ColumnName = "FrmName"; mydt.Columns[3].ColumnName = "Title"; mydt.Columns[4].ColumnName = "BillState"; mydt.Columns[5].ColumnName = "Starter"; mydt.Columns[6].ColumnName = "StarterName"; mydt.Columns[7].ColumnName = "Sender"; mydt.Columns[8].ColumnName = "RDT"; } mydt.TableName = "Frm_Bill"; if (mydt != null) { mydt.Columns.Add("TDTime"); foreach (DataRow dr in mydt.Rows) { // dr["TDTime"] = GetTraceNewTime(dr["FK_Flow"].ToString(), int.Parse(dr["WorkID"].ToString()), int.Parse(dr["FID"].ToString())); } } #endregion ds.Tables.Add(mydt); return(BP.Tools.Json.ToJson(ds)); }