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");
            }
        }
Beispiel #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();
 }
Beispiel #3
0
        public bool faStelpu(Stelpur stelpa)
        {
            SqlCommand command = new SqlCommand("faStelpu", this.connection);

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

            this.connection.Open();

            SqlDataReader dr = command.ExecuteReader();

            dr.Read();

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

            this.connection.Close();
            return(true);
        }
Beispiel #4
0
        public bool baetaStelpu(Stelpur stelpa)
        {
            SqlCommand command = new SqlCommand("baetavidstelpunafni", this.connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@nafn", SqlDbType.VarChar).Value = stelpa.Nafn;
            command.Parameters.Add("@tidni", SqlDbType.Int).Value    = stelpa.tidni1;
            return(this.executeStatement(command));
        }