0% found this document useful (0 votes)
19 views

Dotnet tutorial

This is dot net tutorial for b.tech student

Uploaded by

Deni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Dotnet tutorial

This is dot net tutorial for b.tech student

Uploaded by

Deni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

23SOECE13013 Enterprise Computing Through .

NET Framework (CE525)

Tutorial – 2

1.CREATE A CALCULATOR BASED APPLICATION

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Security.AccessControl;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Calculator

public partial class Calculator : Form

int count;

float num, ans;

public Calculator()

InitializeComponent();

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
}

private void inp_TextChanged(object sender, EventArgs e)

private void one_Click(object sender, EventArgs e)

inp.Text = inp.Text + 1;

private void two_Click(object sender, EventArgs e)

inp.Text = inp.Text + 2;

private void three_Click(object sender, EventArgs e)

inp.Text = inp.Text + 3;

private void four_Click(object sender, EventArgs e)

inp.Text = inp.Text + 4;

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)

private void five_Click(object sender, EventArgs e)

inp.Text = inp.Text + 5;

private void six_Click(object sender, EventArgs e)

inp.Text = inp.Text + 6;

private void seven_Click(object sender, EventArgs e)

inp.Text = inp.Text + 7;

private void eight_Click(object sender, EventArgs e)

inp.Text = inp.Text + 8;

private void nine_Click(object sender, EventArgs e)

inp.Text = inp.Text + 9;

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
private void zero_Click(object sender, EventArgs e)

inp.Text = inp.Text + 0;

private void backspace_Click(object sender, EventArgs e)

if (float.Parse(inp.Text) >= float.Parse(inp.Text))

inp.Text = inp.Text.Remove(0, 1);

else

inp.Clear();

private void add_Click(object sender, EventArgs e)

num = float.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 1;

private void sub_Click(object sender, EventArgs e)

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
{

num = float.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 2;

private void mul_Click(object sender, EventArgs e)

num = float.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 3;

private void div_Click(object sender, EventArgs e)

num = float.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 4;

private void per_Click(object sender, EventArgs e)

num = float.Parse(inp.Text);

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
inp.Clear();

inp.Focus();

count = 5;

private void clearall_Click(object sender, EventArgs e)

inp.Text = inp.Text.Remove(0);

private void sum_Click(object sender, EventArgs e)

switch (count)

case 1:

ans = num + float.Parse(inp.Text);

inp.Text = ans.ToString();

break;

case 2:

ans = num - float.Parse(inp.Text);

inp.Text = ans.ToString();

break;

case 3:

ans = num * float.Parse(inp.Text);

inp.Text = ans.ToString();

break;

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
case 4:

ans = num / float.Parse(inp.Text);

inp.Text = ans.ToString();

break;

private void clear_Click(object sender, EventArgs e)

inp.Text = inp.Text.Remove(1);

private void point_Click(object sender, EventArgs e)

int c = inp.TextLength;

int flag = 0;

string text = inp.Text;

for (int i = 0; i < c; i++)

if (text[i].ToString() == ".")

flag = 1; break;

else

flag = 0;

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)
}

if (flag == 0)

inp.Text = inp.Text + ".";

Output:

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)

2.CREATE MENUSTRIP TOOL AND DESIGN ONE SIMPLE STUDENT


MANAGEMENT SYSTEM'S DESIGN (USE PROPERTY LIKE
BACKGROUND IMAGE,BACK COLOUR ,FORECOLOR AND SO ON..)

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 Student
{
public partial class AddStudent : Form
{
public AddStudent()
{
InitializeComponent();
}

private void AddStudent_Load(object sender, EventArgs e)


{

private void openFileDialog1_FileOk(object sender, CancelEventArgs e)


{

private void submit_Click(object sender, EventArgs e)


{

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)

name.Text = name.Text;
email.Text = email.Text;
enroll.Text = enroll.Text;
colr.AnyColor = true;
var fd = new System.Windows.Forms.OpenFileDialog();
fd.Filter = "jpg files|*.jpg";
if (red.Checked == true)
{
if (colr.ShowDialog() == DialogResult.OK)
{
BackColor = colr.Color;
}
}
else
{
if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string fileToOpen = fd.FileName;
System.IO.FileInfo File = new System.IO.FileInfo(fd.FileName);
BackgroundImage = Image.FromFile(fd.FileName);
}
}
if (forcor.ShowDialog() == DialogResult.OK)
{
ForeColor = forcor.Color;
title.ForeColor = forcor.Color;
display.ForeColor = forcor.Color;
}

display.Visible = true;
display.Text = name.Text + "\n" + email.Text +"\n"+enroll.Text;

}
}

HARSHIL VANPARIA Computer Engineering


23SOECE13013 Enterprise Computing Through .NET Framework (CE525)

Output:

HARSHIL VANPARIA Computer Engineering

You might also like