public IActionResult berekenTemperatuur(string eenheid, int waarde) { Temperatuur temp = new Temperatuur(waarde); if (eenheid == "Kelvin") { ViewBag.opl = temp.Kelvin; } else if (eenheid == "Fahrenheit") { ViewBag.opl = temp.Fahrenheit; } return(View()); }
private void BtnSubmit_Click(object sender, EventArgs e) { String U = txt_UserName.Text; U = Regex.Replace(U, @"\B[A-Z]", m => " " + m.ToString().ToLower()); String P = txt_Password.Text; P = Regex.Replace(P, @"\B[A-Z]", m => " " + m.ToString().ToLower()); { if (txt_UserName.Text == "" || txt_Password.Text == "") { MessageBox.Show("Enter UserName and Password"); return; } try { SqlConnection connection = new SqlConnection(cs); SqlCommand cmd; connection.Open(); cmd = connection.CreateCommand(); cmd.CommandText = ("Select * from tbl_Login where UserName=@UserName COLLATE Latin1_General_CS_AS and Password=@Password COLLATE Latin1_General_CS_AS"); cmd.Parameters.AddWithValue("@UserName", txt_UserName.Text); cmd.Parameters.AddWithValue("@Password", txt_Password.Text); cmd.ExecuteNonQuery(); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { this.Hide(); Temperatuur fm = new Temperatuur(); fm.Show(); } } catch (Exception E) { MessageBox.Show(E.Message); } try { SqlConnection connection2 = new SqlConnection(cs); SqlCommand command; connection2.Open(); command = connection2.CreateCommand(); command.CommandText = ("SELECT (Rights) FROM tbl_Login WHERE UserName=@username AND Password=@password"); command.Parameters.AddWithValue("@username", txt_UserName.Text); command.Parameters.AddWithValue("@password", txt_Password.Text); command.ExecuteNonQuery(); SqlDataAdapter adapt2 = new SqlDataAdapter(command); DataSet ds2 = new DataSet(); adapt2.Fill(ds2); int rights = Convert.ToInt32(ds2.Tables[0].Rows[0][0]); Rights.rights = rights; } catch (Exception) { MessageBox.Show("Login mislukt"); txt_UserName.Clear(); txt_Password.Clear(); this.ActiveControl = txt_UserName; } try { SqlConnection connection3 = new SqlConnection(cs); SqlCommand cmd2; connection3.Open(); cmd2 = connection3.CreateCommand(); cmd2.CommandText = ("SELECT (UserName) FROM tbl_Login WHERE UserName=@UserName"); cmd2.Parameters.AddWithValue("@UserName", txt_UserName.Text); cmd2.ExecuteNonQuery(); SqlDataAdapter adapt3 = new SqlDataAdapter(cmd2); DataSet ds3 = new DataSet(); adapt3.Fill(ds3); string username = Convert.ToString(ds3.Tables[0].Rows[0][0]); Rights.username = username; } catch (Exception /*E*/) { //MessageBox.Show(E.Message); } } }
public void AddTemperatuur(Temperatuur temperatuur) { _omgevingen.Include(o => o.Temperaturen).Where(o => o.Id == 1).FirstOrDefault().Temperaturen.Add(temperatuur); }
private static void Oefening2_Temperatuur() { Temperatuur temp = new Temperatuur(23); Console.WriteLine(temp.ToString()); }