예제 #1
0
        //Yeni task yaradilmasi

        private void BtnTaskAdd_OnClick(object sender, RoutedEventArgs e)
        {
            TextRange textRange = new TextRange(rtbDescript.Document.ContentStart, rtbDescript.Document.ContentEnd);

            //Validationlar yazildi
            if (cmbCustomer.SelectedIndex == -1)
            {
                MessageBox.Show("Müştəri seçin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }


            if (textRange.Text.Length == 0)
            {
                MessageBox.Show("Qisa izah daxil edin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (string.IsNullOrEmpty(dtpDeadline.Text))
            {
                MessageBox.Show("Bitiş tarixini qeyd edin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            //yeni task elave edilmesi
            Customer c = cmbCustomer.SelectedItem as Customer;

            Model.Task task = new Model.Task();


            task.CustomerID   = c.CustomerId;
            task.CreationAt   = DateTime.Now;
            task.DeadlineTime = dtpDeadline.SelectedDate.Value;
            task.Description  = textRange.Text;
            task.FinishTime   = false;
            task.UserID       = UserID;
            db.Tasks.Add(task);
            db.SaveChanges();

            //Taskda qeyd edilen kimi bildiris elave edilir
            Notification not = new Notification();

            not.TaksID           = task.TaskId;
            not.NotificationType = (byte)cmbNote.SelectedIndex;
            not.Create           = DateTime.Now;
            db.Notifications.Add(not);
            db.SaveChanges();
            MainWindows.FillDasboard();
            MainWindows.Notification();
            MessageBox.Show("Task əlavə edildi", "Bildiriş", MessageBoxButton.OK, MessageBoxImage.Information);
            string Username = db.Users.FirstOrDefault(x => x.UserId == UserID).UserName;

            Logger.Write("success", Username + " yeni task yaratdı");
            this.Close();
        }
예제 #2
0
        //Update olunmasi
        private void btnTaskUpdate_Click(object sender, RoutedEventArgs e)
        {
            TextRange textRange = new TextRange(rtbDescript.Document.ContentStart, rtbDescript.Document.ContentEnd);

            //Validationlar yazildi
            if (cmbCustomer.SelectedIndex == -1)
            {
                MessageBox.Show("Müştəri seçin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }


            if (textRange.Text.Length == 0)
            {
                MessageBox.Show("Qisa izah daxil edin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (string.IsNullOrEmpty(dtpDeadline.Text))
            {
                MessageBox.Show("Bitiş tarixini qeyd edin", "Xəbərdarlıq", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            Model.Task upTask = db.Tasks.Find(TaskModel.TaskId);
            if (chbFinish.IsChecked.Value)
            {
                upTask.FinishTime = true;
            }

            upTask.CustomerID   = Convert.ToInt32(cmbCustomer.SelectedValue);
            upTask.DeadlineTime = dtpDeadline.SelectedDate.Value;
            upTask.Description  = textRange.Text;
            upTask.UserID       = UserID;
            upTask.CreationAt   = TaskModel.CreationAt;
            db.SaveChanges();


            if (upTask.FinishTime == true)
            {
                int          noteId = db.Notifications.FirstOrDefault(x => x.TaksID == upTask.TaskId).NotificationId;
                Notification nt     = db.Notifications.FirstOrDefault(x => x.NotificationId == noteId);
                nt.IsActive = true;
                db.SaveChanges();
            }

            MainWindows.Notification();
            MainWindows.FillDasboard();
            MessageBox.Show("Task yeniləndi", "Bildiriş", MessageBoxButton.OK, MessageBoxImage.Information);
            string Username = db.Users.FirstOrDefault(x => x.UserId == UserID).UserName;

            Logger.Write("success", Username + " taskı yenilədi");
            this.Close();
        }
예제 #3
0
파일: Tasks.cs 프로젝트: abbasoffa1/CRM
        private void dgvTasks_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            btnDelete.Visible = true;
            btnUpdate.Visible = true;
            btnAdd.Visible    = false;
            cmbStatus.Enabled = true;
            int id = Convert.ToInt32(dgvTasks.Rows[e.RowIndex].Cells[0].Value.ToString());

            task               = db.Tasks.Find(id);
            txtTaskName.Text   = task.Name;
            cmbUser.Text       = task.UserId + "-" + task.User.Name;
            cmbCustomer.Text   = task.CustomerId + "-" + task.Customer.FullName;
            dtpStartDate.Value = task.Date;
        }
예제 #4
0
파일: Tasks.cs 프로젝트: abbasoffa1/CRM
 //Task Create
 private void btnAdd_Click(object sender, EventArgs e)
 {
     Model.Task newTask = new Model.Task();
     if (string.IsNullOrEmpty(txtTaskName.Text) || string.IsNullOrEmpty(cmbCustomer.Text) || string.IsNullOrEmpty(cmbUser.Text))
     {
         MessageBox.Show("Please fill all inputs!");
     }
     else
     {
         newTask.Name = txtTaskName.Text;
         if (cmbStatus.SelectedText == "Continue")
         {
             newTask.IsStatus = Convert.ToBoolean("True");
         }
         newTask.UserId     = Convert.ToInt16(cmbUser.Text.Split('-')[0]);
         newTask.CustomerId = Convert.ToInt16(cmbCustomer.Text.Split('-')[0]);
         newTask.Date       = dtpStartDate.Value;
         db.Tasks.Add(newTask);
         db.SaveChanges();
         FillDgv();
     }
 }