Exemple #1
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {

            string SessionIDName = "VAM071_gv_ItemInfo" + PageTimeStamp.Value;
            DataTable dtA = new DataTable();
            dtA = (DataTable)Session[SessionIDName];
            LinkButton btn = sender as LinkButton;
            GridViewRow gr = (btn.BindingContainer as GridViewRow);
            int i = gr.RowIndex;
            DataRow drA = dtA.Select("DISC_NO='" + dtA.Rows[i]["DISC_NO"].ToString() + "'")[0];

            ArrayList ParameterDel = new ArrayList();
            ParameterDel.Add(GetValueSetParameter(drA["DISC_NO"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false));
            ParameterDel.Add(Session["UID"].ToString());
            ParameterDel.Add(System.DateTime.Now);
            BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB);
            bco.DeleteDiscountInvoice(ParameterDel, null);
            drA.Delete();
            dtA.AcceptChanges();
            Session[SessionIDName] = dtA;
            this.GridView1.DataSource = dtA;
            this.GridView1.DataBind();

            ArrayList NOList = new ArrayList();
            for (int j = 0; j < dtA.Rows.Count; j++)
            {
                string[] strNO = new string[2];
                strNO[0] = dtA.Rows[j]["DISC_NO"].ToString();
                strNO[1] = SessionIDName;
                NOList.Add(strNO);
            }

            Session["VAM071Query" + SessionIDName] = NOList;
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('刪除成功');", true);
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("位置0") == -1)
                ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者異動,請重新查詢再進行編輯。";
            else
                ErrorMsgLabel.Text = ex.Message;
        }
        //finally { }
    }
Exemple #2
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dtA = (DataTable)Session[this.hidSessionName.Value];
            DataRow drA = dtA.Select("DISC_NO='" + this.TextBox5.Text + "'")[0];


            ArrayList ParameterDel = new ArrayList();
            ParameterDel.Add(GetValueSetParameter(drA["DISC_NO"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEDATE"].ToString(), "datetime", false));
            ParameterDel.Add(GetValueSetParameter(drA["UPDATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEUID"].ToString(), "string", false));
            ParameterDel.Add(GetValueSetParameter(drA["CREATEDATE"].ToString(), "datetime", false));
            ParameterDel.Add(Session["UID"].ToString());
            ParameterDel.Add(System.DateTime.Now);
            BCO.MaintainDiscountInvoice bco = new BCO.MaintainDiscountInvoice(ConnectionDB);
            bco.DeleteDiscountInvoice(ParameterDel, null);
            //drA.Delete();
            //dtA.AcceptChanges();
            //Session[SessionIDName] = dtA;
            //this.GridView1.DataSource = dtA;
            //this.GridView1.DataBind();

            //ArrayList NOList = new ArrayList();
            //for (int j = 0; j < dtA.Rows.Count; j++)
            //{
            //    string[] strNO = new string[2];
            //    strNO[0] = dtA.Rows[j]["DISC_NO"].ToString();
            //    strNO[1] = SessionIDName;
            //    NOList.Add(strNO);
            //}

            //Session["VAM071Query" + SessionIDName] = NOList;
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('刪除成功');", true);
            ErrorMsgLabel.Text = "刪除成功";
            this.btnDel.Enabled = false;
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("位置0") == -1)
                ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者異動,請重新查詢再進行編輯。";
            else
                ErrorMsgLabel.Text = ex.Message;
        }
        //finally { }
    }