[ android27 @ 29.05.2018. 20:33 ] @
mozel pomoc oko wpf aplikacije nemogu da uradim ovaj jedan zadatak a trebami pokusavo sam nesto da pravim a nekontam kako ovo ide ako neko ima slobodnog vremena da pomogne bio bi zahvalan
Kreirati WPF aplikaciju koja koristi MVVM šablon i koja ima funkcionalnosti opisane kroz sledeće radne zadatke:

Kreirati bazu podataka ADMIN_1 i tabelu Users sa kolonama ID, UserName, UserPass, IsAdmin.
Napraviti LoginWindow prozor u kom će korisnik da unese korisničko ime i šifru. Pritiskom na dugme Login proveravate da li korisnik sa navedenim podacima postoji u bazi sa navedenim podacima; ako postoji, prikazati prozor MainWindow. Ukoliko ne postoji korisnik sa navedenim podacima, prikazati mu poruku „Login failed. Please try again.”
Napraviti prozor MainWindow koji će da sadrži ListBox kontrolu sa prikazom korisničkih imena svih korisnika iz tabele Users u bazi.
Omogućiti pregled i izmenu podataka za selektovanog korisnika iz liste. Omogućite korisniku da, kada selektuje red u ListBox kontroli, vidi sve podatke o tom korisniku (korisničko ime, šifru, da li je u pitanju administrator (boolean podatak)). Korisnik može da izmeni neki od podataka i klikom na dugme Save izmene će se snimiti u bazu.
Omogućiti dodavanje novog korisnika u bazu.


Aplikaciju isporučiti u vidu Visual Studio projekta, a bazu podataka u vidu SQL skriptova (u tekstualnom dokumentu). U SSMS-u odradite Tasks-> Generate Scripts, ispratite korake i generisaće se .sql fajl koji je script baze.
[ Shadowed @ 29.05.2018. 20:41 ] @
Sta si do sada uradio i gde je zapelo?
[ android27 @ 29.05.2018. 20:48 ] @
pukusavam ovaj login kod da sastavim ali stvarno ne znam kako znam ovo za korisnike da izbaci kako se radi jer sam dodo na microsoft sql server managment i napravio te korisnike
evo mi kod za login: ovaj kod pokusavam ali uporno nesto nece jel imas neke ideje mozda za laksi login kod da poveze sa sql meni treba kod kad upisim npr admin korisnicko ime i password npr admin da udze u mainwindow pa da izbaci imena iz sql

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for LoginScreen.xaml
/// </summary>
public partial class LoginScreen : Window
{
public LoginScreen()
{
InitializeComponent();
}

private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
SqlConnection sqlCon = new SqlConnection(@"Data Source=local\SQL; Initial Catalog=LoginDB; Integrated Security=True;");
try
{
if (sqlCon.State == ConnectionState.Closed)
sqlCon.Open();
String query = "SELECT COUNT(1) FROM tblUser WHERE Username=@Username AND Password=@Password";
SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.Parameters.AddWithValue("@Username",txtUsername.Text);
sqlCmd.Parameters.AddWithValue("@Password", txtPassword.Password);
int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
if (count == 1)
{
MainWindow dashboard = new MainWindow();
dashboard.Show();
this.Close();
}
else
{
MessageBox.Show("Username or password is incorrect.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlCon.Close();
}
}
}
}
[ Shadowed @ 29.05.2018. 20:56 ] @
OK, ako nisam propustio neku sitnicu, ovaj kod je ispravan. Naravno, trebalo bi tu neke stvari raditi drugacije, ali mislim da je bitnije da razumes kod pa da se kasnije poboljsava, nego da se pogubis u raznim ispravkama.

E sad, pitanje je sta znaci da "nesto nece". Da li dobijes neku gresku? Ne dogodi se nista kad kliknes na Submit dugme? Nesto trece?

Daj i XAML kod od tog login prozora. I, stavi kod izmedju [code] [/code] tagova, mnogo bolje se prikaze.
[ android27 @ 29.05.2018. 21:01 ] @
evo od xaml kod sto sam radio ali dobijam gresku ovu cannot open database LoginDB requested by the login the login failed login failed by the user microsoftaccount i moj email izbaci

