protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
var chk = row.FindControl("chkDelete") as CheckBox;
if (chk.Checked)
{
var lblID = row.FindControl("lblID") as Label;
var lblMC = row.FindControl("lblMC") as Label;
var lblEmployeeID = row.FindControl("lblEmployeeID") as Label;
var lblName = row.FindControl("lblName") as Label;
var lblLastName = row.FindControl("lblLastName") as Label;
var lblDep = row.FindControl("lblDep") as Label;
var lblFaction = row.FindControl("lblFaction") as Label;
var lblShife = row.FindControl("lblShife") as Label;
var lblDay = row.FindControl("lblDay") as Label;
var lblTimeStart = row.FindControl("lblTimeStart") as Label;
var lblTimeEnd = row.FindControl("lblTimeEnd") as Label;
var lblCar = row.FindControl("lblCar") as Label;
var lblFood = row.FindControl("lblFood") as Label;
var lblRemark = row.FindControl("lblRemark") as Label;
// Response.Write(lblID.Text + "<br>");
SqlCommand comm = new SqlCommand();
comm.CommandText = "insert into ApproveGA_HR (id,MC,EmployeeID,Name,LastName,Dep,Faction,Shife,Day,TimeStart,TimeEnd,Car,Food,Remark) Values (@id,@MC,@EmployeeID,@Name,@LastName,@Dep,@Faction,@Shife,@Day,@TimeStart,@TimeEnd,@Car,@Food,@Remark)";
//comm.CommandText = "delete from Detail where id=@id";
comm.Parameters.AddWithValue("@id", int.Parse(lblID.Text));
comm.Parameters.AddWithValue("@MC", Convert.ToString(lblMC.Text));
comm.Parameters.AddWithValue("@EmployeeID", int.Parse(lblEmployeeID.Text));
comm.Parameters.AddWithValue("@Name", Convert.ToString(lblName.Text));
comm.Parameters.AddWithValue("@LastName", Convert.ToString(lblLastName.Text));
comm.Parameters.AddWithValue("@Dep", Convert.ToString(lblDep.Text));
comm.Parameters.AddWithValue("@Faction", Convert.ToString(lblFaction.Text));
comm.Parameters.AddWithValue("@Shife", Convert.ToString(lblShife.Text));
comm.Parameters.AddWithValue("@Day", Convert.ToString(lblDay.Text));
comm.Parameters.AddWithValue("@TimeStart", Convert.ToString(lblTimeStart.Text));
comm.Parameters.AddWithValue("@TimeEnd", Convert.ToString(lblTimeEnd.Text));
comm.Parameters.AddWithValue("@Car", Convert.ToString(lblCar.Text));
comm.Parameters.AddWithValue("@Food", Convert.ToString(lblFood.Text));
comm.Parameters.AddWithValue("@Remark", Convert.ToString(lblRemark.Text));
comm.Connection = con1;
//comm.Parameters.AddWithValue("@id", int.Parse(lblID.Text));
con1.Open();
comm.ExecuteNonQuery();
con1.Close();
//LoadGridView1();
}
}
}