void FillListStatuses()
 {
     listBox1.DataSource =
         RequestStatusDB.GetInstance().
         GetRequestStatuses();
     listBox1.DisplayMember = "Name";
 }
Exemple #2
0
 public static RequestStatusDB GetInstance()
 {
     if (instance == null)
     {
         instance = new RequestStatusDB();
     }
     return(instance);
 }
 private static void Application_ApplicationExit(
     object sender, EventArgs e)
 {
     ClientDB.GetInstance().Save();
     WorkerDB.GetInstance().Save();
     RequestDB.GetInstance().Save();
     RequestStatusDB.GetInstance().Save();
 }
Exemple #4
0
 void FillFilters()
 {
     comboBox2.DataSource    = RequestStatusDB.GetInstance().GetRequestStatuses();
     comboBox2.DisplayMember = "Name";
     comboBox1.DataSource    = typeof(RequestPriority).GetEnumValues();
     comboBox3.DataSource    = WorkerDB.GetInstance().GetWorkers();
     comboBox3.DisplayMember = "LastName";
     comboBox4.DataSource    = ClientDB.GetInstance().GetClients();
     comboBox4.DisplayMember = "LastName";
 }
Exemple #5
0
 public FormRequestEdit(Request request)
 {
     InitializeComponent();
     FillFilters();
     this.request           = request;
     textBox1.Text          = request.Name;
     comboBox1.SelectedItem = request.Priority;
     comboBox2.SelectedItem = RequestStatusDB.GetInstance().GetRequestStatusByID(request.StatusID);
     comboBox3.SelectedItem = WorkerDB.GetInstance().GetWorkerByID(request.WorkerID);
     dateTimePicker1.Value  = request.DateCreate;
     comboBox4.SelectedItem = ClientDB.GetInstance().GetClientByID(request.ClientID);
 }
        public void Log(Request request)
        {
            var    db         = RequestStatusDB.GetInstance();
            string statusName = null;

            if (request.StatusID == 0)
            {
                statusName = "без статуса";
            }
            else
            {
                statusName = db.GetRequestStatusByID(
                    request.StatusID).Name;
            }

            File.AppendAllText(
                Properties.Settings.Default.FilePath,
                $"{DateTime.Now}: id {request.ID} " +
                $"name {request.Name} create: {request.DateCreate}" +
                $"close: {request.DateClose != DateTime.MinValue}, status: {statusName}" +
                $"priority: {request.Priority}, worker id: {request.WorkerID}");
        }
Exemple #7
0
        private void ShowRequests(List <Request> requests)
        {
            listView1.Items.Clear();
            RequestStatusDB statusDB = RequestStatusDB.GetInstance();
            WorkerDB        workerDB = WorkerDB.GetInstance();
            ClientDB        clientDB = ClientDB.GetInstance();

            foreach (var request in requests)
            {
                ListViewItem row = new ListViewItem(request.Name);
                row.SubItems.Add(request.DateCreate.ToString());
                if (request.Closed)
                {
                    row.SubItems.Add(" ");
                }
                row.SubItems.Add(statusDB.GetRequestStatusByID(request.StatusID).Name);
                row.SubItems.Add(request.Priority.ToString());
                row.SubItems.Add(workerDB.GetWorkerByID(request.WorkerID).LastName);
                row.SubItems.Add(clientDB.GetClientByID(request.ClientID).LastName);
                row.Tag = request;
                listView1.Items.Add(row);
            }
        }
        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }
            RequestStatus requestStatus =
                (RequestStatus)listBox1.SelectedItem;
            var requests = RequestDB.GetInstance().
                           GetRequests()
                           .GetRequestsByStatus(requestStatus);

            if (requests.requests.Count == 0)
            {
                RequestStatusDB.GetInstance().
                RemoveRequestStatus(requestStatus);
                FillListStatuses();
            }
            else
            {
                MessageBox.Show("Невозможно удалить статус, " +
                                "Существуют заявки с таким статусом");
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     RequestStatusDB.GetInstance().
     CreateRequestStatus(textBox1.Text);
     Close();
 }