<Window x:Class="wpfloginscreen.LoginScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Login" Height="319" Width="300" FontSize="14" Background="Gray">
<Border Background="#2e3137" CornerRadius="20" Margin="20">
<StackPanel Margin="20">
<Label Content="Login" Foreground="White" FontSize="25" HorizontalAlignment="Center"/>
<Separator></Separator>
<Label Content="Username" Foreground="White"/>
<TextBox Name="txtUsername" Background="Black" Foreground="White" FontSize="18"/>
<Label Content="Password" Foreground="White"/>
<PasswordBox Name="txtPassword" Background="Black" Foreground="White" FontSize="18"/>
<Button Name="btnSubmit" Click="btnSubmit_Click" Content="Submit" Margin="60 10" Background="#545d6a" Foreground="White" FontSize="18"/>
</StackPanel>
</Border>
</Window>
[ Shadowed @ 29.05.2018. 21:15 ] @
OK, onda ti je problem u povezivanju sa bazom podataka. Moras u connection string dodati username i password koji odgovaraju SQL Serveru na koji se povezujes. Proguglaj malo da nadjes tacno uputstvo.
[ android27 @ 29.05.2018. 21:25 ] @
stavio sam isto i na sql username i sifru kao na visual ali opet ista greska
[ android27 @ 29.05.2018. 22:20 ] @
skonto sam sta zeza izgleda nezna sta je UserPass pa me otkaci pa sam moro stavit Password to je bilo problem i kod sql server i kod visual studio sad radi odo nastavit ovo dalje kod zadatka radit ako zapne javljam hvala vam Shadowed na pomoci
[ android27 @ 03.06.2018. 09:01 ] @
mozel mala pomoc opet napravio sam za sacuvanje kod ali nece gdje sam pogresio??

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void btn_save_Click(object sender, RoutedEventArgs e)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ToString();
try
{
if (conn.State == ConnectionState.Closed)
conn.Open();
String query = "insert into ADMIN_1 (Id,Username,Password,IsAdmin) values(˙" + this.txtID.Text + "˙,˙" + this.txtUsername.Text + "˙,˙" + this.txtPassword.Text + "˙,˙" + this.txtIsAdmin.Text + "˙)";
SqlCommand sqlCmd = new SqlCommand(query);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.ExecuteNonQuery();
MessageBox.Show("Saved");

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
conn.Close();
}
}
}
}
}
[ Shadowed @ 03.06.2018. 09:45 ] @
"Neće" se ne racuna :) Koju gresku ti daje?
[ android27 @ 03.06.2018. 10:15 ] @
zasad ne izbacuje nikakve greske pokrenem aplikaciju al nece save kad pritisnem da sacuva napravio sam username,password,id,isadmin na xml i na kod pogledo sam na microsoft sql u database jeli ista sacuvo ali nije nista ne znam kako mi radi kod a nece da sacuva
[ android27 @ 04.06.2018. 19:07 ] @
uspio sam napravit save ali sad mi izbacuje gresku ExecutenonQuery Connection property has not been initialized
[ Shadowed @ 04.06.2018. 21:07 ] @
Nisi komandi dao koju konekciju da koristi. Napravio si konkeciju ali je nisi dodelio komandi.
[ android27 @ 04.06.2018. 21:15 ] @
Shadowed mozesli pomoc oko ovog kako tu komandu da dodjelim mozesli primjer koda dat ili pomoc mi oko ovog koda hvala vam unaprijed
[ Shadowed @ 04.06.2018. 21:26 ] @
OK, generalno kada koristis bazu podataka, kreiras konekciju koja obavlja povezivanje sa sql serverom. Zatim kreiras komandu koja ce se izvrsiti. Ali ona mora da se izvrsi na nekom sql serveru, ne moze tako, sama za sebe. Zato moramo da joj "damo" konekciju.
To mozes da uradis na dva nacina: da dodelis Connection property-u ili da prosledis u kontruktor prilikom kreiranja.

Dakle, u tvom slucaju bi uradio jednu od sledece dve stvari:
Code:

SqlCommand sqlCmd = new SqlCommand(query);
sqlCmd.Connection = conn;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.ExecuteNonQuery();


ili

Code:

SqlCommand sqlCmd = new SqlCommand(query, conn);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.ExecuteNonQuery();



