Exemplo n.º 1
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            if (mainGridView.SelectedRows.Count > 0 && !menu_Employee_show)
            {
                mainGridView.Width   = mainGridView.Width - menu_Employee_size;
                panelEmployees.Width = menu_Employee_size;
                menu_Employee_show   = !menu_Employee_show;

                listboxCurrentCerts.Items.Clear();
                employee = new EmployeeChanges();

                buttonControl.Text = "Add New!";
            }
            else if (mainGridView.SelectedRows.Count <= 0)
            {
                MessageBox.Show("You have to select a row for too edit!");
            }
            else if (menu_Employee_show)
            {
                mainGridView.Width   = mainGridView.Width + menu_Employee_size;
                panelEmployees.Width = 0;
                menu_Employee_show   = !menu_Employee_show;
                textBoxName.Text     = "";
                TextAdditInfo.Text   = "";
            }
        }
Exemplo n.º 2
0
        private void fillListBox()
        {
            if (mainGridView.SelectedRows.Count > 0)
            {
                con.Open();

                cmd.CommandText = "select Certifications.Id, Certifications.Name, EmployeeCertification.Additional_Info, EmployeeCertification.Expiration_Date" +
                                  " from Certifications" +
                                  " join EmployeeCertification on Certifications.Id = EmployeeCertification.CertificationId" +
                                  " join Employees on Employees.Id = EmployeeCertification.EmployeeId where Employees.Id = " + mainGridView.SelectedRows[0].Cells["Id"].Value.ToString();
                dr = cmd.ExecuteReader();

                listboxCurrentCerts.Items.Clear();
                employee = new EmployeeChanges();

                while (dr.Read())
                {
                    employee.CertId.Add(dr[0].ToString());
                    employee.CertAdditInfo.Add(dr[2].ToString());

                    if (!DBNull.Value.Equals(dr[3]))
                    {
                        employee.CertDate.Add(Convert.ToDateTime(dr[3]).ToShortDateString());
                    }
                    else
                    {
                        employee.CertDate.Add("NULL");
                    }
                    listboxCurrentCerts.Items.Add(new KeyValuePair <string, string>(dr[0].ToString(), dr[1].ToString()));
                }

                dr.Close();
                con.Close();


                listboxCurrentCerts.DisplayMember = "Value";
                listboxCurrentCerts.ValueMember   = "Key";
            }
        }