protected void btnDel_Click(object sender, EventArgs e) { try { string SessionIDName = "VAM321_" + 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 = null; if (dtA.Rows[i]["ITEM"].ToString().Trim() == "") { drA = dtA.Select("VENDOR='" + dtA.Rows[i]["VENDOR"].ToString() + "'")[0]; } else { drA = dtA.Select("VENDOR='" + dtA.Rows[i]["VENDOR"].ToString() + "' And ITEM ='" + dtA.Rows[i]["ITEM"].ToString() + "'")[0]; } CAMCommon CAMCommonBCO = new CAMCommon(); ArrayList ParameterList = new ArrayList(); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(drA["VENDOR"].ToString(), "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(drA["ITEM"].ToString(), "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(Session["UID"].ToString(), "string", false)); VAM32_BCO BCO = new VAM32_BCO(ConntionDB); string[] strResult = BCO.DeleteShipSubsidy(ParameterList, null); if (strResult[0] == "1") { drA.Delete(); dtA.AcceptChanges(); Session[SessionIDName] = dtA; this.GridView1.DataSource = dtA; this.GridView1.DataBind(); if (dtA.Rows.Count > 0) { StringCollection sc = new StringCollection(); string strVendor = ""; foreach (DataRow dr in dtA.Rows) { if (strVendor != dr["VENDOR"].ToString()) { sc.Add(dr["VENDOR"].ToString()); } strVendor = dr["VENDOR"].ToString(); } Session["VAM32CodeCollection"] = sc; } } ErrorMsgLabel.Text = strResult[1]; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }
private void BindData() { CAMCommon CAMCommonBCO = new CAMCommon(); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_VENDOR_S.Text, "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_VENDOR_E.Text, "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_ITEM_S.Text, "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_ITEM_E.Text, "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEDATE.StartDate, "date", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEDATE.EndDate, "date", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEUID.Text, "string", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEDATE.StartDate, "date", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEDATE.EndDate, "date", false)); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEUID.Text, "string", false)); ParameterList.Add((TextBoxRowCountLimit.Text == "") ? "100" : (int.Parse(TextBoxRowCountLimit.Text) < 0) ? "100" : TextBoxRowCountLimit.Text); ParameterList.Add(CAMCommonBCO.GetValueSetParameter(Session["UID"].ToString(), "string", false)); VAM32_BCO BCO = new VAM32_BCO(ConntionDB); DataTable dt = BCO.QueryShipSubsidyByFind(ParameterList); string SessionIDName = "VAM321_" + PageTimeStamp.Value; Session[SessionIDName] = dt; GridView1.DataSource = dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 20 : (int.Parse(TextBoxPagesize.Text) < 0) ? 20 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (dt.Rows.Count > 0) { StringCollection sc = new StringCollection(); string strVendor = ""; foreach (DataRow dr in dt.Rows) { if (strVendor != dr["VENDOR"].ToString()) { sc.Add(dr["VENDOR"].ToString()); } strVendor = dr["VENDOR"].ToString(); } Session["VAM32CodeCollection"] = sc; } else { ErrorMsgLabel.Text = "查無資料"; } }