U onom prvom kodu koji si dao si imao ovu drugu opciju.
[ android27 @ 04.06.2018. 21:38 ] @
Hvala vam na brzom odgovoru, upiso sam to pa sam sad probo save ali izbacilo mi incorrect syntax near '"'. Kako da nadzem gdje ova syntax greska pa da popravim, ja sam pocetnik kod ovog programiranje pa jos ucim neke stvari
[ Shadowed @ 04.06.2018. 22:41 ] @
Ide li? :) Evo ti hint: obrati paznju na navodnike u SQL-u.
[ android27 @ 04.06.2018. 22:55 ] @
Izgleda citav mi kod nije valjo trebo sam dodat addparametars pa username kao na login kodu sto sam radio objavit cu sutra novi kod sto sam radio za save, moram sad skontat za prozor da mi izbaci od korisnika imena,sifre i id sa strane i da ima opcija da se edituju i izbrisu... to ce potrajat :) ako zapne javit cu se hvala vama na pomoci :D
[ Shadowed @ 04.06.2018. 23:02 ] @
Koriscenje parametara je svakako bolji nacin i to bih ti napisao nakon sto pohvatas osnovnu ideju. Ako si ukapirao kako da ih koristis, nastavi sa njima.
Inace, problem je bio sto si umesto apostrofa (') imao neku "gornju tacku".
[ android27 @ 13.06.2018. 20:41 ] @
sad sam doso da one korisnike napravim da izbaci kad kliknem na show ali nesto neradi, nepokazuje mi nikakve greske nego nece da ji prikaze gdje sam sad pogresio

/code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ToString();

conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into ADMIN_1 (Username,Password,IsAdmin) values(@username,@password,@admin)";
cmd.Parameters.AddWithValue("@username", this.txtUsername.Text);
cmd.Parameters.AddWithValue("@password", this.txtPassword.Text);
cmd.Parameters.AddWithValue("@admin", this.txtIsAdmin.Text);

cmd.ExecuteNonQuery();

conn.Close();
MessageBox.Show("Saved");
}
private void Button_Click2(object sender, RoutedEventArgs e)
{
SqlConnection connection = new SqlConnection();

connection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ToString();

SqlCommand command = new SqlCommand();

command.Connection = connection;
command.CommandText = "Select * From ADMIN_1 (Username,Password,IsAdmin) values(@username,@password,@admin)";
command.CommandType = CommandType.Text;

try
{
connection.Open();

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())
{
string value = (string)reader["Username"];
string value2 = (string)reader["Password"];
string value3 = (string)reader["IsAdmin"];

string item = string.Format(value, value2 , value3);

this.listBox1.Items.Add(item);
}

reader.Close();
}
catch
{
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
}
}
}

/code

ovo je od xaml

<Window x:Class="wpfloginscreen.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox x:Name="txtUsername" HorizontalAlignment="Left" Height="23" Margin="65,34,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="txtPassword" HorizontalAlignment="Left" Height="23" Margin="65,75,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="txtIsAdmin" HorizontalAlignment="Left" Height="23" Margin="65,116,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Button Content="Save" HorizontalAlignment="Left" Margin="91,163,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<Label Content="Username" HorizontalAlignment="Left" Margin="-3,31,0,0" VerticalAlignment="Top"/>
<Label Content="Password" HorizontalAlignment="Left" Margin="0,72,0,0" VerticalAlignment="Top"/>
<Label Content="IsAdmin" HorizontalAlignment="Left" Margin="7,113,0,0" VerticalAlignment="Top"/>
<ListBox x:Name="listBox1" Height="100" Margin="271,31,10,0" VerticalAlignment="Top"/>
<Button Content="Show" HorizontalAlignment="Left" Margin="354,148,0,0" VerticalAlignment="Top" Width="74" Click="Button_Click2"/>

</Grid>
</Window>


[ Shadowed @ 13.06.2018. 21:51 ] @
Proveri SQL query.
[ android27 @ 19.06.2018. 18:40 ] @
mozel mi neko dat primjer koda za edit dugme sto pravim ali da je malo lakse da kad pritisnem edit mogu izmjenit podatke u sql pokusavam pravit neke kodove ali nijedan nece ovo sam pravio i nije uspjelo

/code

private void Button_Click_1(object sender, RoutedEventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ToString();

SqlConnection conn1 = new SqlConnection();
SqlDataAdapter ad = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
String str = "UPDATE Username, Password, IsAdmin FROM ADMIN_1";
cmd.Parameters.AddWithValue("@Username", this.txtUsername.Text);
cmd.Parameters.AddWithValue("@IsAdmin", this.txtIsAdmin.Text);
cmd.Parameters.AddWithValue("@Password", this.txtPassword.Text);
//add whatever parameters you required to update here
int rows = cmd.ExecuteNonQuery();
conn.Close();
}
}
}
[ Shadowed @ 19.06.2018. 21:51 ] @
Nije ti dobar SQL query.
Pogledaj ovde primere za select, insert, update i delete (u ovom konkretnom slucaju za update).
[ android27 @ 21.06.2018. 22:11 ] @
hvala vam na pomoci evo kod za ovu zadacu nadam se da ce pomoci drugima...

