当前位置 : 主页 > 网络编程 > net编程 >

自定义表单设计之八-流程节点字段配置

来源:互联网 收集:自由互联 发布时间:2023-10-08
FieldViewOfNode.aspx html xmlns="http://www.w3.org/1999/xhtml"head runat="server" title/title/headbody form id="form1" runat="server" div table class="table_bgcolor" tr td style="width: 100%; text-align: left;" class="table_titlebgcolor" 工作

自定义表单设计之八-流程节点字段配置_字段

FieldViewOfNode.aspx

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="table_bgcolor">
            <tr>
                <td style="width: 100%; text-align: left;" class="table_titlebgcolor">
                    工作流配置:节点字段
                </td>
            </tr>
            <tr>
                <td style="width: 100%; text-align: left;">
                    <asp:GridView runat="server" ID="FieldViewGridView" DataKeyNames="id,fieldid,detailtable"
                        SkinID="GridViewSkin" AutoGenerateColumns="false" OnRowDataBound="FieldViewGridView_RowDataBound">
                        <Columns>
                            <asp:TemplateField HeaderText="位置">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="ViewTypeLabel" Text='<%#Eval("viewtype") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="fieldid" HeaderText="字段编号" />
                            <asp:BoundField DataField="fieldname" HeaderText="字段名称" />
                            <asp:BoundField DataField="fieldlabel" HeaderText="显示名" />
                            <asp:TemplateField HeaderText="可见">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsViewCheckBox" Checked='<%# Eval("isview").ToString() == "y" ? true : false%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="可编辑">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsEditCheckBox" Checked='<%#Eval("isedit").ToString() == "y" ? true : false %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="必填">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="MandatoryCheckBox" Checked='<%#Eval("ismandatory").ToString() == "y" ? true : false %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="排序">
                                <ItemTemplate>
                                    <asp:TextBox runat="server" Width="60" ID="OrderIDTextBox" Text='<%#Bind("orderid") %>'></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
            <td style="width: 100%; text-align: left;">
            明细表操作
            </td>
            </tr>
            <tr>
                <td style="width: 100%; text-align: left;">
                    <asp:GridView runat="server" ID="DetailTableGridView" DataKeyNames="nodeguid,groupid"
                        SkinID="GridViewSkin" AutoGenerateColumns="false">
                        <Columns>
                            <asp:TemplateField HeaderText="序号">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="明细表名">
                                <ItemTemplate>
                                    <%#Eval("tablename") %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="允许新增明细">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsAddCheckBox" Checked='<%# Eval("isadd").ToString() == "y" ? true : false%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="允许修改已有明细">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsEditCheckBox" Checked='<%# Eval("isedit").ToString() == "y" ? true : false%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="允许删除已有明细">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsDeleteCheckBox" Checked='<%# Eval("isdelete").ToString() == "y" ? true : false%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="是否打印空明细">
                                <ItemTemplate>
                                    <asp:CheckBox runat="server" ID="IsHideNullCheckBox" Checked='<%# Eval("ishidenull").ToString() == "y" ? true : false%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td style="width: 100%; text-align: center;">
                    <asp:Button runat="server" ID="SaveButton" Text=" 保 存 " OnClick="onSaveButtonClick" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

