Exemple #1
0
        public ModelGetEmployeeList GetEmployeeList()
        {
            ModelGetEmployeeList obj = new ModelGetEmployeeList();

            List <EmployeeList> empList = new List <EmployeeList>();
            DataTable           dt      = new DataTable();

            string           q       = "select uid,fname,lname from nworksuser where _type='Admin' or _type='Admin_Employee';";
            MySqlCommand     cmd     = new MySqlCommand(q, conn);
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);;

            conn.Open();
            adapter.Fill(dt);
            conn.Close();

            foreach (DataRow row in dt.Rows)
            {
                EmployeeList employee = new EmployeeList();
                employee.uid   = row["uid"].ToString();
                employee.fname = row["fname"].ToString();
                employee.lname = row["lname"].ToString();

                empList.Add(employee);
            }

            obj.ServiceStatus = "Success";
            obj.EmpList       = empList;
            return(obj);
        }
Exemple #2
0
        public ModelGetEmployeeList EmpList()
        {
            ModelGetEmployeeList obj = new ModelGetEmployeeList();
            DataTable            dt  = new DataTable();

            string           q       = "select uid,fname,lname from nworksuser where _type='Employee' ;";
            MySqlCommand     cmd     = new MySqlCommand(q, conn);
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);;

            conn.Open();
            adapter.Fill(dt);
            DataView dataview = dt.DefaultView;

            dataview.Sort = "fname asc";
            DataTable dtt = dataview.ToTable();

            conn.Close();

            List <EmployeeList> Employees = new List <EmployeeList>();

            foreach (DataRow row in dtt.Rows)
            {
                EmployeeList employee = new EmployeeList();
                employee.uid   = row["uid"].ToString();
                employee.fname = row["fname"].ToString();
                employee.lname = row["lname"].ToString();
                Employees.Add(employee);
            }
            obj.ServiceStatus = "Success";
            obj.EmpList       = Employees;
            return(obj);
        }