• 初识智遥工作流软件——表单开发篇2


      刚写两篇博客,就被博友批评了,看样子我的写作水平亟待提高,努力......。
     
      由于公司也是刚安装了智遥工作流这软件,软件公司提供3个月免费试用。现在还是在试用阶段。领导交待我先做几个流程测试一下,看看是否符合实际需求。由于不熟悉,所以就只能从最简单最常用的“请假流程”入手了,还望大家见谅!以后再放上复杂的。
     
      智遥工作流的表单,一键生成源代码功能确实不错,很对我这种懒人的胃口。但是自动生成的东西,肯定是无法满足用户需求的,所以必须是扩展方便,如果扩展不了,再怎么方便都是白搭。现在就来看看系统自动生成的源代码吧:
     
    请假单前台页面代码:
    <%@ Page Title="" Language="C#" MasterPageFile="~/WorkFlow/Form.Master" AutoEventWireup="true" CodeFile="QJD.aspx.cs" Inherits="WorkFlow_Form_QJD" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/base.js" type="text/javascript"></script>
    <div id="d_content" style="padding:10px 10px 10px 10px">
    <ext:FormPanel ID="FormPanel1" runat="server"   Padding="10" Border="true" LabelWidth="70" Width="670" title="请假单"  >
    <Items>
    <ext:TextField ID="Tworkid" runat="server" FieldLabel="编号" ReadOnly="true" AnchorHorizontal="95%" />
    <ext:ComboBox ID="Tleave_type" runat="server" FieldLabel="请假类别" AnchorHorizontal="95%" ></ext:ComboBox>
    <ext:TextField ID="Tuserid" runat="server" FieldLabel="工号" AnchorHorizontal="95%" />
    <ext:TextField ID="Tusername" runat="server" FieldLabel="姓名" AnchorHorizontal="95%" />
    <ext:TextField ID="Tdepartment" runat="server" FieldLabel="部门" AnchorHorizontal="95%" />
    <ext:TextField ID="Tgrade" runat="server" FieldLabel="职级" AnchorHorizontal="95%" />
    <ext:TextField ID="Tgender" runat="server" FieldLabel="性别" AnchorHorizontal="95%" />
    <ext:TextField ID="Tposition" runat="server" FieldLabel="职位" AnchorHorizontal="95%" />
    <ext:DateField ID="Tdate_join" runat="server" FieldLabel="入职日期" AnchorHorizontal="95%" />
    <ext:DateField ID="Tdate_from" runat="server" FieldLabel="开始日期" AnchorHorizontal="95%" />
    <ext:TextField ID="Ttime_from" runat="server" FieldLabel="开始时间" AnchorHorizontal="95%" />
    <ext:DateField ID="Tdate_to" runat="server" FieldLabel="结束日期" AnchorHorizontal="95%" />
    <ext:TextField ID="Ttime_to" runat="server" FieldLabel="结束时间" AnchorHorizontal="95%" />
    <ext:NumberField ID="Ttotal_day" runat="server" FieldLabel="合计" AnchorHorizontal="95%" />
    <ext:NumberField ID="Ttotal_hour" runat="server" FieldLabel="合计小时" AnchorHorizontal="95%" />
    <ext:TextField ID="Tagent" runat="server" FieldLabel="代理人" AnchorHorizontal="95%" />
    <ext:TextField ID="Treason" runat="server" FieldLabel="请假事由" AnchorHorizontal="95%" />
    </Items>
    </ext:FormPanel>
    </div>
    </asp:Content>

    前台代码没什么好讲的,就是几个控件从上往下排列下来,也不用写CSS样式,也不用表格,简洁+简单。我喜欢。

    请假单后台代码:

    using System;
    using System.Data;
    using System.Text;
    using System.Web.UI;
    using Ext.Net;
    using ZOA_DAL;
    
       public partial class WorkFlow_Form_QJD : BasePage
       {
          Z_User u = new Z_User();
          Z_Flow f = new Z_Flow();
          SqlHelper sh = new SqlHelper();
          protected void Page_Init(object sender, EventArgs e)
          {
          
          }
          
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!Page.IsPostBack)
              {
                  Hidden Hworkid = (Hidden)Master.FindControl("Hworkid");
                  Hidden HCmd = (Hidden)Master.FindControl("HCmd");
                  string cmd = HCmd.Text.ToString().ToUpper();
                  InitRights(cmd);
                  string workid = Hworkid.Text;
                  Tworkid.Text = workid;
                  if (cmd == "N")
                  {
                      Tuserid.Text = u.GetLoginID();
                      Tusername.Text = u.GetLoginName();
                      Tdepartment.Text = u.GetDeptName(u.GetLoginID());
                      
                  }
                  else
                  {
                      BindMainData(workid);
                  }
              }
          
          }
          
          // 绑定主数据
          protected void BindMainData(string workid)
          {
              DataTable dt = sh.Query("select * from F_QJD where workid='" + workid + "'");
              if (dt.Rows.Count > 0)
              {
                  Tworkid.Text = dt.Rows[0]["workid"].ToString();
                  Tleave_type.SelectedItem.Value = dt.Rows[0]["leave_type"].ToString();
                  Tuserid.Text = dt.Rows[0]["userid"].ToString();
                  Tusername.Text = dt.Rows[0]["username"].ToString();
                  Tdepartment.Text = dt.Rows[0]["department"].ToString();
                  Tgrade.Text = dt.Rows[0]["grade"].ToString();
                  Tgender.Text = dt.Rows[0]["gender"].ToString();
                  Tposition.Text = dt.Rows[0]["position"].ToString();
                  Tdate_join.Text = Convert.ToDateTime( dt.Rows[0]["date_join"]).ToShortDateString();
                  Tdate_from.Text = Convert.ToDateTime( dt.Rows[0]["date_from"]).ToShortDateString();
                  Ttime_from.Text = dt.Rows[0]["time_from"].ToString();
                  Tdate_to.Text = Convert.ToDateTime( dt.Rows[0]["date_to"]).ToShortDateString();
                  Ttime_to.Text = dt.Rows[0]["time_to"].ToString();
                  Ttotal_day.Text = dt.Rows[0]["total_day"].ToString();
                  Ttotal_hour.Text = dt.Rows[0]["total_hour"].ToString();
                  Tagent.Text = dt.Rows[0]["agent"].ToString();
                  Treason.Text = dt.Rows[0]["reason"].ToString();
              }
          
          }
          
          // 保存表单信息, 在点击保存时自动调用
          public override bool SaveData(int status)
          {
              Hidden HCmd = (Hidden)Master.FindControl("HCmd");
              string cmd = HCmd.Text.ToUpper(); 
              string CFnid = GetCurrentFnid(cmd); 
              if (SaveCheck(CFnid) == true)
              {
                  switch (CFnid)
                  { 
                      case "A":
                      string v_workid = Tworkid.Text.ToString();
                      string v_leave_type = Tleave_type.SelectedItem.Value.ToString();
                      string v_userid = Tuserid.Text.ToString();
                      string v_username = Tusername.Text.ToString();
                      string v_department = Tdepartment.Text.ToString();
                      string v_grade = Tgrade.Text.ToString();
                      string v_gender = Tgender.Text.ToString();
                      string v_position = Tposition.Text.ToString();
                      string v_date_join = Tdate_join.Text.ToString();
                      string v_date_from = Tdate_from.Text.ToString();
                      string v_time_from = Ttime_from.Text.ToString();
                      string v_date_to = Tdate_to.Text.ToString();
                      string v_time_to = Ttime_to.Text.ToString();
                      string v_total_day = Ttotal_day.Text.ToString();
                      string v_total_hour = Ttotal_hour.Text.ToString();
                      string v_agent = Tagent.Text.ToString();
                      string v_reason = Treason.Text.ToString();
                      string v_creator=u.GetLoginID();
                      string v_modifier=u.GetLoginID();
                      string v_ctime=DateTime.Now.ToString();
                      string v_mtime=DateTime.Now.ToString();
                      string subject = "请假单("+ u.GetLoginName() +")";
                      StringBuilder strSql = new StringBuilder();
                      if (cmd == "N")
                      {
                          string fid = Request.QueryString["fid"].ToString();
                          string fnid = Request.QueryString["fnid"].ToString();
                          int frev = Convert.ToInt32(Request.QueryString["frev"]);
                          string formid = Request.QueryString["formid"].ToString();
                          strSql.Clear();
                          strSql.Append("Insert into F_QJD( ");
                          strSql.Append("workid,");
                          strSql.Append("leave_type,");
                          strSql.Append("userid,");
                          strSql.Append("username,");
                          strSql.Append("department,");
                          strSql.Append("grade,");
                          strSql.Append("gender,");
                          strSql.Append("position,");
                          strSql.Append("date_join,");
                          strSql.Append("date_from,");
                          strSql.Append("time_from,");
                          strSql.Append("date_to,");
                          strSql.Append("time_to,");
                          strSql.Append("total_day,");
                          strSql.Append("total_hour,");
                          strSql.Append("agent,");
                          strSql.Append("reason,");
                          strSql.Append("creator,ctime) values (");
                          strSql.Append("'" + v_workid + "',");
                          strSql.Append("'" + v_leave_type + "',");
                          strSql.Append("'" + v_userid + "',");
                          strSql.Append("'" + v_username + "',");
                          strSql.Append("'" + v_department + "',");
                          strSql.Append("'" + v_grade + "',");
                          strSql.Append("'" + v_gender + "',");
                          strSql.Append("'" + v_position + "',");
                          strSql.Append("'" + v_date_join + "',");
                          strSql.Append("'" + v_date_from + "',");
                          strSql.Append("'" + v_time_from + "',");
                          strSql.Append("'" + v_date_to + "',");
                          strSql.Append("'" + v_time_to + "',");
                          strSql.Append("'" + v_total_day + "',");
                          strSql.Append("'" + v_total_hour + "',");
                          strSql.Append("'" + v_agent + "',");
                          strSql.Append("'" + v_reason + "',");
                          strSql.Append("'" +  v_creator + "',");
                          strSql.Append("'" +  v_ctime + "')");
                  
                          sh.Execute(strSql.ToString());
                          //2.这句很重要,切勿删除
                          f.FlowSummaryAdd(v_workid, fid, formid, subject, status, v_creator, v_ctime);
                          HCmd.Text = "E";
                      }
                      else 
                      {
                          strSql.Clear();
                          strSql.Append("Update F_QJD set  ");
                          strSql.Append("workid='" + v_workid + "' ,"); 
                          strSql.Append("leave_type='" + v_leave_type + "' ,"); 
                          strSql.Append("userid='" + v_userid + "' ,"); 
                          strSql.Append("username='" + v_username + "' ,"); 
                          strSql.Append("department='" + v_department + "' ,"); 
                          strSql.Append("grade='" + v_grade + "' ,"); 
                          strSql.Append("gender='" + v_gender + "' ,"); 
                          strSql.Append("position='" + v_position + "' ,"); 
                          strSql.Append("date_join='" + v_date_join + "' ,"); 
                          strSql.Append("date_from='" + v_date_from + "' ,"); 
                          strSql.Append("time_from='" + v_time_from + "' ,"); 
                          strSql.Append("date_to='" + v_date_to + "' ,"); 
                          strSql.Append("time_to='" + v_time_to + "' ,"); 
                          strSql.Append("total_day='" + v_total_day + "' ,"); 
                          strSql.Append("total_hour='" + v_total_hour + "' ,"); 
                          strSql.Append("agent='" + v_agent + "' ,"); 
                          strSql.Append("reason='" + v_reason + "' ,"); 
                          strSql.Append("modifier='" + v_modifier + "', ");
                          strSql.Append("mtime='" + v_mtime + "' ");
                          strSql.Append(" Where workid='" + v_workid + "'");
                          sh.Execute(strSql.ToString());
                          
                          f.FlowSummaryEdit(v_workid, status, v_creator, v_ctime);
                      }
                      break;
                      //case "A01":
                      //根据实际需要,补充代码
                      //    break;
                      //default :
                      //    break;
                  }
                  return true;
              }
              else
              {
                  return false;
              }
          }
          // 保存前检查
          protected bool SaveCheck(string CFnid)
          {
              bool pass = true;
              string msg = "";
              switch (CFnid)
              {
                  case "A":
                      if (Tworkid.Text.ToString() == "")
                      {
                          msg += "请输入编号!<br/>";
                      }
                      if (Tleave_type.Text.ToString() == "")
                      {
                          msg += "请输入请假类别!<br/>";
                      }
                      if (Tuserid.Text.ToString() == "")
                      {
                          msg += "请输入工号!<br/>";
                      }
                      if (Tusername.Text.ToString() == "")
                      {
                          msg += "请输入姓名!<br/>";
                      }
                      if (Tdepartment.Text.ToString() == "")
                      {
                          msg += "请输入部门!<br/>";
                      }
                      if (Tdate_join.Text.ToString() == "")
                      {
                          msg += "请输入入职日期!<br/>";
                      }
                      if (Tdate_from.Text.ToString() == "")
                      {
                          msg += "请输入开始日期!<br/>";
                      }
                      break;
                      //case "A01":
                      //    break;
                  }
                  if (msg != "")
                  {
                     pass = false;
                     X.Msg.Alert("提示:", msg).Show();
                  }
                  return pass;
              }
              
              
          // 在点击结束流程时,会自动调用该函数
          public override bool EndFlow()
          {
              return true;
          }
          
          // 权限控制
          protected void InitRights( string cmd)
          {
              if ((cmd == "N") || (cmd == "A") || (cmd == "E"))
              {
                  string fnid = GetCurrentFnid(cmd);
                  if (fnid == "A")
                  {
                  }
              }
          }
    
          // 获取当前节点编号
          protected string GetCurrentFnid(string cmd)
          {
              string fnid = "A";
              if (cmd == "A")
              {
                  string lid = Request.QueryString["lid"].ToString();
                  Z_Flow_Log fl = new Z_Flow_Log();
                  fnid = fl.Getfnid(lid);
              }
              return fnid;
          }
    
       }
    智遥的顾问讲解了一下,后台代码组成,以及各个函数的功能作用。

    1.BindMainData() 用于显示表单内容
    2.SaveData() 当用户点击"暂存/转下一步"时候自动调用,保存数据
    3.SaveCheck() 当用户保存的时候调用,提示是否有输错了的,漏输了之类的
    4.EndFlow() 当用户点击结束的时候会自动调用,里面空的,啥都没执行,就是为了扩展而留下的,有时候需要在流程结束的时候将数据写入到ERP或者HR系统中,这时就排上用场了。
    5.GetCurrentFnid()这个太有用了,可以获得当前操作所处在的节点,用户可以根据需求自行扩展,比如控制输入权限之类的。
    总结:自动生成的代码非常规范,整洁;没有使用高深的代码,至少我能轻松看懂。让人感觉这智遥工作流系统好简单啊。之前使用金和C6的时候,就觉得工作流好高深,动不动就得webservice,XML之类的。

     到目前为止,个人对这个智遥工作流很满意,希望以后制做复杂流程时,不出现各种不给力现象。

  • 相关阅读:
    Java WebSocket通信Demo
    JAVA FTP/SFTP 上传下载文件
    SpringMVC+MyBatis 事务中 基于注解的声明式事务
    Java 调用支付宝接口
    linux安装Tomcat
    使用cxf发布restful的webservice
    restful的webservice
    oracle时间比较和分页查询
    jenkins问题
    linux安装jenkins
  • 原文地址:https://www.cnblogs.com/zhiyao/p/3103275.html
Copyright © 2020-2023  润新知