0% found this document useful (0 votes)
4 views6 pages

Lab-3 Task.docx

The document outlines a C# Windows Forms application that includes a login and signup functionality. Users can upload an image file during signup, which is saved along with their username, password, and gender selection. The application utilizes a 'student' class to encapsulate user data and a datastore to manage the stored information.

Uploaded by

saeeedk484
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Lab-3 Task.docx

The document outlines a C# Windows Forms application that includes a login and signup functionality. Users can upload an image file during signup, which is saved along with their username, password, and gender selection. The application utilizes a 'student' class to encapsulate user data and a datastore to manage the stored information.

Uploaded by

saeeedk484
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

namespace Lab_3_Task

{
public partial class Form1 : Form
{
public static Form1 Instance;
string fPath;
System.Drawing.Image fs; // Return type is Image
public Form1()
{
InitializeComponent();
Instance = this;
}

private void Form1_Load(object sender, EventArgs e)


{

private void upload_Click(object sender, EventArgs e)


{
OpenFileDialog fileDialog = new OpenFileDialog
{
InitialDirectory = "C:\\Users\\PMLS\\OneDrive\\Desktop\\SDA",
Title = "Choose image file",
Filter = "All Image Files|*.jpg;*.jpeg;*.bmp;*.gif;*.png;*.tif;*.tiff|JPeg Image|*.jpg;*.jpeg|Bitmap
Image|*.bmp|Gif Image|*.gif|Png Image|*.png|Tiff Image|*.tif;*.tiff"
};

if (fileDialog.ShowDialog() == DialogResult.OK)
{
fPath = fileDialog.FileName; // Save the file path
fs = System.Drawing.Image.FromFile(fPath); // Load the image
pictureBox1.Image = fs; // Display the image in the picture box
}

private void signup_Click(object sender, EventArgs e)


{
String extension = System.IO.Path.GetExtension(fPath);
String fileName = username.Text;
fileName = fileName + extension;
String path = System.IO.Directory.GetCurrentDirectory();

String pathWithName = System.IO.Path.Combine(path, fileName);

fs.Save(pathWithName);

student std = new student();


std.UserName = username.Text;
std.PassWord = password.Text;
//std.SelectAge = age.Text;
std.ImagePath = pathWithName;

if (male.Checked)
{
std.SelectGender = "Male";
}
else
{
if (female.Checked)
{
std.SelectGender = "Female";
}
}

datastore.data.Add(std);
MessageBox.Show("SignUp Successfully");

private void linklogin_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)


{
LoginForm loginForm = new LoginForm();

loginForm.ShowDialog();
this.Hide();
string fPath;
System.Drawing.Image fs;

}
}
}
Datastore class:​
Student class:
public class student
{
private string userName;
private string passWord;
private string selectGender;
private string selectAge;
private string fileContent;
private System.Drawing.Image fss;
private string imagePath;
//Encapsulation
public string UserName
{
get
{
return userName;
}

set
{
userName = value;
}
}

public string PassWord


{
get
{
return passWord;
}

set
{
passWord = value;
}
}
public string SelectGender
{
get
{
return selectGender;
}

set
{
selectGender = value;
}
}

public string SelectAge


{
get
{
return selectAge;
}

set
{
selectAge = value;
}
}

public string FileContent


{
get
{
return fileContent;
}

set
{
fileContent = value;
}

}
public string ImagePath
{
get { return imagePath; }
set { imagePath = value; }
}
}
}
Task#1​
Create a Login and Signup page. When the user enters their username and password in the login form,
their Name, Age, and picture should be displayed on a new form

You might also like