Ejemplo n.º 1
0
 private void DropList_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.Serializable))
     {
         TaskerModel.Task tsk      = e.Data.GetData(DataFormats.Serializable) as TaskerModel.Task;
         ListView         listView = sender as ListView;
         int curr_id      = tsk.Id;
         var changeStatus = ctx.Tasks.Find(curr_id);
         if (changeStatus != null)
         {
             changeStatus.Status = Grid.GetColumn(listView) + 1;
             if (changeStatus.Status == 4)
             {
                 email_send(changeStatus, "A Task is Done");
                 changeStatus.DataFinalizarii = DateTime.Now;
             }
             else if (changeStatus.Status == 3)
             {
                 email_send(changeStatus, "A Task needs your review");
             }
             ctx.SaveChanges();
             refresh(sender, e);
         }
     }
 }
Ejemplo n.º 2
0
        private void btnEditTask_Click(object sender, RoutedEventArgs e)
        {
            TaskerModel.Task tsk         = null;
            TaskerModel.Task selected    = ctx.Tasks.Find(idTask);
            Angajat          responsible = (Angajat)cmbAngajati.SelectedItem;
            int priority = 1;  //if rbtnLow.IsChecked

            if ((bool)rbtnMedium.IsChecked)
            {
                priority = Convert.ToInt32(medie);
            }
            else if ((bool)rbtnMedium.IsChecked)
            {
                priority = max;
            }
            try
            {
                if (ValidateTask())
                {
                    tsk            = selected;
                    tsk.Denumire   = txtTitle.Text.Trim();
                    tsk.Descriere  = txtDescription.Text.Trim();
                    tsk.Deadline   = (DateTime)pickerDeadline.SelectedDate;
                    tsk.IdAngajat  = responsible.Id;
                    tsk.Prioritate = priority;
                    ctx.SaveChanges();
                    MessageBox.Show("Task Edited Successfully!");
                    this.Close();
                }
            }
            catch (DataException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void List_MouseMove(object sender, MouseEventArgs e)
        {
            // Get the current mouse position
            Point  mousePos = e.GetPosition(null);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                // Get the dragged ListViewItem
                ListView     listView     = sender as ListView;
                ListViewItem listViewItem =
                    FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);
                if (listViewItem == null)
                {
                    return;
                }

                // Find the data behind the ListViewItem
                TaskerModel.Task tsk = (TaskerModel.Task)listView.ItemContainerGenerator.
                                       ItemFromContainer(listViewItem);

                // Initialize the drag & drop operation
                DataObject dragData = new DataObject(DataFormats.Serializable, tsk);
                DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move);
            }
        }
Ejemplo n.º 4
0
 public void getData_Task(TaskerModel.Task obj)
 {
     denumire   = obj.Denumire.ToString();
     descr      = obj.Descriere.ToString();
     deadline   = obj.Deadline;
     resp       = Convert.ToInt32(obj.IdAngajat);
     idTask     = Convert.ToInt32(obj.Id);
     prioritate = (int)ctx.Tasks.Find(idTask).Prioritate;
 }
Ejemplo n.º 5
0
        private void DecreasePriority(object sender, RoutedEventArgs e)
        {
            ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);

            TaskerModel.Task tsk = (TaskerModel.Task)listViewItem.DataContext;
            var getTask          = ctx.Tasks.Find(tsk.Id);
            var taskBelow        = ctx.Tasks.Where(x => x.Status == getTask.Status && x.Prioritate < getTask.Prioritate).OrderByDescending(x => x.Prioritate).Select(x => x.Prioritate).FirstOrDefault();

            getTask.Prioritate = (taskBelow != null) ? taskBelow - 1 : getTask.Prioritate - 1;
            ctx.SaveChanges();
            refresh(sender, e);
        }
Ejemplo n.º 6
0
        //get selected item
        private void List_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ListView     listView     = sender as ListView;
            ListViewItem listViewItem =
                FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);

            if (listViewItem == null)
            {
                return;
            }

            selectedTask = (TaskerModel.Task)listView.ItemContainerGenerator.
                           ItemFromContainer(listViewItem);
        }
Ejemplo n.º 7
0
        //DELETE TASK
        private void btnDeleteTask_Click(object sender, RoutedEventArgs e)
        {
            TaskerModel.Task tsk = ctx.Tasks.Find(selectedTask.Id);
            MessageBoxResult res = MessageBox.Show("Are you sure you want to delete the task - " + tsk.Denumire + "?", "Delete Task", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                try
                {
                    ctx.Tasks.Remove(tsk);
                    ctx.SaveChanges();
                    MessageBox.Show("Task Deleted Successfully!");
                    refresh(sender, e);
                }
                catch (DataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 8
0
        //SENDING EMAIL
        public void email_send(TaskerModel.Task tsk, string subject)
        {
            var    angajat      = ctx.Angajats.Find(tsk.IdAngajat);
            string managerEmail = null;

            foreach (Angajat a in ctx.Angajats)
            {
                if (a.IsManager == true)
                {
                    managerEmail = a.Email;
                    break;
                }
            }
            var          fromAddress  = new MailAddress("*****@*****.**", "Tasker");
            var          toAddress    = new MailAddress(managerEmail, "Manager");
            const string fromPassword = "******";
            string       body         = "Title: " + tsk.Denumire + Environment.NewLine
                                        + "Description: " + tsk.Descriere + Environment.NewLine
                                        + "Responsible: " + angajat.Nume + Environment.NewLine
                                        + "Date: " + DateTime.Now.ToString();

            var smtp = new SmtpClient
            {
                Host           = "smtp.gmail.com",
                Port           = 587,
                EnableSsl      = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                Timeout        = 20000
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
Ejemplo n.º 9
0
        private void btnCreateTask_Click(object sender, RoutedEventArgs e)
        {
            TaskerModel.Task tsk         = null;
            Angajat          responsible = (Angajat)cmbAngajati.SelectedItem;
            int priority = 1;  //if rbtnLow.IsChecked

            if ((bool)rbtnMedium.IsChecked)
            {
                priority = Convert.ToInt32(medie);
            }
            else if ((bool)rbtnMedium.IsChecked)
            {
                priority = max;
            }
            try
            {
                if (ValidateTask())
                {
                    tsk = new TaskerModel.Task()
                    {
                        Denumire  = txtTitle.Text.Trim(),
                        Descriere = txtDescription.Text != null?txtDescription.Text.Trim() : null,
                                        Deadline    = (DateTime)pickerDeadline.SelectedDate,
                                        Status      = 1,
                                        DataCrearii = System.DateTime.Now,
                                        IdAngajat   = responsible.Id,
                                        Prioritate  = priority
                    };
                    ctx.Tasks.Add(tsk);
                    ctx.SaveChanges();
                    MessageBox.Show("Task Created Successfully!");
                    this.Close();
                }
            }
            catch (DataException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }