Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == "" || textBox3.Text == "")
            {
                MessageBox.Show("Please enter a name/lastname!");
                return;
            }

            //int workerID;
            string name     = textBox2.Text;
            string lastname = textBox3.Text;
            //string date = (textBox6.Text);
            DateTime date = DateTime.Parse(textBox6.Text);

            /*try
             * {
             *  workerID = int.Parse(textBox1.Text);
             * }
             * catch (FormatException)
             * {
             *  MessageBox.Show("Please enter a ID!");
             *
             *  return;
             * }*/

            int idOfPos = DBConnection.GetIDByPositionName(comboBox.SelectedItem.ToString());

            //Изпълнение на метод, който изпраща заявка, която връща ID на избрания отдел
            int idOfDep = DBConnection.GetDepartmentID(comboBox2.SelectedItem.ToString());

            /*if (idOfDep == -1)
             * {
             *  MessageBox.Show("There is no ID for type: " + typeListBox.SelectedItem.ToString() + "!");
             *
             *  return;
             * }*/
            DBConnection.InsertWorkerToDB(name, lastname, idOfPos, idOfDep, date);
        }