protected void btn_eliminarClick(object sender, EventArgs e) // Panel Eliminar { try { foreach (GridViewRow row in GridView1.Rows) { if (row.RowIndex == GridView1.SelectedIndex) { //GridView1.SelectedRow.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Delete$" + GridView1.SelectedRow.RowIndex); GridView1.DeleteRow(row.RowIndex); //GridView1.SetEditRow(row.RowIndex); //GridView1.SelectRow(GridView1.SelectedIndex); row.BackColor = ColorTranslator.FromHtml("#A1DCF2"); //GridView1.SelectedRow.BackColor = ColorTranslator.FromHtml("#A1DCF2"); row.ToolTip = string.Empty; } else { row.BackColor = GridView1.BackColor; //row.BackColor = ColorTranslator.FromHtml("#FFFFFF"); //row.ToolTip = "Click to select this row."; } } } catch (Exception ex) { } }
protected void deleterow_ServerClick(object sender, EventArgs e) { var DeletButton = (Control)sender; GridViewRow row = (GridViewRow)DeletButton.NamingContainer; GridView1.DeleteRow(row.RowIndex); }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; int appointment_ID = Convert.ToInt32(row.Cells[1].Text); int student_ID = Convert.ToInt32(row.Cells[2].Text); appointment.Appointment_Id = appointment_ID; appointment.Student_Id = student_ID; appointment.Reason = txtComments.Value; try { appointment.updateValues(); GridView1.DeleteRow(GridView1.SelectedIndex); ScriptManager.RegisterStartupScript( this, this.GetType(), "MessageBox", "alert('Appointment has been cancelled');", true); } catch (Exception ex) { throw new Exception(ex.ToString(), ex); } clear(); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { GridView1.DeleteRow(e.RowIndex); }catch (Exception ee) { Console.WriteLine(ee); } }
protected void GridView1_RowDeleting(Object sender, GridViewDeleteEventArgs e) { GridView1.DeleteRow(e.RowIndex); var time = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("Time"); var date = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("Session Date"); string delete_command = "DELETE FROM Booking WHERE SessionTime=" + time + " and SessionDate=" + date; GridView1.DataBind(); }
/// <summary> /// 删行 /// </summary> private void btnDelRow() { for (int i = GridView1.RowCount - 1; i >= 0; i--) { if (GridView1.IsRowSelected(i)) { GridView1.DeleteRow(i); } } }
protected void btXoa_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox item = (CheckBox)GridView1.Rows[i].Cells[0].Controls[1]; if (item.Checked) { GridView1.DeleteRow(i); } } }
protected void RemoveSelectedRows(object sender, EventArgs e) { var result = (from o in GridView1.Rows.Cast <GridViewRow>() let cell = o.Cells[0] let checkbox = cell.Controls[1] as CheckBox where checkbox != null && checkbox.Checked select o); foreach (var row in result) { GridView1.DeleteRow(row.RowIndex); } }
protected void btnQuitarSeleccionados_Click(Object sender, EventArgs e) { //Recorrer las filas del GridView... for (int i = 0; i <= (GridView1.Rows.Count - 1); i++) { CheckBox chkElim = GridView1.Rows[i].FindControl("chkEliminar") as CheckBox; if (chkElim.Checked) { borraMasivo = true; GridView1.DeleteRow(i); } } borraMasivo = false; LlenarTabla(); }
protected void btn_eliminarClick(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowIndex == GridView1.SelectedIndex) { GridView1.DeleteRow(row.RowIndex); row.BackColor = ColorTranslator.FromHtml("#A1DCF2"); row.ToolTip = string.Empty; } else { row.BackColor = GridView1.BackColor; } } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Remove") { // Retrieve the row index stored in the // CommandArgument property. int index = Convert.ToInt32(e.CommandArgument); myListS = (List <string>)Session["cartSession"]; myListS.RemoveAt(index); GridView1.DeleteRow(index); GridView1.DataBind(); Response.Redirect(Request.RawUrl); // Retrieve the row that contains the button // from the Rows collection. //GridViewRow row = GridView1.Rows[index]; // Add code here to add the item to the shopping cart. } }
protected void DeleteCountry_Click(object sender, EventArgs e) { GridView1.DeleteRow(Convert.ToInt32(GridView1.SelectedRow.ID)); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridView1.DeleteRow(int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString())); }
public void RowDeletin(GridViewDeleteEventArgs e) { GridView1.DeleteRow(e.RowIndex); GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { int row = GridView1.Rows.Count; for (int i = 0; i < row; i++) { TextBox txt = (TextBox)GridView1.Rows[i].Cells[7].FindControl("TextBox1"); txt.ReadOnly = true; txt.BackColor = System.Drawing.Color.Yellow; } DatabaseManagement dm = new DatabaseManagement(); OracleConnection conn = dm.dbaseConn(); dm.connOpen(conn); int flag = 1; row = GridView1.Rows.Count; for (int i = 0; i < row; i++) { TextBox txt = (TextBox)GridView1.Rows[i].Cells[7].FindControl("TextBox1"); int quantity = int.Parse(txt.Text); /*quantity*/ int stock = int.Parse(GridView1.Rows[i].Cells[6].Text); if (quantity == 0) { string deletedpid = GridView1.Rows[i].Cells[2].Text; string delete_query = "delete from dummytable where pid='" + deletedpid + "'"; //dm.InsertRow(delete_query, conn); SqlDataSource1.DeleteCommand = delete_query; GridView1.DeleteRow(i); Label2.Text = "0"; flag = 0; } else if ((stock - quantity) <= 10) { GridView1.Rows[i].Cells[8].Text = "minimun stock can be 10"; GridView1.Rows[i].Cells[8].BackColor = System.Drawing.Color.Red; Label1.Text = (stock - quantity).ToString(); flag = 0; } } if (flag == 1) { int new_row = GridView1.Rows.Count; for (int i = 0; i < new_row; i++) { string pid = GridView1.Rows[i].Cells[2].Text; string name = GridView1.Rows[i].Cells[3].Text; TextBox txt = (TextBox)GridView1.Rows[i].Cells[7].FindControl("TextBox1"); int quantity = int.Parse(txt.Text); string stock = GridView1.Rows[i].Cells[6].Text; string unitprice = GridView1.Rows[i].Cells[4].Text; string date = GridView1.Rows[i].Cells[5].Text; string order_product_query = "insert into order_product values('" + pid + "','" + name + "'," + int.Parse(unitprice) + "," + int.Parse(stock) + "," + quantity + ")"; dm.InsertRow(order_product_query, conn); string shop_10_query = "insert into shop_10 values('" + Session["saleid"].ToString() + "','" + name + "'," + quantity + "," + unitprice + ")"; dm.InsertRow(shop_10_query, conn); /*stock update*/ int update_stock = (int.Parse(stock) - quantity); string update_stock_product_6_query = "update product_6 set stock=" + update_stock + "where pid='" + pid + "'"; Label1.Text = update_stock_product_6_query; dm.InsertRow(update_stock_product_6_query, conn); /*insert into database*/ } string dateofsale = GridView1.Rows[0].Cells[5].Text; string rep_4_query = "insert into rep_4 values('" + Session["rid"].ToString() + "','" + Session["saleid"].ToString() + "','" + Session["shopid"].ToString() + "',sysdate,'ok')"; //Label1.Text = rep_4_query; dm.InsertRow(rep_4_query, conn); string sale_query = "insert into sale values('" + Session["saleid"].ToString() + "',to_char(sysdate,'DD-MON-YYYY'))"; //Label2.Text = sale; dm.InsertRow(sale_query, conn); string schedule_11_query = "insert into schedule_11 values('" + Session["saleid"].ToString() + "',sysdate,'" + datofdelivery + "')"; // Label2.Text += " " + schedule_11_query; dm.InsertRow(schedule_11_query, conn); string shop_9_query = "insert into shop_9 values('" + Session["saleid"].ToString() + "','" + Session["shopid"].ToString() + "'," + cost + ",0)"; //Label3.Text = shop_9_query; dm.InsertRow(shop_9_query, conn); string bonusinfo_query = "update bonusinfo set totalorder=(totalorder+" + cost + ") where rid='" + Session["rid"].ToString() + "'"; //Label1.Text = bonusinfo_query; dm.InsertRow(bonusinfo_query, conn); /*insert into database*/ /*bonus calculation*/ string get_target = "select * from bonusinfo where rid='" + Session["rid"].ToString() + "'"; string target = dm.ReadRow(get_target, conn)["totaltarget"].ToString(); string bonus_str = dm.ReadRow(get_target, conn)["totalbonus"].ToString(); string totalorder = dm.ReadRow(get_target, conn)["totalorder"].ToString(); double final_total_order = double.Parse(totalorder) + cost; Label1.Text = final_total_order.ToString(); double total_target = double.Parse(target); double bonus = double.Parse(bonus_str); if (final_total_order >= total_target) { if (final_total_order == total_target) { bonus = bonus + 500; } else { bonus = bonus + ((final_total_order - total_target) * .05); } string update_bonusinfo = "update bonusinfo set totaltarget=" + (total_target + 50000) + ",totalbonus=" + bonus + " where rid='" + Session["rid"].ToString() + "'"; Label1.Text = update_bonusinfo; dm.InsertRow(update_bonusinfo, conn); } string delete_saleid_query = "delete from dummytable where saleid='" + Session["saleid"].ToString() + "'"; dm.InsertRow(delete_saleid_query, conn); /*notification starts here*/ string confirm_notify = "insert into notification(ncounter,rid,shopid,saleid) values(2,'" + Session["rid"].ToString() + "','" + Session["shopid"].ToString() + "','" + Session["saleid"].ToString() + "')"; dm.InsertRow(confirm_notify, conn); dm.connClose(conn); Response.Redirect("~/ComfirmOrder.aspx?" + Session["saleid"].ToString()); //} } dm.connClose(conn); }