Exemple #1
0
        /// <summary>
        /// 核准
        /// </summary>
        protected void ApproveButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = LocalGlobal.DbConnect();

            con.Open();
            SqlTransaction tran = con.BeginTransaction();//使用事务
            SqlCommand     cmd  = new SqlCommand();

            cmd.Connection  = con;
            cmd.Transaction = tran;

            using (PurProvider purProvider = new PurProvider())
            {
                try
                {
                    bool flag = false;
                    foreach (GridViewRow row in DetailList.Rows)
                    {
                        HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck");
                        if (rowCheckControl.Checked)
                        {
                            string prNo = row.Cells[1].Text.Trim();
                            string seq  = row.Cells[2].Text.Trim();

                            cmd.CommandText = purProvider.ApprovePr(prNo, seq);
                            cmd.ExecuteNonQuery();

                            flag = true;
                        }
                    }

                    if (flag)
                    {
                        tran.Commit();
                        this.BindList();
                    }
                    else
                    {
                        this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage"));
                        tran.Rollback();
                        return;
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    this.ShowErrorMessage("提交失败。" + error.Message);
                    return;
                }
            }
        }