public static ClientDB GetInstance()
 {
     if (instance == null)
     {
         instance = new ClientDB();
     }
     return(instance);
 }
Exemplo n.º 2
0
 private static void Application_ApplicationExit(
     object sender, EventArgs e)
 {
     ClientDB.GetInstance().Save();
     WorkerDB.GetInstance().Save();
     RequestDB.GetInstance().Save();
     RequestStatusDB.GetInstance().Save();
 }
Exemplo n.º 3
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";
 }
Exemplo n.º 4
0
        private void Remove_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }
            Client client = (Client)listView1.SelectedItems[0].Tag;

            ClientDB.GetInstance().RemoveClient(client);
            ShowListClient();
        }
Exemplo n.º 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);
 }
Exemplo n.º 6
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (client == null)
     {
         client = ClientDB.GetInstance().
                  CreateClient();
     }
     client.FirstName = textBox3.Text;
     client.LastName  = textBox2.Text;
     client.Status    = (ClientStatus)comboBox1.SelectedItem;
     client.Phone     = Convert.ToInt64(textBox4.Text);
     Close();
 }
Exemplo n.º 7
0
        void ShowListClient()
        {
            listView1.Items.Clear();
            var clients = ClientDB.GetInstance().
                          GetClients();

            foreach (var client in clients)
            {
                ListViewItem row = new ListViewItem(
                    client.FirstName);
                row.SubItems.Add(client.LastName);
                row.SubItems.Add(client.Status.ToString());
                row.SubItems.Add(client.Phone.ToString());
                row.Tag = client;
                listView1.Items.Add(row);
            }
        }
Exemplo n.º 8
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);
            }
        }