public List <EmployeeModel> GetAll() { List <EmployeeModel> lst = new List <EmployeeModel>(); string getAllEmp = "select * from employee"; SqlDataAccess d = new SqlDataAccess(con.GetConnectionForSql()); d.Connection.Open(); var cmd = d.Command(getAllEmp); DataSet ds = d.ExecuteDataSetForSqlQueryNew(cmd); var table = ds.Tables[0]; for (int i = 0; i < table.Rows.Count; i++) { var id = table.Rows[i]["Id"]; EmployeeModel e = new EmployeeModel(); e.Id = Convert.ToInt32(id); var Name = table.Rows[i]["Name"]; e.Name = Convert.ToString(Name); lst.Add(e); Console.WriteLine(id); Console.WriteLine(Name); } return(lst); }
public List <SalaryModel> GetAll() { List <SalaryModel> lst = new List <SalaryModel>(); string getAllEmp = "select * from salary"; SqlDataAccess d = new SqlDataAccess(con.GetConnectionForSql()); d.Connection.Open(); var cmd = d.Command(getAllEmp); DataSet ds = d.ExecuteDataSetForSqlQueryNew(cmd); var table = ds.Tables[0]; for (int i = 0; i < table.Rows.Count; i++) { var id = table.Rows[i]["Fk_EmployeeId"]; SalaryModel e = new SalaryModel(); e.EmployeeId = Convert.ToInt32(id); var amount = table.Rows[i]["salary_amount_paid"]; e.SalaryPaidAmount = Convert.ToDouble(amount); lst.Add(e); Console.WriteLine(id); Console.WriteLine(amount); } // return lst; return(lst); }