Beispiel #1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string id = e.CommandArgument.ToString();

        if (e.CommandName.ToString() == "Detail")
        {
            Response.Redirect("MemberCash.aspx?id=" + id);
        }
        else if (e.CommandName.ToString() == "Del")
        {
            DataTable dt = RegistermemberBLL.QueryWithdraw(id);
            if (dt.Rows.Count > 0)
            {
                if (RegistermemberBLL.GetAuditState(int.Parse(id)) == 1)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + GetTran("007174", "该申请单已经审核,不可以删除!") + ")');</script>");
                    bind();
                    return;
                }
                if (RegistermemberBLL.GetAuditState(int.Parse(id)) == 2)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + GetTran("007986", "该申请单已经开始处理,不可以删除!") + "');</script>");
                    bind();
                    return;
                }
                if (RegistermemberBLL.GetAuditState(int.Parse(id)) == 3)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + GetTran("007987", "该申请单已经是账号错误,不可以删除!") + "');</script>");
                    bind();
                    return;
                }

                using (SqlConnection conn = new SqlConnection(DAL.DBHelper.connString))
                {
                    conn.Open();
                    SqlTransaction tran = conn.BeginTransaction();
                    try
                    {
                        if (!DAL.ECTransferDetailDAL.DeleteWithdraw(tran, int.Parse(id), Convert.ToDouble(dt.Rows[0]["WithdrawMoney"].ToString()), dt.Rows[0]["number"].ToString()))
                        {
                            tran.Rollback();
                            ScriptHelper.SetAlert(Page, GetTran("000417", "删除失败!"));
                            bind();
                            return;
                        }
                        else
                        {
                            tran.Commit();
                            ScriptHelper.SetAlert(Page, GetTran("000749", "删除成功!"));
                            bind();
                        }
                    }
                    catch {
                        tran.Rollback();
                        ScriptHelper.SetAlert(Page, GetTran("000417", "删除失败!"));
                        bind();
                    }
                }
            }
            else
            {
                ScriptHelper.SetAlert(Page, GetTran("000861", "不能重复删除!"));
            }
        }
    }