博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
某年某月某天
阅读量:5066 次
发布时间:2019-06-12

本文共 9118 字,大约阅读时间需要 30 分钟。

审批流

第一种:

【FlowPath代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>

/// FlowPath 的摘要说明
/// </summary>
public partial class FlowPath
{
 public string Name
 {
        get
        {
            MyDBDataContext Context=new MyDBDataContext();
            var query = context.Emp.Where(p => p.UserName == this.EmpId);
            if (query.Count() > 0)
            {
                return query.First().Name;
            }
            return "";
        }

 }

}

【登录源】

<title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        用户名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        密码:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="登录" />
   
    </div>
    </form>
</body>

【登录代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page

{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["user"] = TextBox1.Text;
        Response.Redirect("~/Test/Main.aspx");
    }
}

【Main源】

<title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:UserList ID="UserList1" runat="server" />
        <uc2:NodesShow ID="NodesShow1" runat="server" />
    </div>        
    </form>
</body>

【Main代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Main : System.Web.UI.Page

{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserList1.Show += NodesShow1.ShowSession;
    }
}

【NodesShow源】

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NodesShow.ascx.cs" Inherits="NodesShow" %>

<asp:Panel ID="Panel1" runat="server">
    <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
        <HeaderTemplate>
            <table width="300" border="0" align="center">
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td width="220"><%#Eval("Name") %></td>
                <td width="44">
                    <asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" runat="server" CommandArgument="<%#SetKey() %>" ImageUrl="~/images/delete.png"/></td>
            </tr>
        </ItemTemplate>
        <SeparatorTemplate>
            <tr>
                <td>
                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/arrow.png" /></td>
                <td></td>
            </tr>
        </SeparatorTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnSubmit" runat="server" Text="提交" OnClick="btnSubmit_Click" />
</asp:Panel>

【NodesShow代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class NodesShow : System.Web.UI.UserControl

{
    private string SetKey()
    {
        return Eval("Code").ToString();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ShowSession();
        }
    }
    private void ShowSession()
    {
        if (Session["list"] != null)
        {
            List<FlowPath>list=Session["list"]as List<FlowPath>;
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }
    }

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

    }

    protected void ImageButton1_Click(object sender, EventArgs e)

    {
        //删除的代码
        //1.获取要删除的主键
        string key = (sender as ImageButton).CommandArgument.ToString();
        //2.执行删除
        if (Session["list"] != null)
        {
            List<FlowPath> list = Session["list"] as List<FlowPath>;
            FlowPath data=list.Where(p => p.Code == key).First();
            list.Remove(data);
            Session["list"] = list;
        }
        //3.刷新
        ShowSession();
    }
}

【UserList源】

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserList.ascx.cs" Inherits="UserList" %>

<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <input type="radio" name="rbusers" value="<%#Eval("UserName") %>"><%#Eval("Name") %>
        </ItemTemplate>
    </asp:Repeater>
    <br/>
    <asp:Button ID="btnAddNode" runat="server" Text="添加节点" OnClick="btnAddNode_Click" />
</asp:Panel>

【UserList代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserList : System.Web.UI.UserControl

{  
    //定义代理新类型
    public delegate void ShowDelegate();
    //使用代理类型定义代理变量
    public event ShowDelegate Show;

    private MyDBDataContext_Context=new MyDBDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var query = _Context.Emp;
            Repeater1.DataSource=query;
            Repeater1.DataBind();
        }
    }
   protected void btnAddNode_Click(object sender, EventArgs e)
   {   //一、获取之前添加的人员列表
       if(Session["list"]==null)
       {
           List<FlowPath>temp=new List<FlowPath>();
           Session["list"]=temp;
       }
       List<FlowPath>list=Session["list"]as List<FlowPath>;
   }
    //二、添加选中人员
    //1.计算人员排序号
    list=list.OrderBy(p=>p.Orders).ToList();
    int order=1;
    if(list.Count>0)
    {
        order=list.Last().Orders.Value+1;
    }
    //2.生成节点对象
    FlowPath data=new FlowPath();
    data.Code=DateTime.Now.ToString("yyyyMMddhhmmss")+order+Session["user"].ToString();
    data.EmpId=Request["rbusers"].ToString();
    data.Orders=order;
    //3.把对象添加到集合当中去
    list.Add(data);
    //4.把数据送到Session中保存
    Session["list"]=list;
    //三、重新绑定NodeShow中的Repeater
    //重新调用
    if(Show!=null)
    {
        Show();
    }
}

第二种:

【FlowPath代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>

/// FlowPath 的摘要说明
/// </summary>
public partial class FlowPath
{
 private MyDBDataContext_Context=new MyDBDataContext();
 public string Name
 {
        get
        {
            string empID=this.EmpId;
            var query=_Context.Emp.Where(p=>p.UserName==empID);
            if(query.Count()>0)
            {
                return query.First().Name;
            }
            return "";
        }
 }
}

