コード例 #1
0
        void LoadInsertTextboxes() // method that loads info into the "edit info" textboxes
        {
            int index;

            index = lvAllEmployees.FocusedItem.Index;

            string       sql = $"SELECT employeeID, firstName, lastName, dateOfBirth, phone, address, contactFirstName, contactPhone, salary, position, departmentName, pass, username FROM employee WHERE employeeID={allEmployees[index].id};";
            MySqlCommand cmd = new MySqlCommand(sql, this.conn);

            conn.Open();
            MySqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                int employeeID = Convert.ToInt32(dr[0]);
                tbInsFirstName.Text       = dr[1].ToString();
                tbInsLastName.Text        = dr[2].ToString();
                dateTimePickerIns.Text    = dr[3].ToString();
                tbInsTelNumber.Text       = dr[4].ToString();
                tbInsAddress.Text         = dr[5].ToString();
                tbInsContactName.Text     = dr[6].ToString();
                tbInsContactPhone.Text    = dr[7].ToString();
                tbInsSalary.Text          = dr[8].ToString();
                cbxInsPosition.Text       = dr[9].ToString();
                cbxInsDepartment.Text     = dr[10].ToString();
                tbInsPassword.Text        = dr[11].ToString();
                tbInsConfirmPassword.Text = dr[11].ToString();
                tbInsUsername.Text        = dr[12].ToString();

                //used to create new contract
                currentWorkerInfo = new CurrentWorkerInfo(employeeID, cbxInsPosition.Text, cbxInsDepartment.Text, Convert.ToInt32(tbInsSalary.Text));

                //variable used to change the username
                currentUser = dr[12].ToString();
                //allEmployees.Add(new Statistics(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), dr[3].ToString()));
            }
            conn.Close();
        }
コード例 #2
0
 private void tabControl2_SelectedIndexChanged(object sender, EventArgs e)
 {
     currentWorkerInfo = null;
     currentUser       = "";
     lvAllEmployees.SelectedItems.Clear();
 }