private void populateData() { DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); DataTable dt3 = new DataTable(); //SqlDataReader reader; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { using (SqlCommand command = new SqlCommand("sp_employee_balance", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@empid", sec.getempid()); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); dt.Load(reader); dt1.Load(reader); dt2.Load(reader); dt3.Load(reader); } catch (SqlException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } if (dt.Rows.Count > 0) { Lbl_empWin.Text = dt.Rows[0][0].ToString(); Lbl_empName.Text = (string)dt.Rows[0][1]; Lbl_leaveBalance.Text = dt.Rows[0][3].ToString(); Lbl_leaveTaken.Text = dt.Rows[0][2].ToString(); } if (dt1.Rows.Count > 0) { GV_LeaveDetails.DataSource = dt1; GV_LeaveDetails.DataBind(); GV_LeaveDetails.HeaderRow.TableSection = TableRowSection.TableHeader; } if (dt2.Rows.Count > 0) { GV_leaveTaken.DataSource = dt2; GV_leaveTaken.DataBind(); GV_leaveTaken.HeaderRow.TableSection = TableRowSection.TableHeader; } if (dt3.Rows.Count > 0) { GV_yearBalence.DataSource = dt3; GV_yearBalence.DataBind(); GV_yearBalence.HeaderRow.TableSection = TableRowSection.TableHeader; } }
void populateEmployeeDetails(int empid) { ViewState.Add("empid", empid); DataTable dt_accumulate = new DataTable(); DataTable dt_taken = new DataTable(); DataTable dt_employee = new DataTable(); DataTable dt_balance = new DataTable(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { using (SqlCommand command = new SqlCommand("sp_get_emp_balance_admin", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@empid", empid); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); dt_accumulate.Load(reader); dt_taken.Load(reader); dt_employee.Load(reader); dt_balance.Load(reader); } catch (SqlException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } GV_Accumulate.DataSource = dt_accumulate; GV_Accumulate.DataBind(); GV_leaveTaken.DataSource = dt_taken; GV_leaveTaken.DataBind(); GV_balance.DataSource = dt_balance; GV_balance.DataBind(); Lbl_empName.Text = ti.ToTitleCase((string)dt_employee.Rows[0][0]); Lbl_empWin.Text = (string)dt_employee.Rows[0][1]; lbl_empusername.Text = (string)dt_employee.Rows[0][3]; lbl_empaccountstatus.Text = (bool)dt_employee.Rows[0][2] ? "Locked" : "Unlocked"; lbl_emplastlogin.Text = ((DateTime)dt_employee.Rows[0][4]).ToString("MM-dd-yyyy hh:mm:ss"); load.Visible = false; addEmployee.Visible = false; employeeSelect.Visible = false; employeeDetails.Visible = true; }