Example #1
0
        public List<TaskDTO> GetAllTasksFromWorker(TaskRDG worker)
        {
            List<TaskDTO> tasks = new List<TaskDTO>();
            TaskDTO taskDTO;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "SP_GetAllTasksFromWorker";
            cmd.Parameters.Clear();

            SqlParameter par = new SqlParameter("@Username", SqlDbType.NVarChar);
            par.Value = worker.Worker.UserName;
            cmd.Parameters.Add(par);

            cmd.Transaction = trans.GetTransaction();
            cmd.Connection = trans.GetTransaction().Connection;
            SqlDataReader datareader = cmd.ExecuteReader();
            while (datareader.Read() && datareader.HasRows)
            {
                taskDTO = new TaskDTO();
                taskDTO.TaskID = (int)datareader["TaskID"];
                taskDTO.Description = (string)datareader["Description"];
                taskDTO.IsDone = (bool)datareader["IsDone"];
                taskDTO.Feedback = (string)datareader["Feedback"];
                taskDTO.ToolID = (int)datareader["FK_ToolID"];
                taskDTO.Date = (DateTime)datareader["Date"];
                tasks.Add(taskDTO);
            }
            datareader.Close();
            cmd.ExecuteNonQuery();
            return tasks;
        }
Example #2
0
        public List<TaskDTO> GetNotified(DateTime date, string Username = "")
        {
            TaskDTO taskDTO;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "SP_GetNotified";
            cmd.CommandTimeout = 0;

            cmd.Transaction = trans.GetTransaction();
            cmd.Connection = trans.GetTransaction().Connection;

            string sqlFormattedDate = date.ToString("yyyy-MM-dd HH:mm:ss");

            cmd.Parameters.Add(new SqlParameter("@Date", sqlFormattedDate));

            //  SqlParameter par = new SqlParameter("@Date", SqlDbType.Date);//
            // par.Value = sqlFormattedDate;//
            //cmd.Parameters.Add(par); //

            if (Username != "")
            {
                cmd.Parameters.Add(new SqlParameter("@Username", Username));
            }
            //cmd.ExecuteNonQuery();

            SqlDataReader datareader = cmd.ExecuteReader();
            List<TaskDTO> notifications = new List<TaskDTO>();

            while (datareader.Read())
            {
                taskDTO = new TaskDTO();

                taskDTO.TaskID = (int)datareader["TaskID"];
                taskDTO.Description = (string)datareader["Description"];
                taskDTO.IsDone = (bool)datareader["IsDone"];
                taskDTO.Feedback = (string)datareader["Feedback"];
                taskDTO.ToolID = (int)datareader["FK_ToolID"];
                taskDTO.Date = (DateTime)datareader["Date"];

                WorkerDTO worker = new WorkerDTO();
                worker.UserName = (string)datareader["FK_Username"];
                taskDTO.Worker = worker;

                notifications.Add(taskDTO);
            }
            datareader.Close();
            return notifications;
        }
Example #3
0
        public List<TaskDTO> GetAllTasks()
        {
            TaskDTO taskDTO;
            cmd.CommandTimeout = 0;
            cmd.CommandText = "SP_GetAllTasksForSupervisor";
            cmd.Transaction = trans.GetTransaction();
            cmd.Connection = trans.GetTransaction().Connection;
            SqlDataReader datareader = cmd.ExecuteReader();

            List<TaskDTO> tasks = new List<TaskDTO>();

            while (datareader.Read() == true && datareader.HasRows)
            {
                taskDTO = new TaskDTO();
                taskDTO.Worker = new WorkerDTO();

                taskDTO.TaskID = (int)datareader["TaskID"];
                taskDTO.Description = (string)datareader["Description"];
                taskDTO.ToolID = (int)datareader["FK_ToolID"];
                taskDTO.IsDone = (bool)datareader["IsDone"];
                taskDTO.Feedback = (string)datareader["Feedback"];
                taskDTO.Date = (DateTime)datareader["Date"];
                taskDTO.Worker.Name = (string)datareader["Name"];
                taskDTO.Worker.PhoneNumber = (string)datareader["PhoneNr"];
                tasks.Add(taskDTO);
            }

            datareader.Close();
            return tasks;
        }