管理员批准/拒绝一份文件 [英] admin approve/reject in one document

查看:74
本文介绍了管理员批准/拒绝一份文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成批准/拒绝文件但是有问题



假设在管理员登录时网格视图中有3个文档并且只想批准/拒绝1文件即docid 81并点击提交按钮然后数据保存在数据库中



批准表

i done with approve/reject documents but there is a problem

suppose there is a 3 documents in grid view when admin login and want to approve/reject only 1 document i.e docid 81 and click on submit button then data save in database

approval table

**seqno docid approveid  approveby**
79     14      3       john
80     16      3       john
81     17      2      john





但在我的代码中,当管理员批准/拒绝仅1(即81 docid)文档而管理员没有在其他两个工作,然后管理员点击提交按钮然后其他两个文件数据也保存在批准(即79,80 docid)表。 。为什么会这样?



这里是提交按钮代码





but in my code when admin approve/reject only 1 (i.e 81 docid) document whereas admin not worked in others two then admin click on submit button then other two documents data are also save in approval (i.e 79,80 docid)table ..why this happened?

here is submit button code

protected void Button1_Click(object sender, EventArgs e)
    {

        string connStr = 
        ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
        SqlConnection mySQLconnection = new SqlConnection(connStr);
        if (mySQLconnection.State == ConnectionState.Closed)
        {
            mySQLconnection.Open();
        }

        foreach (GridViewRow row in GrdFileApprove.Rows)
        {

            if (row.RowType == DataControlRowType.DataRow)
            {
                DropDownList DropDownListcontrol = row.FindControl("DropDownList4") as
             DropDownList;
                SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
                cmd.CommandType = CommandType.StoredProcedure;                
                cmd.Parameters.Add("@DocID", SqlDbType.Int).Value = 
              Convert.ToInt32((row.Cells[1].Text));
                cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value = 
               Convert.ToInt32(DropDownListcontrol.SelectedValue);
                cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value = 
               (Session["Login2"]);
                cmd.ExecuteNonQuery();
                DMSLIB.Doc myDoc = new DMSLIB.Doc();
                myDoc.MarkDocAs(Convert.ToInt16(row.Cells[1].Text), Convert.ToInt32(DropDownListcontrol.SelectedValue));


            }
            else
            {
                apfi.Text = "Error";
            }
        }


        if (mySQLconnection.State == ConnectionState.Open)
        {
            mySQLconnection.Close();
        }

推荐答案

您好,



您可以使用一个gridview选项,而不是使用单独的Button来实现此功能。



选项1:

在Gridview中,您可以选择添加[命令类型 - >按钮控制]

按钮将在每一行上可用,您点击的按钮将生成事件,并且可以在代码后面处理您的特定操作。



在这里查找示例应用程序。



行更新事件 [ ^ ]





选项2:

您可以为每一行添加一个复选框控件,最后当您单击提交按钮时,然后在执行操作时可以检查每一行网格,并仅更新数据表复选框状态被检查,否则丢弃。

注意:如果你有1000多行,在这种方法中,所有行都需要遍历,这不是最佳的。



谢谢!
Hi,

You may use a gridview option rather using an individual Button for this functionality.

Option 1:
In Gridview, you have a option to add the [Command Type -> Button Controls]
Button will be available on each Row and which ever button you click the event will be generated and that can be handled in code Behind to your specific operations.

Find sample application here.

Row updating event in gridview ASP.NET[^]


Option 2:
You can add a Check box control for each Row, finally when you click Submit Button, then as you are doing you can check each row of grid, and update Databse only the Check box status is checked else discard.
Note: If you have 1000+ rows, in this approach all the rows needs to be traversed which is not optimal.

Thanks!


这篇关于管理员批准/拒绝一份文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