示例#1
0
        public List<WorkerDTO> GetAllWorkers()
        {
            WorkerDTO wDTO;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "SP_GetAllWorkers";
            cmd.Parameters.Clear();

            cmd.Transaction = trans.GetTransaction();
            cmd.Connection = trans.GetTransaction().Connection;
            SqlDataReader datareader = cmd.ExecuteReader();

            List<WorkerDTO> WorkersDTO = new List<WorkerDTO>();

            while (datareader.Read() == true)
            {
                wDTO = new WorkerDTO();
                wDTO.UserName = (string)datareader["UserName"];
                wDTO.IsSupervisor = (bool)datareader["IsSuperviser"];
                wDTO.Address = (string)datareader["Address"];
                wDTO.Name = (string)datareader["Name"];
                wDTO.PhoneNumber = (string)datareader["PhoneNr"];

                WorkersDTO.Add(wDTO);
            }
            datareader.Close();

            return WorkersDTO;
        }
示例#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;
        }