Example #1
0
        private void deleteGalimiNusiz_Click(object sender, EventArgs e)
        {
            try
            {
                GalimiNusizengimai gl = new GalimiNusizengimai();
                gl.nusizengimo_Kodas = int.Parse(deleteGalimiNusizNusizKodas.Text);
                galimiNuzRep.DeleteGalimiNusiz(gl);


                deleteGalimiNusizNusizKodas.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            MessageBox.Show("Deleted succesfully");
            getGalimiNusizengimaiDisplay();
        }
Example #2
0
        public void DeleteGalimiNusiz(GalimiNusizengimai galimiNusiz)
        {
            try
            {
                cnn = new MySqlConnection(connectionString);

                string newSql = ("Delete from galimi_nusiz where galimi_nusiz.NusizKodas=@id ");

                cnn.Open();                                       //open connection. we use the Open method of the cnn variable to open a connection to the database.
                MySqlCommand cmd = new MySqlCommand(newSql, cnn); //select all from newTestTable
                cmd.Parameters.AddWithValue("@id", galimiNusiz.nusizengimo_Kodas);
                cmd.ExecuteNonQuery();                            //execute function

                cnn.Close();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
        }
Example #3
0
        //REGISTER STUDENT
        public GalimiNusizengimai InsertGalimiNusizengimai(GalimiNusizengimai galimiNusiz)//provide transportas object when calling this function
        {
            try
            {
                //setting new SqlConnection, providing connectionString
                cnn = new MySqlConnection(connectionString);
                cnn.Open();//open database

                MySqlCommand cmd1 = new MySqlCommand("Insert into galimi_nusiz (NusPav,NusizengimaiId) VALUES(@NusPav,@NusizengimaiId)", cnn);
                cmd1.Parameters.AddWithValue("@NusPav", galimiNusiz.nusizengimo_Pavadinimas);
                cmd1.Parameters.AddWithValue("@NusizengimaiId", galimiNusiz.nusizengimo_Id);
                cmd1.ExecuteNonQuery();
                cnn.Close();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
            return(galimiNusiz);//return
        }
Example #4
0
        private void addGalimiNusiz_Click(object sender, EventArgs e)
        {
            try
            {
                GalimiNusizengimai gn = new GalimiNusizengimai();
                gn.nusizengimo_Pavadinimas = addGalimiNusizNusPav.Text;
                gn.nusizengimo_Id          = int.Parse(addGalimiNusizNusizId.Text);

                GalimiNusizengimai ins = galimiNuzRep.InsertGalimiNusizengimai(gn);

                addGalimiNusizNusPav.Clear();
                addGalimiNusizNusizId.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            MessageBox.Show("Inserted succesfully");
            getGalimiNusizengimaiDisplay();
        }
Example #5
0
        public void UpdateGalimiNusizengimai(GalimiNusizengimai galimiNusiz)
        {
            try
            {
                //setting new SqlConnection, providing connectionString
                cnn = new MySqlConnection(connectionString);

                //check if user exist
                MySqlCommand cmd = new MySqlCommand("Update galimi_nusiz SET NusPav=@NusPav, NusizengimaiId=@NusizengimaiId  WHERE NusizKodas=@NusizKodas", cnn);//to check if username exist we have to select all items with username
                cmd.Parameters.AddWithValue("@NusPav", galimiNusiz.nusizengimo_Pavadinimas);
                cmd.Parameters.AddWithValue("@NusizengimaiId", galimiNusiz.nusizengimo_Id);
                cmd.Parameters.AddWithValue("@NusizKodas", galimiNusiz.nusizengimo_Kodas);
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #6
0
        private void updateGalimiNusiz_Click(object sender, EventArgs e)
        {
            try
            {
                GalimiNusizengimai gn = new GalimiNusizengimai();
                gn.nusizengimo_Pavadinimas = updateGalimiNusizNusPav.Text;
                gn.nusizengimo_Id          = int.Parse(updateGalimiNusizNusizId.Text);
                gn.nusizengimo_Kodas       = int.Parse(updateGalimiNusizNusizKodas.Text);

                galimiNuzRep.UpdateGalimiNusizengimai(gn);

                updateGalimiNusizNusPav.Clear();
                updateGalimiNusizNusizId.Clear();
                updateGalimiNusizNusizKodas.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            MessageBox.Show("Updated succesfully");
            getGalimiNusizengimaiDisplay();
        }