con = new SqlConnect(); con.SqlQuery("Select * from DeductionInfo"); ListViewDed(); //LvDeductions.Items.Clear(); con = new SqlConnect(); con.SqlQuery("Select Firstname, Lastname, Department, Position from EmpRecord inner join EmpRecord2 on EmpRecord.empID = EmpRecord2.empID where EmpRecord.empID = @id"); con.cmd.Parameters.AddWithValue("@id", lblEmpID.Text); sdr = con.cmd.ExecuteReader(); if (sdr.Read()) { lblEmployeeName.Text = sdr[1].ToString() + "," + " " + sdr[0].ToString(); lblEmpDept.Text = sdr[2].ToString() + "," + " " + sdr[3].ToString(); } con = new SqlConnect(); con.SqlQuery("Select * from EmployeeDeduct where EmployeeeID = @empID"); con.cmd.Parameters.AddWithValue("@empID", lblEmpID.Text); sda = new SqlDataAdapter(con.cmd); ds = new DataSet(); sda.Fill(ds); con.cmd.Connection.Close(); if (ds.Tables[0].Rows.Count > 0) { for (int g = 0; g < ds.Tables[0].Rows.Count; g++) { con = new SqlConnect(); con.SqlQuery("Select * from DeductionInfo"); sda = new SqlDataAdapter(con.cmd); DataSet ds2 = new DataSet(); sda.Fill(ds2); con.cmd.Connection.Close(); if (ds2.Tables[0].Rows.Count > 0) { for (int j = 0; j < ds2.Tables[0].Rows.Count; j++) { if (ds.Tables[0].Rows[g].ItemArray[0].ToString() == ds2.Tables[0].Rows[j].ItemArray[6].ToString()) { LvDeductions.Items[j].Checked = true; } } } } }
LvDeductions.Items[j].Checked = true;
con = new SqlConnect(); con.SqlQuery("Select * from DeductionInfo where DeductID like @id"); con.cmd.Parameters.AddWithValue("@id", ds2.Tables[0].Rows[j].ItemArray[6].ToString()+"");
con.cmd.Parameters.AddWithValue("@id", ds2.Tables[0].Rows[j].ItemArray[6].ToString()+"%");