LoginApp/.vs/LoginApp/v15/.suo
LoginApp/.vs/LoginApp/v15/Browse.VC.db
LoginApp/.vs/LoginApp/v15/Server/sqlite3/db.lock
LoginApp/.vs/LoginApp/v15/Server/sqlite3/storage.ide
LoginApp/.vs/LoginApp/v15/Server/sqlite3/storage.ide-shm
LoginApp/.vs/LoginApp/v15/Server/sqlite3/storage.ide-wal
LoginApp/LoginApp.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoginApp", "LoginApp\LoginApp.csproj", "{0AE781A7-0126-4084-A95E-5657D17D2626}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0AE781A7-0126-4084-A95E-5657D17D2626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AE781A7-0126-4084-A95E-5657D17D2626}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AE781A7-0126-4084-A95E-5657D17D2626}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AE781A7-0126-4084-A95E-5657D17D2626}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F6F67228-E26C-4E76-9CB8-7A42D79180EF}
EndGlobalSection
EndGlobal
LoginApp/LoginApp/App.config
LoginApp/LoginApp/bin/Debug/LoginApp.exe
LoginApp/LoginApp/bin/Debug/LoginApp.exe.config
LoginApp/LoginApp/bin/Debug/LoginApp.pdb
LoginApp/LoginApp/DataObj.cs
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace LoginApp
{
public class DataObj
{
//character used to separate data values in the text file
private const char DELIMITER = '\t';
//used to store the file name
private string fileDir = "../../Data/";
private string filePath = "";
public DataObj()
{
//create the 'Data' folder to store the text files
//if it doesn't exist
Directory.CreateDirectory(fileDir);
//read the name of the class and use it for the file name
//put all files in the 'Data' folder
filePath = fileDir + this.GetType().Name + ".txt";
}
public void writeDataStream()
{
try
{
//create variable to store data string
string dataString = "";
//use reflection to read the data members of the class
foreach (var field in this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
{
dataString += field.GetValue(this) + DELIMITER.ToString();
}
//write the string to the file
File.WriteAllText(filePath, dataString);
//Display message
MessageBox.Show("Data saved to file successfully.");
}
catch (Exception ex)
{
Console.Out.WriteLine(ex.StackTrace + " - " + ex.Message);
}
}
public void readDataStream()
{
try
{
//read the data from to the file
string dataString = File.ReadAllText(filePath);
//create variable to store data string
string[] values = dataString.Split(DELIMITER);
int index = 0;
//use reflection to write the data members of the class
foreach (var field in this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
{
field.SetValue(this, values[index]);
index++;
}
}
catch (Exception ex)
{
Console.Out.WriteLine(ex.StackTrace + " - " + ex.Message);
}
}
}
}
LoginApp/LoginApp/Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LoginApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("Please enter username");
textBox1.Focus();
}
else if (textBox2.Text == "")
{
MessageBox.Show("Please enter password");
textBox2.Focus();
}
else if (textBox1.Text == "user1" && textBox2.Text == "password1")
{
MessageBox.Show("welcome user");
}
else
{
MessageBox.Show("incorrect username or password");
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
}
}
}
LoginApp/LoginApp/Form1.Designer.cs
namespace LoginApp
{
partial class Form1
{
///
/// Required designer variable.
/// private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
/// ///
true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(108, 219);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(90, 36);
this.button1.TabIndex = 0;
this.button1.Text = "Login";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(460, 219);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(84, 36);
this.button2.TabIndex = 1;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(47, 51);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(79, 17);
this.label1.TabIndex = 2;
this.label1.Text = "UserName:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(47, 120);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(73, 17);
this.label2.TabIndex = 3;
this.label2.Text = "Password:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(162, 51);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(365,...