【登录源】

<title></title>

</head>
<body>
    <form id="form1" runat="server">
        用户名:<asp:TextBox ID="txtUID" runat="server"></asp:TextBox>
        <br />
        密码:<asp:TextBox ID="txtPWD" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click" Text="登录" />
    </form>
</body>

【登录代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page

{
    private MyDBDataContext_Context = new MyDBDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        var query=_Context.Emp.Where(p=>p.UserName==txtUID.Text&&p.password==txtPWD.Text);
        if(query.Count()>0)
        {
            Session["user"]=txtUID.Text;
            Response.Redirect("Main.aspx");
        }
    }
}

【Main源】

<title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:RadioButtonList ID="rblUsers" runat="server" RepeatDirection="Horizontal">
        </asp:RadioButtonList>
        <br />
        <asp:Button ID="Button1" runat="server" Text="添加节点" OnClick="Button1_Click" />
        <br />
        <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
                <div>
                <%#Eval("EmpID") %>
                <asp:ImageButton ID="ImageButton1" CommandArgument="<%#ShowKey() %>" OnClick="ImageButton1_Click" runat="server" ImageUrl="~/images/delete.png"/>
                </div>
            </ItemTemplate>
            <SeparatorTemplate>
                <asp:Image ID="Image1" ImageUrl="~/images/arrow.png" runat="server" />
            </SeparatorTemplate>
        </asp:Repeater>
   
    </div>
        <asp:Button ID="Button2" runat="server" Text="提交" />
    </form>
</body>

【Main代码】

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Main : System.Web.UI.Page

{
    private MyDBDataConrtext_Context=new MyDBDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if(Session["list"]==null)
            {
                Response.Redirect("Default.aspx");
            }
            //加载人员列表数据
            LoadEmp();
        }
    }
    public string ShowKey()
    {
        return Eval("Code").ToString();
    }
    private void LoadEmp()
    {
        var query = _Context.Emp;
        rblUsers.DataSource=query;
        rblUsers.DataTextField="Name";
        rblUsers.DataValueField="UserName";
        rblUsers.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //从集合中把session取出来
        if(Session["list"]==null)
        {
            List<FlowPath>temp=new List<FlowPath>();
            Session["list"]=temp;
        }
        List<FlowPath>list=Session["list"]as List<FlowPath>;
        //找最大索引号
        int maxOrders=0;
        if(list.Count>0)
        {
        list=list.OrderByDescending(p=>p.Orders).ToString();
        int maxOrder=list.First().Orders.Value;
        }
        maxOrder++;
        //向session中添加对象
        FlowPath data=new FlowPath();
        data.Code=DateTime.Now.ToString("yyyyMMddhhmmss")+maxOrder.ToString()+Session["user"].ToString();
        data.EmpId=rblUsers.SelectedValue;
        data.Orders=maxOrder;
        list.Add(data);
        list=list.OrderBy(p=>p.Orders).ToList();
        Session["list"]=list;
        //页面显示
        Repeater1.DataSource=list;
        Repeater1.DataBind();
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
   {
        //取出要删除项的主键值
        ImageButton btn=sender as ImageButton;
        string key=btn.CommandArgument.ToString();
        //从session中删除对应项
        if(Session["list"]=null)
        {
            List<FlowPath>list=Session["list"]as List<FlowPath>;
            var query=list.Where(p=>p.Code==key);
            if(query.Count()>0)
            {
                FlowPath data=query.First();
                list.Remove(data);
                Session["list"]=list;
                Repeater1.DataSource=list;
                Repeater1.DataBind();
            }
          
        }
   }
}

转载于:https://www.cnblogs.com/kxy3-1314/p/4887748.html

你可能感兴趣的文章
Android HttpURLConnection Post 参数 (https)
查看>>
我的软件工程课程目标
查看>>
数据库中触发器、事务
查看>>
关于JAVA并发编程你需要知道的——硬件篇
查看>>
数据分析师发展之路
查看>>
stream的filter用法
查看>>
条款25 :尽可能延后变量定义式的出现时间
查看>>
C#中Thread.IsBackground 属性
查看>>
Python的DEBUG LOG
查看>>
HTTP中get、post请求工具类
查看>>
Android MVP模式就是这么回事儿
查看>>
我的第一个可用的Windows驱动完成了
查看>>
搭建一个自己的SVN服务器
查看>>
[BZOJ4452] Export Estimate
查看>>
《人月神话》---1
查看>>
DDoS防御方案
查看>>
jmx无验证设置
查看>>
Always keep in mind
查看>>
learning python学习小记(一)
查看>>
英语学习
查看>>