Beispiel #1
0
        private void schDepartment_changee(object sender, EventArgs e)
        {
            int idOfDep = DBConnection.GetDepartmentID(schDepartment.Text);

            DataTable dt = DBConnection.SelectWorkersByDep(idOfDep);

            dataGridView1.DataSource = dt;
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DESKTOP-3MKAK0L;Initial Catalog=CompanyDB;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

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

            //DateTime date = DateTime.Parse(textBox6.Text);
            //Изпълнение на метод, който изпраща заявка, която връща ID на избрания тип
            int            idOfDep  = DBConnection.GetDepartmentID(comboBox2.SelectedItem.ToString());
            SqlDataAdapter dataAdap = new SqlDataAdapter("UPDATE Worker SET Name= '" + textBox2.Text + "', Lastname ='" + textBox3.Text + "', PositionID ='" + idOfPos + "', DepartmentID ='" + idOfDep + "', АppointmentDate ='" + textBox6.Text + "'WHERE WorkerID='" + textBox1.Text + "'", conn);

            dataAdap.SelectCommand.ExecuteNonQuery();
            conn.Close();

            MessageBox.Show("Data updated successfully!");
        }
Beispiel #3
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);
        }