1. ovo je za prozor mainwindow.xaml kod

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
SqlConnection con;
DataTable dt;

public MainWindow()
{
InitializeComponent();

//Connect your access database
con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ToString();
BindGrid();
}

//Display records in grid
private void BindGrid()
{
SqlCommand cmd = new SqlCommand();
if (con.State != ConnectionState.Open)
con.Open();
cmd.Connection = con;
cmd.CommandText = "select * from ADMIN_1";
SqlDataAdapter da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
gvData.ItemsSource = dt.AsDataView();

if (dt.Rows.Count > 0)
{
lblCount.Visibility = System.Windows.Visibility.Hidden;
gvData.Visibility = System.Windows.Visibility.Visible;
}
else
{
lblCount.Visibility = System.Windows.Visibility.Visible;
gvData.Visibility = System.Windows.Visibility.Hidden;
}

}

//Add records in grid
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
SqlCommand cmd = new SqlCommand();
if (con.State != ConnectionState.Open)
con.Open();
cmd.Connection = con;

if (txtId.Text != "")
{
if (txtId.IsEnabled == true)
{
cmd.CommandText = "insert into ADMIN_1(Id,Username,Password,IsAdmin) Values(" + txtId.Text + ",'" + txtUsername.Text + "','" + txtPassword.Text + "','" + txtIsAdmin.Text + "')";
cmd.ExecuteNonQuery();
BindGrid();
MessageBox.Show("korisnik je uspjesno dodat...");
ClearAll();
}
else
{
cmd.CommandText = "update ADMIN_1 set Username='" + txtUsername.Text + "',Password='" + txtPassword.Text + "',IsAdmin='" + txtIsAdmin.Text + "' where Id=" + txtId.Text;
cmd.ExecuteNonQuery();
BindGrid();
MessageBox.Show("korisnicki podaci su azurirani...");
ClearAll();
}
}
else
{
MessageBox.Show("molimo dodajte Id.......");
}
}

//Clear all records from controls
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
ClearAll();
}

private void ClearAll()
{
txtId.Text = "";
txtUsername.Text = "";
txtPassword.Text = "";
txtIsAdmin.Text = "";
btnAdd.Content = "Add";
txtId.IsEnabled = true;
}

//Edit records
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
if (gvData.SelectedItems.Count > 0)
{
DataRowView row = (DataRowView)gvData.SelectedItems[0];
txtId.Text = row["Id"].ToString();
txtUsername.Text = row["Username"].ToString();
txtPassword.Text = row["Password"].ToString();
txtIsAdmin.Text = row["IsAdmin"].ToString();
txtId.IsEnabled = false;
btnAdd.Content = "Update";
}
else
{
MessageBox.Show("molimo izaberite korisnika iz liste...");
}
}

//Delete records from grid
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
if (gvData.SelectedItems.Count > 0)
{
DataRowView row = (DataRowView)gvData.SelectedItems[0];

SqlCommand cmd = new SqlCommand();
if (con.State != ConnectionState.Open)
con.Open();
cmd.Connection = con;
cmd.CommandText = "delete from ADMIN_1 where Id=" + row["Id"].ToString();
cmd.ExecuteNonQuery();
BindGrid();
MessageBox.Show("korisnik uspjesno izbrisan...");
ClearAll();
}
else
{
MessageBox.Show("molimo izaberite korisnika iz liste...");
}
}

//Exit
private void btnExit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}

dole je xaml izgled aplikacije..

