`
uule
  • 浏览: 6349099 次
  • 性别: Icon_minigender_1
  • 来自: 一片神奇的土地
社区版块
存档分类
最新评论

.NET审批组建的开发

 
阅读更多


 选择“操作”会初始化对应的“下一环节处理”,
选择“下一环节处理”会初始化“备选责任人”

 

//public delegate void EventHandler(object sender, EventArgs e);

	public event EventHandler PreSubmit;

	// 提交前事件触发
	if (PreSubmit != null)
	{
	     EventArgs ea = new EventArgs();
	     PreSubmit(this, ea);
	}

 控件使用:

<!-- 注册用户组件 -->
<%@ Register src="../../AspUC/Dispose/Dispose.ascx" tagname="Dispose" tagprefix="uc1" %>


<div>
     <uc1:Dispose ID="Dispose1" runat="server" OnPreSubmit="SaveNetworkInfo"/>
</div>

 

Dispose.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Dispose.ascx.cs" Inherits="OSP.Web.AspUC.Dispose.Dispose" %>
<table style="table-layout:fixed;" id="opinionform">
    <tr>
        <td class="leftform">
            <table style=" table-layout:fixed;" >
                <tr>
                    <td>
                        <h2>处理意见</h2>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:TextBox ID="Comment" runat="server" TextMode="MultiLine" Rows="8"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">保存常用意见</asp:LinkButton>
                        <asp:DropDownList ID="UsualComment" runat="server" 
                            onselectedindexchanged="UsualComment_SelectedIndexChanged" AutoPostBack="true">
                        </asp:DropDownList>
                        <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">删除意见</asp:LinkButton>
                    </td>
                </tr>
            </table>
        </td>
        <td class="rightform">
            <table style="table-layout:fixed;" >
                <tr>
                    <td >
                    <h2>选择操作</h2>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:ListBox ID="Action" runat="server" Rows="4" 
                            onselectedindexchanged="Action_SelectedIndexChanged" AutoPostBack="true"></asp:ListBox>
                    </td>
                </tr>
                <tr>
                    <td >
                    <h2>下一环节处理(多选时请按ctrl键)</h2>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:ListBox ID="Activity" runat="server" Rows="4" SelectionMode="Multiple" onselectedindexchanged="Activity_SelectedIndexChanged" AutoPostBack="true"></asp:ListBox>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="2" class="bottomform">
            <table style="width:100%;">
                <tr>
                    <td colspan="3" >
                    <h2>选择执行人</h2>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                    <h2>备选责任人</h2>
                        
                    </td>
                    <td>
                    </td>
                    <td>
                    <h2>已选责任人</h2>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:ListBox ID="OptUser1" runat="server" Rows="5"></asp:ListBox>
                    </td>
                    <td style="width:70px;">
                        <table style=" table-layout:fixed;">
                            <tr align="center">
                                <td>
                                    <asp:Button ID="Button1" runat="server" Text=">>" Width="50px" 
                                        onclick="Button1_Click" />
                                </td>
                            </tr>
                            <tr align="center">
                                <td>
                                    <asp:Button ID="Button2" runat="server" Text=">" Width="50px" 
                                        onclick="Button2_Click"/>
                                </td>
                            </tr>
                            <tr align="center">
                                <td>
                                    <asp:Button ID="Button3" runat="server" Text="<" Width="50px" 
                                        onclick="Button3_Click"/>
                                </td>
                            </tr>
                            <tr align="center">
                                <td>
                                    <asp:Button ID="Button4" runat="server" Text="<<" Width="50px" 
                                        onclick="Button4_Click"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <asp:ListBox ID="OptUser2" runat="server" Rows="5"></asp:ListBox>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center">
        <div class="button2">
            <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/themes/default/images/btn_submit.gif" Width="50" Height="20" onclick="ImageButton2_Click"/>
            <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/themes/default/images/btn_close.gif" Width="50" Height="20" OnClientClick="window.returnValue=0;window.close();"/>
            </div>
        </td>
    </tr>
</table>

 Dispose.ascx.cs:

//属性
namespace OSP.Web.AspUC.Dispose
{
    public partial class Dispose : System.Web.UI.UserControl
    {
        private BLL.WorkFlowBll workFlow = new BLL.WorkFlowBll();

        #region 暴露属性
        /// <summary>
        /// 提交前触发事件 外部设置
        /// </summary>
        public event EventHandler PreSubmit;

        /// <summary>
        /// 提交后触发事件 外部设置
        /// </summary>
        public event EventHandler PostSubmit;

        /// <summary>
        /// 环节参数:key=value;key=value... 外部设置
        /// </summary>
        public string ActivityParam;

        /// <summary>
        /// 流程参数:key=value;key=value... 外部设置
        /// </summary>
        public string ProcessParam;

        /// <summary>
        /// 下一环节名称 只读
        /// </summary>
        public string NextActivityName
        {
            get { return Activity.SelectedItem.Text; }
        }

        /// <summary>
        /// 下一环节元数据 只读
        /// </summary>
        public string NextActivityMetaData
        {
            get { return Activity.SelectedItem.Value; }
        }

        private decimal piid;

        public decimal ProcessInstanceId
        {
            get { return piid; }
        }
        #endregion
//页面加载
/// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // 下一环节信息
                string fullname = Page.Request.QueryString["fn"];
                string sn = Page.Request.QueryString["sn"];
                string originator = Page.Request.QueryString["ou"];
                DataSet ds = null;
                
                if (string.IsNullOrEmpty(fullname))
                {
                    #region 流程过程审批
                    ds = workFlow.GetWorklistItem(sn, false);

                    // 操作初始化
                    DataTable dta = ds.Tables["Action"];
                    Action.DataTextField = "Name";
                    Action.DataValueField = "Name";
                    Action.DataSource = dta;
                    Action.DataBind();
                    #endregion
                }
                else
                {
                    #region 流程发起选人
                    ds = XMLUtil.ConvertDataSet(workFlow.getNextActivityInfo(originator, fullname));
                    Action.Items.Add(new ListItem("开始","开始"));
                    Action.SelectedIndex = 0;

                    DataTable dta = ds.Tables["NextActivity"];
                    if (dta != null && dta.Rows.Count > 0)
                    {
                        Activity.Items.Add(new ListItem(dta.Rows[0]["ActName"].ToString(), dta.Rows[0]["MetaData"].ToString()));
                        Activity.SelectedIndex = 0;

                        DataTable dtu = ds.Tables["AvailableUser"];
                        if (dtu != null && dtu.Rows.Count > 0)
                        {
                            foreach(DataRow dr in dtu.Rows)
                            {
                                OptUser1.Items.Add(new ListItem(dtu.Rows[0]["UserName"].ToString(), dtu.Rows[0]["LoginID"].ToString()));
                            }
                        }
                    }
                    #endregion
                }
                this.ViewState["ds"] = ds;

                // 常用意见信息
                DataSet dsoc = workFlow.getOftenComment();
                UsualComment.Items.Add(new ListItem("-- 请选择 --", "0"));
                UsualComment.SelectedIndex = 0;
                if (dsoc.Tables["OftenComment"] != null)
                {
                    foreach (DataRow dr in dsoc.Tables["OftenComment"].Rows)
                    {
                        UsualComment.Items.Add(new ListItem(dr["Comment"].ToString(), dr["CommentID"].ToString()));
                    }
                }
            }
        }

 

//控件联动事件
#region 控件联动事件
        /// <summary>
        /// 根据操作确定环节列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Action_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Page.Request.QueryString["fn"]))
            {
                Activity.Items.Clear();
                DataSet ds = (DataSet)this.ViewState["ds"];
                if (Action.SelectedValue != null)
                {
                    DataRow[] dr = null;
                    if (ds.Tables["Action"] != null && (dr = ds.Tables["Action"].Select("Name='" + Action.SelectedValue + "'")).Length > 0)
                    {
                        dr = dr[0].GetChildRows(ds.Relations["Action_WFNextActivitys"]);
                        if (dr.Length > 0)
                        {
                            DataRow[] d = dr[0].GetChildRows(ds.Relations["WFNextActivitys_NextActivity"]);
                            foreach (DataRow dr2 in d)
                            {
                                Activity.Items.Add(new ListItem(dr2["ActName"].ToString(), dr2["MetaData"].ToString()));
                            }

                            OptUser1.DataSource = null;
                            OptUser2.DataSource = null;
                            OptUser1.DataBind();
                            OptUser2.DataBind();
                        }
                    }
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in OptUser1.Items)
            {
                OptUser2.Items.Add(li);
            }
            OptUser1.Items.Clear();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in OptUser1.Items)
            {
                if (li.Selected)
                {
                    OptUser2.Items.Add(li);
                }
            }
            foreach (ListItem li in OptUser2.Items)
            {
                OptUser1.Items.Remove(li);
            }
            OptUser1.SelectedIndex = -1;
            OptUser2.SelectedIndex = -1;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in OptUser2.Items)
            {
                if (li.Selected)
                {
                    OptUser1.Items.Add(li);
                }
            }
            foreach (ListItem li in OptUser1.Items)
            {
                OptUser2.Items.Remove(li);
            }
            OptUser1.SelectedIndex = -1;
            OptUser2.SelectedIndex = -1;
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in OptUser2.Items)
            {
                OptUser1.Items.Add(li);
            }
            OptUser2.Items.Clear();
        }

        protected void Activity_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Page.Request.QueryString["fn"]))
            {
                OptUser1.Items.Clear();
                OptUser2.Items.Clear();
                DataSet ds = (DataSet)this.ViewState["ds"];
                if (Activity.SelectedValue != null)
                {
                    string sql = "MetaData='" + Activity.Items[Activity.SelectedIndex].Value + "'";
                    for (int i = Activity.SelectedIndex + 1; i < Activity.Items.Count; i++)
                    {
                        if (Activity.Items[i].Selected)
                        {
                            sql += "or MetaData='" + Activity.Items[i].Value + "'";
                        }
                    }

                    DataRow[] dr = null;
                    DataRow[] dr3 = null;
                    if (ds.Tables["NextActivity"] != null && (dr = ds.Tables["NextActivity"].Select(sql)).Length > 0)
                    {
                        Dictionary<string, string> dir = new Dictionary<string, string>();
                        for (int j = 0; j < dr.Length; j++)
                        {
                            dr3 = dr[j].GetChildRows(ds.Relations["NextActivity_AvailableUsers"]);
                            if (dr3.Length > 0)
                            {
                                DataRow[] d = dr3[0].GetChildRows(ds.Relations["AvailableUsers_AvailableUser"]);
                                foreach (DataRow dr2 in d)
                                {
                                    dir[dr2["LoginID"].ToString()] = dr2["UserName"].ToString();
                                }
                            }
                        }

                        foreach (string key in dir.Keys)
                        {
                            OptUser1.Items.Add(new ListItem(dir[key], key));
                        }

                    }

                }
            }
        }
        #endregion

 

//
/// <summary>
        /// 提交审批
        /// 提交前和后会触发相应事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            // 表单校验
            if (OptUser1.Items.Count > 0 && OptUser2.Items.Count < 1)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "showMsg", "showMsg('请选择责任人!');", true);
                return;
            }
            if (Action.SelectedIndex < 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "showMsg", "showMsg('请选择操作!');", true);
                return;
            }
            if (Activity.SelectedIndex < 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "showMsg", "showMsg('请选择环节!');", true);
                return;
            }

            // 提交前事件触发
            if (PreSubmit != null)
            {
                EventArgs ea = new EventArgs();
                PreSubmit(this, ea);
            }

            #region 提交审批
            // 下一环节信息
            string fullname = Page.Request.QueryString["fn"];
            string sn = Page.Request.QueryString["sn"];
            string originator = Page.Request.QueryString["ou"];
            string folio = Page.Request.QueryString["folio"];

            string msg = "";
            
            if (string.IsNullOrEmpty(fullname))
            {
                string activityParam = "Outcome=k2sql:" + Action.SelectedValue;
                if (!string.IsNullOrEmpty(ActivityParam))
                {
                    activityParam += (";" + ActivityParam);
                }
                string processParam = "";
                string userInfo = "";
                if (OptUser2.Items.Count > 0)
                {
                    userInfo = Activity.SelectedValue + "=k2sql:" + OptUser2.Items[0].Value;
                    for (int i = 1; i < OptUser2.Items.Count; i ++)
                    {
                        userInfo += ",k2sql:" + OptUser2.Items[i].Value;
                    }
                }
                processParam += userInfo;

                processParam += ";Route01=" + Activity.SelectedValue;
                

                if (!string.IsNullOrEmpty(ProcessParam))
                {
                    processParam += (";" + ProcessParam);
                }
                workFlow.finishWorkListItem(sn, Action.SelectedValue, activityParam, processParam, Comment.Text);
                msg = "审批成功!";
            }
            else
            {
                string processParam = "";
                string userInfo = "";
                if (OptUser2.Items.Count > 0)
                {
                    userInfo = Activity.SelectedValue + "=k2sql:" + OptUser2.Items[0].Value;
                    for (int i = 1; i < OptUser2.Items.Count; i++)
                    {
                        userInfo += ",k2sql:" + OptUser2.Items[i].Value;
                    }
                }
                processParam += userInfo;
                piid = Convert.ToDecimal(workFlow.startProcess(originator, fullname, folio, processParam));
                msg = "流程发起成功!";
            }
            #endregion

            // 提交后事件触发
            if (PostSubmit != null)
            {
                EventArgs ea = new EventArgs();
                PostSubmit(this, ea);
            }

            // 如果成功,关闭
            ScriptManager.RegisterStartupScript(this, this.GetType(), "showMsg", "showMsg('" + msg + "');window.returnValue=1;window.close();", true);

        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            workFlow.deleOftenComment(UsualComment.SelectedValue);
            UsualComment.Items.Remove(UsualComment.Items[UsualComment.SelectedIndex]);
            UsualComment.SelectedIndex = 0;
            Comment.Text = "";
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            UsualComment.Items.Add(new ListItem(Comment.Text, workFlow.saveOftenComment(Comment.Text)));
            UsualComment.SelectedIndex = UsualComment.Items.Count - 1;
        }

        protected void UsualComment_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (UsualComment.SelectedIndex != 0)
            {
                Comment.Text = UsualComment.SelectedItem.Text;
            }
        }

 

"常用意见数据源":
DataSet dsoc

//GetOftenComment.xml

<?xml version="1.0" encoding="utf-8"?>

<OftenComments>
  <Result>0</Result>
  <IsOK>true</IsOK>
  <OftenComment>
    <CommentID>22684FA6DD0B49B6B248E932666E4CB4</CommentID>
    <Comment>............hahahah3333同意</Comment>
  </OftenComment>
  <OftenComment>
    <CommentID>B1226234D35B4F7D9581C72D0DB03355</CommentID>
    <Comment>............hahahah</Comment>
  </OftenComment>
  <OftenComment>
    <CommentID>BE11D9B4767C44D196ABFC6DFF6C5CE2</CommentID>
    <Comment>............hahahah3333</Comment>
  </OftenComment>
  <Action>Get</Action>
</OftenComments>

 ..

  • 大小: 12.3 KB
分享到:
评论

相关推荐

    Asp.Net审批流程

    API(Application Programming Interface)在Asp.Net审批流程中起着关键作用。我们可以利用ASP.Net Web API来构建RESTful服务,提供审批数据的增删改查接口。这些接口可以被前端页面调用,获取或更新审批状态,也...

    《.NET平台开发CRM》课件—03在.NET框架下开发三层结构数据库应用系统.pdf

    《.NET平台开发CRM》课件—03在.NET框架下开发三层结构数据库应用系统.pdf《.NET平台开发CRM》课件—03在.NET框架下开发三层结构数据库应用系统.pdf《.NET平台开发CRM》课件—03在.NET框架下开发三层结构数据库应用...

    ASP.NET 4.0 网站开发与项目实战 光盘

    ASP.NET 4.0 是微软开发的一个强大的Web应用程序框架,用于构建动态、数据驱动的网站和应用程序。这个框架是.NET Framework的一部分,提供了丰富的特性和工具,使得开发者能够更高效地构建高质量的Web应用。 在...

    Web程序设计--ASP.NET实用网站开发课后习题及答案

    ASP.NET 实用网站开发知识点总结 本节总结了 ASP.NET 实用网站开发的相关知识点,包括 .NET Framework、ASP.NET 网站开发、HTML、CSS、JavaScript、C#语言等方面。 一、.NET Framework * .NET Framework 主要包括...

    C# .NET工控上位机开发

    本文将详细探讨C# .NET在工控上位机开发中的应用,以及相关的核心知识点。 一、C#语言基础 C#是一种面向对象的编程语言,由微软公司开发,主要用于.NET Framework平台。它的语法简洁明了,支持类型安全和垃圾回收,...

    用vb.net开始asp.net1.1的开发

    用vb.net开始asp.net1.1的开发用vb.net开始asp.net1.1的开发

    .NET FRAMEWORK4.5.2开发工具包

    用于VisualStudio2019以上版本开发.net framework 4.5.2框架的代码。适用于64位操作系统~ 从Visual Studio 2022开始,‌Microsoft不再包含.NET Framework 4.0到4.5.1的.NET Framework组件,‌因为这些版本不再受到...

    asp.net 微信公众号开发源码

    asp.net 微信公众号开发源码

    【全网首发】ASP.NET MVC4开发指南(附带源码)

    这个"ASP.NET MVC4开发指南"提供了一套全面的学习资源,旨在帮助开发者掌握这一强大的Web开发技术。 MVC(Model-View-Controller)模式是ASP.NET MVC4的核心设计原则,它将应用程序分为三个主要部分:模型(Model)...

    civil 3d .net二次开发随笔(-)

    ### Civil 3D .NET 二次开发随笔 #### 一、引言 随着三维建模技术的进步,Civil 3D 成为了土木工程、测绘、设计与施工领域的重要工具。Civil 3D 是一款由 Autodesk 公司开发的专业三维建模软件,广泛应用于土木...

    Web程序设计 : ASP.NET实用网站开发 .pdf

    Web程序设计 : ASP.NET实用网站开发 .pdf

    ASP.NET Web 应用开发技术(第二版) 课后答案

    ASP.NET Web 应用开发技术(第二版) 课后答案 喻钧 web应用程序

    《AutoCAD C#.Net 二次开发》课件.pdf

    《AutoCAD C#.Net 二次开发》课件,《AutoCAD C#.Net 二次开发》课件《AutoCAD C#.Net 二次开发》课件,《AutoCAD C#.Net 二次开发》课件,《AutoCAD C#.Net 二次开发》课件《AutoCAD C#.Net 二次开发》课件。...

    ASP.NET电子商务开发实战(完整版)1/2

    ASP.NET电子商务开发实战(完整版)本压缩包内包含:ASP.NET电子商务开发实战(中文版)、ASP.NET电子商务开发实战(英文版)和配书源代码三项内容。 ASP.NET电子商务开发实战(中文版)为完整版本,本资源与网上流传的ASP...

    asp.net core敏捷开发框架c#源码

    ASP.NET Core是一个由微软开发的开源、跨平台的web应用框架,它是在.NET Core基础上构建的,用于构建高性能、模块化的互联网规模的应用程序。这个"asp.net core敏捷开发框架c#源码"提供了完整的C#源代码,适用于那些...

    [深入浅出AutoCAD.NET二次开发].李冠亿.扫描版

    [深入浅出AutoCAD.NET二次开发].李冠亿.扫描版 适合AutoCAD二次开发新手入门

    完全手册ASP.NET AJAX实用开发详解 源码

    本书从易到难、由浅入深、循序渐进系统地介绍了ASP.NET AJAX(C#)知识点和基于AJAX的Web应用系统的开发技术。全书通俗易懂,大量的实例供读者更加深刻地巩固所学习的知识,使读者更好地进行开发实践。 本书共分为15...

Global site tag (gtag.js) - Google Analytics