Exemplo n.º 1
0
        public List<WorkPlanWeek> ReadWorkPlans()
        {
            List<WorkPlanWeek> workPlans = new List<WorkPlanWeek>();
            try
            {
                conn.Open();
                SqlCommand sqlcmd = new SqlCommand("getWeeklyWorkPlan", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;

                DataTable table = new DataTable();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
                adapter.Fill(table);
                SqlDataReader reader = sqlcmd.ExecuteReader();
                reader.Read();
                foreach (DataRow row in table.Rows)
                {
                    WorkPlanWeek workPlan = new WorkPlanWeek(
                        row["Day"].ToString(),
                        row["EmployeeName"].ToString(),
                        row["ShiftStart"].ToString(),
                        row["ShiftEnd"].ToString(),
                        row["Shift"].ToString(),
                        row["TypeofWork"].ToString()
                    );
                    workPlans.Add(workPlan);
                }
                conn.Close();
                return workPlans;
            }
            catch (Exception e)
            {
                return workPlans;
                throw e;
            }
        }
Exemplo n.º 2
0
        public List<WorkPlanWeek> ReadWorkPlans(string filterWorktype, string filtermail, string filterShift, string filterEmployeeSearch, string filterDatePicke)
        {
            List<WorkPlanWeek> workPlans = new List<WorkPlanWeek>();
            try
            {
                conn.Open();
                SqlCommand sqlcmd = new SqlCommand("getWeeklyWorkPlanFiltered", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;

                sqlcmd.Parameters.Add(new SqlParameter("@filterWorktype", filterWorktype));
                sqlcmd.Parameters.Add(new SqlParameter("@mail", filtermail));
                sqlcmd.Parameters.Add(new SqlParameter("@filterShift", filterShift));
                sqlcmd.Parameters.Add(new SqlParameter("@filterEmployeeSearch", filterEmployeeSearch));
                sqlcmd.Parameters.Add(new SqlParameter("@filterDatePicke", filterDatePicke));

                DataTable table = new DataTable();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
                adapter.Fill(table);
                SqlDataReader reader = sqlcmd.ExecuteReader();
                reader.Read();
                foreach (DataRow row in table.Rows)
                {
                    WorkPlanWeek workPlan = new WorkPlanWeek(
                        row["Day"].ToString(),
                        row["EmployeeName"].ToString(),
                        row["ShiftStart"].ToString(),
                        row["ShiftEnd"].ToString(),
                        row["Shift"].ToString(),
                        row["TypeofWork"].ToString()
                    );
                    workPlans.Add(workPlan);
                }
                conn.Close();
                return workPlans;
            }
            catch (Exception e)
            {
                return workPlans;
                throw e;
            }
        }