FieldViewOfNode.aspx.cs

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                initialNodeFieldView();
                initialDetailTableGridView();
            }
        }

        #region EventHandler
        protected void FieldViewGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label ViewTypeLabel = e.Row.FindControl("ViewTypeLabel") as Label;
                if (ViewTypeLabel.Text == "0")
                {
                    ViewTypeLabel.Text = "主表";
                }
                else
                {
                    string detailtable = FieldViewGridView.DataKeys[e.Row.RowIndex]["detailtable"].ToString();
                    ViewTypeLabel.Text = detailtable;
                }
            }
        }

        protected void onSaveButtonClick(object sender, EventArgs e)
        {
            string nodeguid = Request.QueryString["NodeID"];
            foreach (GridViewRow row in FieldViewGridView.Rows)
            {
                int fieldid = (int)FieldViewGridView.DataKeys[row.RowIndex]["fieldid"];

                CheckBox IsViewCheckBox = row.FindControl("IsViewCheckBox") as CheckBox;
                CheckBox IsEditCheckBox = row.FindControl("IsEditCheckBox") as CheckBox;
                CheckBox MandatoryCheckBox = row.FindControl("MandatoryCheckBox") as CheckBox;
                TextBox OrderIDTextBox = row.FindControl("OrderIDTextBox") as TextBox;
                decimal orderid = 0M;
                decimal.TryParse(OrderIDTextBox.Text, out orderid);
                int id = 0;
                if (DBNull.Value != FieldViewGridView.DataKeys[row.RowIndex]["id"])
                {
                    id = (int)FieldViewGridView.DataKeys[row.RowIndex]["id"];
                }
                M.workflow_nodeform nodeformModel = null;
                if (id > 0)
                {
                    nodeformModel = nodeformBLL.GetModel(id);
                }
                if (id == 0)
                {//新加
                    nodeformModel = new M.workflow_nodeform();
                    nodeformModel.fieldid = fieldid;
                    nodeformModel.nodeguid = nodeguid;
                }
                nodeformModel.isview = IsViewCheckBox.Checked ? "y" : "n";
                if (IsViewCheckBox.Checked)
                {//字段可见
                    nodeformModel.isedit = IsEditCheckBox.Checked ? "y" : "n";
                    nodeformModel.ismandatory = MandatoryCheckBox.Checked ? "y" : "n";
                    if (false == IsEditCheckBox.Checked)
                    {//不可编辑
                        nodeformModel.ismandatory = "";
                    }
                }
                else
                {//
                    nodeformModel.isedit = "";
                    nodeformModel.ismandatory = "";
                }
                nodeformModel.orderid = orderid;
                if (id > 0)
                {//修改
                    nodeformBLL.Update(nodeformModel);
                }
                else
                {//添加
                    nodeformBLL.Add(nodeformModel);
                }
            }
            initialNodeFieldView();

            int groupid = -1;
            string isAdd = "n";
            string isEdit = "n";
            string isDelete = "n";
            string isHideNull = "n";
            foreach (GridViewRow row in DetailTableGridView.Rows)
            {
                CheckBox IsAddCheckBox = row.FindControl("IsAddCheckBox") as CheckBox;
                isAdd = IsAddCheckBox.Checked ? "y" : "n";
                CheckBox IsEditCheckBox = row.FindControl("IsEditCheckBox") as CheckBox;
                isEdit = IsEditCheckBox.Checked ? "y" : "n";
                CheckBox IsDeleteCheckBox = row.FindControl("IsDeleteCheckBox") as CheckBox;
                isDelete = IsDeleteCheckBox.Checked ? "y" : "n";
                CheckBox IsHideNullCheckBox = row.FindControl("IsHideNullCheckBox") as CheckBox;
                isHideNull = IsHideNullCheckBox.Checked ? "y" : "n";
                groupid = (int)DetailTableGridView.DataKeys[row.RowIndex]["groupid"];
                M.workflow_NodeFormGroup nodeFormGroupModel = nodeFormGroupBLL.GetModel(nodeguid, groupid);
                if (nodeFormGroupModel != null)
                {//update
                    nodeFormGroupModel.isadd = isAdd;
                    nodeFormGroupModel.isedit = isEdit;
                    nodeFormGroupModel.isdelete = isDelete;
                    nodeFormGroupModel.ishidenull = isHideNull;
                    nodeFormGroupBLL.Update(nodeFormGroupModel);
                }
                else
                {//add
                    nodeFormGroupModel = new M.workflow_NodeFormGroup();
                    nodeFormGroupModel.nodeguid = nodeguid;
                    nodeFormGroupModel.groupid = groupid;
                    nodeFormGroupModel.isadd = isAdd;
                    nodeFormGroupModel.isedit = isEdit;
                    nodeFormGroupModel.isdelete = isDelete;
                    nodeFormGroupModel.ishidenull = isHideNull;
                    nodeFormGroupBLL.Add(nodeFormGroupModel);
                }
            }
            initialDetailTableGridView();
        }
        #endregion //End EventHandler

        #region Helper Methods
        private void initialNodeFieldView()
        {
            string nodeid = Request.QueryString["NodeID"];
            M.WF_Activity activityModel = activityBLL.GetModel(new Guid(nodeid));

            int formid = 0;
            formid = int.Parse(Request.QueryString["FormID"]);
            
            if (formid == 0)
            {
                Common.MessageBox.Show(this, "还没有挂接表单!");
                return;
            }
            DataSet nodeformDS = nodeformBLL.GetList(formid, nodeid);
            DataView dv = null;
            if (nodeformDS.Tables.Count > 0)
            {
                dv = nodeformDS.Tables[0].DefaultView;
                dv.Sort = "viewtype,orderid";
            }
            FieldViewGridView.DataSource = dv;
            FieldViewGridView.DataBind();
        }

        private void initialDetailTableGridView()
        {
            string nodeguid = Request.QueryString["NodeID"];
            M.WF_Activity activityModel = activityBLL.GetModel(new Guid(nodeguid));
            M.WF_Process processModel = processBLL.GetModel(activityModel.WorkFlowID);

            int formid = 0;
            formid = int.Parse(Request.QueryString["FormID"]);
            if (formid == 0)
            {
                return;
            }
            List<M.workflow_billdetailtable> billdetailtableList = billdetailtableBLL.GetModelList("billid=" + formid + " order by orderid");
            if (billdetailtableList == null)
            {
                return;
            }
            DetailTableGridView.DataSource = nodeFormGroupBLL.GetList(nodeguid, "1=1 order by orderid");
            DetailTableGridView.DataBind();
        }
        #endregion //End Helper Methods


上一篇:数字转化为罗马数字
下一篇:没有了
网友评论