Example #1
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {
            string SessionIDName = "VAM281_" + PageTimeStamp.Value;
            DataTable dtA = (DataTable)Session[SessionIDName];
            LinkButton btn = sender as LinkButton;
            GridViewRow gr = (btn.BindingContainer as GridViewRow);
            int i = gr.RowIndex;

            ArrayList ParameterDel = new ArrayList();
            ParameterDel.Add(dtA.Rows[i]["ID"].ToString());
            ParameterDel.Add(Session["UID"].ToString());
            ParameterDel.Add(dtA.Rows[i]["UPDATEDATE"].ToString());
            ParameterDel.Add(dtA.Rows[i]["UPDATEUID"].ToString());

            VAM28_BCO BCO = new VAM28_BCO(ConntionDB);
            BCO.DeleteOilSubsidyRecord(ParameterDel, null);

            DataRow drA = null;
            drA = dtA.Select("ID=" + dtA.Rows[i]["ID"].ToString())[0];
            drA.Delete();
            dtA.AcceptChanges();

            Session[SessionIDName] = dtA;
            this.GridView1.DataSource = dtA;
            this.GridView1.DataBind();

            if (dtA.Rows.Count > 0)
            {
                StringCollection sc = new StringCollection();
                foreach (DataRow dr in dtA.Rows)
                {
                    sc.Add(dr["ID"].ToString());
                }

                Session["VAM28CodeCollection" + PageTimeStamp.Value] = sc;
            }

            ErrorMsgLabel.Text = "刪除成功";
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }