Felhasználói ablakok hozzáadása. Az 'is' és az 'as' operátorok használata.

This commit is contained in:
István Priskin 2022-05-16 19:16:31 +02:00
parent f32e4af616
commit 7fdb128b70
12 changed files with 426 additions and 22 deletions

View File

@ -0,0 +1,75 @@

namespace FelhasznalokGrafikus
{
partial class AdminForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(148, 46);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(188, 30);
this.label1.TabIndex = 0;
this.label1.Text = "Ez az admin ablak";
//
// button1
//
this.button1.Location = new System.Drawing.Point(203, 201);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Bezárás";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// AdminForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(489, 457);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "AdminForm";
this.Text = "AdminForm";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace FelhasznalokGrafikus
{
public partial class AdminForm : Form
{
public AdminForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -8,6 +8,13 @@ namespace FelhasznalokGrafikus
{ {
public string token; public string token;
public AdminUser(string tnev, string login, string jelszo, string email): base (tnev,login,jelszo,email)
{
}
public void belepes() public void belepes()
{ {
Console.WriteLine("Belépett mint admin felhasználó."); Console.WriteLine("Belépett mint admin felhasználó.");

View File

@ -8,9 +8,17 @@ namespace FelhasznalokGrafikus
{ {
public string teljesnev; public string teljesnev;
public string login; public string login;
private string jelszo; public string jelszo;
public string email; public string email;
public Felhasznalo(string tnev, string login, string jelszo, string email)
{
teljesnev = tnev;
this.login = login;
this.jelszo = jelszo;
this.email = email;
}
public void belepes() public void belepes()
{ {
Console.WriteLine("Belépett mint alap felhasználó."); Console.WriteLine("Belépett mint alap felhasználó.");

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon /> <ApplicationIcon />

View File

@ -30,33 +30,93 @@ namespace FelhasznalokGrafikus
private void InitializeComponent() private void InitializeComponent()
{ {
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.LoginBox = new System.Windows.Forms.TextBox();
this.JelszoBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(75, 40); this.button1.Location = new System.Drawing.Point(141, 210);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0; this.button1.TabIndex = 0;
this.button1.Text = "Teszt"; this.button1.Text = "Belépés";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.button1_Click);
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(69, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(219, 30);
this.label1.TabIndex = 1;
this.label1.Text = "Belépés a programba";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.Location = new System.Drawing.Point(69, 85);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Login-név:";
//
// LoginBox
//
this.LoginBox.Location = new System.Drawing.Point(141, 81);
this.LoginBox.Name = "LoginBox";
this.LoginBox.Size = new System.Drawing.Size(147, 23);
this.LoginBox.TabIndex = 3;
//
// JelszoBox
//
this.JelszoBox.Location = new System.Drawing.Point(141, 136);
this.JelszoBox.Name = "JelszoBox";
this.JelszoBox.Size = new System.Drawing.Size(147, 23);
this.JelszoBox.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label3.Location = new System.Drawing.Point(69, 140);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(39, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Jelszó:";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(357, 295); this.ClientSize = new System.Drawing.Size(357, 295);
this.Controls.Add(this.JelszoBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.LoginBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Felhasználókat tesztelő program";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox LoginBox;
private System.Windows.Forms.TextBox JelszoBox;
private System.Windows.Forms.Label label3;
} }
} }

View File

@ -12,30 +12,38 @@ namespace FelhasznalokGrafikus
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
private List<Felhasznalo> userek;
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
userek = new List<Felhasznalo>();
userek.Add(new Felhasznalo("Alap felhasználó","alap","alap123","alap@nn.hu"));
userek.Add(new AdminUser("Admin felhasználó", "admin", "admin123", "admin@nn.hu"));
userek.Add(new UgyfelUser("Ügyfél felhasználó", "ugyfel", "ugyfel123", "ugyfel@nn.hu"));
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
AdminUser au = new AdminUser(); foreach (Felhasznalo item in userek)
au.email = "admin@gszi.edu.hu"; {
au.login = "admin"; if( item.login==LoginBox.Text && item.jelszo==JelszoBox.Text)
au.teljesnev = "Adminisztrátor Felhasználó"; {
au.token = "83hfd8qnwr98mjfjq5464gjkl"; if (item is AdminUser)
au.belepes(); {
AdminForm af = new AdminForm();
Felhasznalo alap = new Felhasznalo(); af.ShowDialog();
alap.belepes(); break;
} else if ( item is UgyfelUser)
Felhasznalo f = new AdminUser(); {
Object ob = new UgyfelUser(); UgyfelUser kliens = item as UgyfelUser;
UgyfelForm uf = new UgyfelForm();
//((UgyfelUser)f).belepes(); uf.ShowDialog();
break;
}
Console.WriteLine("Teszt gomb nyomása."); }
}
} }
} }
} }

View File

@ -0,0 +1,75 @@

namespace FelhasznalokGrafikus
{
partial class UgyfelForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(95, 105);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 3;
this.button1.Text = "Bezárás";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(47, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(188, 30);
this.label1.TabIndex = 2;
this.label1.Text = "Ez az ügyfél ablak";
//
// UgyfelForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(279, 196);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "UgyfelForm";
this.Text = "UgyfelForm";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace FelhasznalokGrafikus
{
public partial class UgyfelForm : Form
{
public UgyfelForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -6,6 +6,11 @@ namespace FelhasznalokGrafikus
{ {
class UgyfelUser: Felhasznalo class UgyfelUser: Felhasznalo
{ {
public UgyfelUser(string tnev, string login, string jelszo, string email) : base(tnev, login, jelszo, email)
{
}
public void belepes() public void belepes()
{ {
Console.WriteLine("Ez az ügyfél belépése."); Console.WriteLine("Ez az ügyfél belépése.");