Beispiel #1
0
        internal static void UpdateTask(Task task)
        {
            if (task == null)
                return;
            if (task.TaskID == Guid.Empty)
                return;
            string sqlQuery = "UPDATE Task SET Name=@Name, CreatedBy=@CreatedBy, AssignedTo=@AssignedTo, " +
                "GivenBy=@GivenBy, ApprovedBy=@ApprovedBy, FullDescription=@FullDescription, " +
                "DateCreated=@DateCreated, DateModified=@DateModified, DateExecuted=@DateExecuted, " +
                "DateToEndTask=@DateToEndTask, IsApproved=@IsApproved, TaskStatus=@TaskStatus WHERE TaskID=@TaskID";

            DbCommand dbCommand = DBHelper.GetDBCommand(sqlQuery);
            DBHelper.AddInParameter(dbCommand, "TaskID", DbType.Guid, task.TaskID);
            DBHelper.AddInParameter(dbCommand, "Name", DbType.String, task.Name);
            DBHelper.AddInParameter(dbCommand, "CreatedBy", DbType.Guid, task.CreatedByID);
            DBHelper.AddInParameter(dbCommand, "AssignedTo", DbType.Guid, task.AssignedToID);
            DBHelper.AddInParameter(dbCommand, "GivenBy", DbType.Guid, task.GivenByID);
            if(task.ApprovedByID != Guid.Empty)
                DBHelper.AddInParameter(dbCommand, "ApprovedBy", DbType.Guid, task.ApprovedByID);
            else
                DBHelper.AddInParameter(dbCommand, "ApprovedBy", DbType.Guid, DBNull.Value);
            DBHelper.AddInParameter(dbCommand, "FullDescription", DbType.String, task.FullDescription);
            DBHelper.AddInParameter(dbCommand, "DateCreated", DbType.DateTime, task.DateCreated);
            DBHelper.AddInParameter(dbCommand, "DateModified", DbType.DateTime, task.DateModified);
            if(task.DateExecuted.HasValue)
                DBHelper.AddInParameter(dbCommand, "DateExecuted", DbType.DateTime, task.DateExecuted);
            else
                DBHelper.AddInParameter(dbCommand, "DateExecuted", DbType.DateTime, DBNull.Value);
            DBHelper.AddInParameter(dbCommand, "DateToEndTask", DbType.DateTime, task.DateToEndTask);
            DBHelper.AddInParameter(dbCommand, "IsApproved", DbType.Boolean, task.IsApproved);
            DBHelper.AddInParameter(dbCommand, "TaskStatus", DbType.Guid, task.TaskStatusID);
            DBHelper.ExecuteNonQuery(dbCommand);
        }
Beispiel #2
0
        private void BindData(Task t)
        {
            task = t;
            lblName.Text = t.Name;
            lblDescription.Text = t.FullDescription;
            lblDateCreated.Text = t.DateCreated.ToString("dd/mm/yyyy hh:mm");
            lblCreatedBy.Text = t.CreatedBy.ToString();
            lblAssignedBy.Text = t.AssignedTo.ToString();
            IList<Employee> employees = EmployeeManager.GetEmployees(true);
            if (t.GivenByID == ApplicationManager.Instance.CurrentEmployee.EmployeeID
                && (t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Zakonczone
                || t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Anulowane))
            {
                chxApproved.Enabled = true;
            }
            else
                chxApproved.Enabled = false;

            selectEmployee.SelectedEmployeeId = t.AssignedToID;
            selectEmployee.EmptyTextVisible = false;
            selectEmployee.BindData(employees);
            selectTaskStatus.EmptyTextVisible = false;
            selectTaskStatus.SelectedTaskStatusID = t.TaskStatusID;
            selectTaskStatus.BindData();
            chxApproved.Checked = t.IsApproved;
        }
Beispiel #3
0
 public void BindData(Task t)
 {
     task = t;
     this.lblName.Text = t.Name;
     this.lblDate.Text = t.DateCreated.Day + "/" + t.DateCreated.Month + "/" + t.DateCreated.Year;
     int cutTo = t.FullDescription.Length;
     if (cutTo > 100)
         cutTo = 100;
     this.lblText.Text = t.FullDescription.Substring(0, cutTo);
     if (t.FullDescription.Length > cutTo)
         this.lblText.Text += "...";
     if (t.IsApproved)
     {
         this.lblText.Font = new Font("Tahoma", 8, FontStyle.Strikeout);
     }
     if (t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Nowe)
     {
         lblStatus.Text = "Status: Nowe";
         lblStatus.ForeColor = Color.Green;
     }
     if (t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Rozpoczete)
     {
         lblStatus.Text = "Status: Rozpoczęte";
         lblStatus.ForeColor = Color.Red;
     }
     if (t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Zakonczone)
     {
         lblStatus.Text = "Status: Zakończone";
         lblStatus.ForeColor = Color.Black;
     }
     if (t.TaskStatus.DictionaryNumber == (int)TaskStatusEnum.Anulowane)
     {
         lblStatus.Text = "Status: Anulowane";
         lblStatus.ForeColor = Color.Black;
     }
 }
Beispiel #4
0
 private static Task GetTaskFromReader(IDataReader dataReader)
 {
     Task task = new Task();
     task.TaskID = DBHelper.GetGuid(dataReader, "TaskID");
     task.Name = DBHelper.GetString(dataReader, "Name");
     task.CreatedByID = DBHelper.GetGuid(dataReader, "CreatedBy");
     task.AssignedToID = DBHelper.GetGuid(dataReader, "AssignedTo");
     task.GivenByID = DBHelper.GetGuid(dataReader, "GivenBy");
     task.ApprovedByID = DBHelper.GetGuid(dataReader, "ApprovedBy");
     task.FullDescription = DBHelper.GetString(dataReader, "FullDescription");
     task.DateCreated = DBHelper.GetDateTime(dataReader, "DateCreated");
     task.DateModified = DBHelper.GetNullableDateTime(dataReader, "DateModified");
     task.DateExecuted = DBHelper.GetNullableDateTime(dataReader, "DateExecuted");
     task.DateToEndTask = DBHelper.GetNullableDateTime(dataReader, "DateToEndTask");
     task.IsApproved = DBHelper.GetBoolean(dataReader, "IsApproved");
     task.TaskStatusID = DBHelper.GetGuid(dataReader, "TaskStatus");
     return task;
 }
Beispiel #5
0
 public static void UpdateTask(Task task)
 {
     task.DateModified = DateTime.Now;
     TaskDB.UpdateTask(task);
 }
Beispiel #6
0
 public void Show(Task task)
 {
     BindData(task);
     Show();
 }