Skip to content

Instantly share code, notes, and snippets.

@AungWinnHtut
Last active January 27, 2018 10:32
Show Gist options
  • Save AungWinnHtut/cde1636244226d9819c9ec2b1a6c5c8e to your computer and use it in GitHub Desktop.
Save AungWinnHtut/cde1636244226d9819c9ec2b1a6c5c8e to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace _2018012701_CS_FIO_signin_signup
{
public partial class frmSignIn : Form
{
public frmSignIn()
{
InitializeComponent();
}
private void btnSignup_Click(object sender, EventArgs e)
{
this.Hide();
frmSignup frmsignup = new frmSignup();
frmsignup.Show();
}
private void btnSignin_Click(object sender, EventArgs e)
{
string sUname = txtUname.Text.ToString();
string sPass = txtPass.Text.ToString();
string sFname = sUname + "reg.txt";
string sFilePass = "";
if (File.Exists(sFname))
{
StreamReader sr = new StreamReader(sFname);
sFilePass = sr.ReadLine();
sr.Close();
if (sPass == sFilePass)
{
MessageBox.Show("password is correct");
}
else
{
MessageBox.Show("wrong username or password");
}
}
else
{
MessageBox.Show("wrong username or password");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace _2018012701_CS_FIO_signin_signup
{
public partial class frmSignup : Form
{
public frmSignup()
{
InitializeComponent();
}
private void btnSignup_Click(object sender, EventArgs e)
{
string sUname = txtUname.Text.ToString();
string sPass = txtPass.Text.ToString();
string sComfirm = txtComfirm.Text.ToString();
if ((sUname != "") && (sPass != "") && (sComfirm != ""))
{
string sFname = sUname + "reg.txt";
if (!File.Exists(sFname))
{
StreamWriter sw = new StreamWriter(sFname);
sw.WriteLine(sPass);
sw.Close();
this.Hide();
frmSignIn frmsignin = new frmSignIn();
frmsignin.Show();
}
else
{
MessageBox.Show("username already exists, please choose another username");
}
}
else
{
MessageBox.Show("Fill all data to sign up");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment