private void btnBreyta_Click(object sender, EventArgs e)
        {
            btnOK.Enabled       = true;
            txtNyttNafn.Enabled = true;
            txtTidni.Enabled    = true;
            txtNafn.Enabled     = false;
            btnBreyta.Enabled   = false;

            Strakar strakur = new Strakar();

            strakur.nafn = txtNafn.Text;
            Stelpur stelpa = new Stelpur();

            stelpa.nafn = txtNafn.Text;
            if (sql.faStrak(strakur))
            {
                kyn = 0;
                txtNyttNafn.Text = strakur.nafn;
                txtTidni.Text    = strakur.tidni1.ToString();
            }
            else if (sql.faStelpu(stelpa))
            {
                kyn = 1;
                txtNyttNafn.Text = stelpa.nafn;
                txtTidni.Text    = stelpa.tidni1.ToString();
            }
            else
            {
                MessageBox.Show("Nafn fannst ekki");
            }
        }
Esempio n. 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (rBStrakur.Checked)
     {
         fN.kyn = 1;
         Strakar strakur = new Strakar();
         strakur.nafn        = txtNafn.Text;
         strakur.tidni1      = int.Parse(txtTidni.Text);
         strakur.eignarfall  = txtEF.Text;
         strakur.eignarfall2 = txtEF2.Text;
         sql.baetaStraki(strakur);
     }
     if (rBStelpa.Checked)
     {
         fN.kyn = 0;
         Stelpur stelpa = new Stelpur();
         stelpa.nafn   = txtNafn.Text;
         stelpa.tidni1 = int.Parse(txtTidni.Text);
         sql.baetaStelpu(stelpa);
     }
     fN.ok      = true;
     fN.string1 = txtNafn.Text;
     fN.string2 = txtEF.Text;
     fN.string3 = txtEF2.Text;
     fN.tidni   = int.Parse(txtTidni.Text);
     this.Close();
 }
Esempio n. 3
0
        public bool faStrak(Strakar strakur)
        {
            SqlCommand command = new SqlCommand("faStrak", this.connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@strakur", SqlDbType.VarChar).Value = strakur.nafn;

            this.connection.Open();

            SqlDataReader dr = command.ExecuteReader();

            dr.Read();

            try
            {
                strakur.tidni1 = dr.GetInt32(1);
            }
            catch (Exception)
            {
                this.connection.Close();
                return(false);
            }

            this.connection.Close();
            return(true);
        }
Esempio n. 4
0
        public bool baetaStraki(Strakar strakur)
        {
            SqlCommand command = new SqlCommand("baetavidstrakanafni", this.connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@nafn", SqlDbType.VarChar).Value = strakur.Nafn;
            command.Parameters.Add("@tidni", SqlDbType.Int).Value    = strakur.Tidni1;
            command.Parameters.Add("@ef", SqlDbType.VarChar).Value   = strakur.Eignarfall;
            command.Parameters.Add("@ef2", SqlDbType.VarChar).Value  = strakur.Eignarfall2;
            return(this.executeStatement(command));
        }