<Window x:Class="wpfloginscreen.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Code Scratcher WPF with access Add, Edit and Delete operations" Height="700" Width="900" Background="DarkOrange" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" >
<Window.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20"/>
<Setter Property="Width" Value="160"/>
<Setter Property="Margin" Value="10"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="20"/>
<Setter Property="Width" Value="250"/>
<Setter Property="Margin" Value="10"/>
</Style>
</Window.Resources>
<DockPanel Name="dockMain" VerticalAlignment="top" HorizontalAlignment="Center" LastChildFill="False">
<StackPanel>
<Label Content="Main Window" HorizontalAlignment="Center" FontSize="36" FontWeight="Bold"></Label>
<WrapPanel>
<TextBlock Text="ID : "/>
<TextBox Name="txtId" />
</WrapPanel>
<WrapPanel>
<TextBlock Text="User Name : "/>
<TextBox Name="txtUsername" />
</WrapPanel>
<WrapPanel>
<TextBlock Text="Password : "/>
<TextBox Name="txtPassword" />
</WrapPanel>
<WrapPanel>
<TextBlock Text="IsAdmin : "/>
<TextBox Name="txtIsAdmin" TextWrapping="Wrap" AcceptsReturn="True"/>
</WrapPanel>
<WrapPanel Margin="0" HorizontalAlignment="Center" Height="59">
<Button Name="btnAdd" Content="Add" FontSize="25" Width="120" Margin="5" Click="btnAdd_Click" />
<Button Name="btnEdit" Content="Edit" FontSize="25" Width="120" Margin="5" Click="btnEdit_Click" />
<Button Name="btnDelete" Content="Delete" FontSize="25" Width="120" Margin="5" Click="btnDelete_Click" />
<Button Name="btnCancel" Content="Cancel" FontSize="25" Width="120" Margin="5" Click="btnCancel_Click" />
<Button Name="btnExit" Content="Exit" FontSize="25" Width="120" Margin="5" Background="#400000" Foreground="Bisque" Click="btnExit_Click" />
</WrapPanel>
<Label Content="Nema Podataka." Name="lblCount" HorizontalAlignment="Center" FontSize="16" FontWeight="Bold" Foreground="#FFE10000"></Label>
<WrapPanel Margin="20" HorizontalAlignment="Center">
<DataGrid AutoGenerateColumns="True" Name="gvData" SelectionMode="Single" FontSize="15" Padding="5" Background="Black" />
</WrapPanel>
</StackPanel>
</DockPanel>
</Window>

za login screen napravite novi xaml i kod evo dole ispod je kod

using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for LoginScreen.xaml
/// </summary>
public partial class LoginScreen : Window
{
public LoginScreen()
{
InitializeComponent();
}

private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
SqlConnection sqlCon = new SqlConnection(@"Data Source=DESKTOP-AL48L30\SIDIKSQL; Initial Catalog=ADMIN_1; Integrated Security=True;");
try
{
if (sqlCon.State == ConnectionState.Closed)
sqlCon.Open();
String query = "SELECT COUNT(1) FROM ADMIN_1 WHERE Username=@Username AND Password=@Password";
SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.Parameters.AddWithValue("@Username",txtUsername.Text);
sqlCmd.Parameters.AddWithValue("@Password", txtPassword.Password);
int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
if (count == 1)
{
MainWindow dashboard = new MainWindow();
dashboard.Show();
this.Close();
}
else
{
MessageBox.Show("Username or password is incorrect.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlCon.Close();
}
}

private void Image_MouseLeave(object sender, MouseEventArgs e)
{
Image img = (Image)sender;
DoubleAnimation animation = new DoubleAnimation(0,TimeSpan.FromSeconds(1));
img.BeginAnimation(Image.OpacityProperty, animation);
}

private void Image_MouseEnter(object sender, MouseEventArgs e)
{
Image img = (Image)sender;
DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(1));
img.BeginAnimation(Image.OpacityProperty, animation);
}
}
}

dole ispod xaml izgled aplikacije

<Window x:Class="wpfloginscreen.LoginScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Login" Height="404.151" Width="303.813" FontSize="14" Background="Black">
<Border Background="#2e3137" CornerRadius="20" Margin="20,20,20,5">
<StackPanel Margin="20">
<Image Height="100" Margin="0,0,0,0" Source="3.png" Stretch="Fill" MouseLeave="Image_MouseLeave" MouseEnter="Image_MouseEnter"/>
<Button x:Name="btnSubmit" Click="btnSubmit_Click" Content="PRIJAVA" Margin="60 10" Background="#545d6a" Foreground="White" FontSize="18" RenderTransformOrigin="0.611,0.737"/>
<Separator/>
<Label Content="Username" Foreground="White"/>
<TextBox x:Name="txtUsername" Background="#545d6a" Foreground="White" FontSize="18"/>
<Label Content="Password" Foreground="White"/>
<PasswordBox x:Name="txtPassword" Background="#545d6a" Foreground="White" FontSize="18"/>
</StackPanel>
</Border>
</Window>


[ android27 @ 21.06.2018. 22:12 ] @
trebace mi sad pomoc oko zadace aukcijska prodaja ko zna nek mi ode na novu temu sto cu otvorit
[ computerinspector @ 12.03.2019. 17:36 ] @
Pozdrav, ima li resenja aukcijske prodaje?