0% found this document useful (0 votes)
10 views16 pages

B.tech student preparation

Dot net example tutorial

Uploaded by

Deni
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)
10 views16 pages

B.tech student preparation

Dot net example tutorial

Uploaded by

Deni
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/ 16

23SOECE13030 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;

foat num, ans;

public Calculator()

InitializeComponent();

Zeal Raval Computer Engineering

23SOECE13030 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;

Zeal Raval Computer Engineering

23SOECE13030 Enterprise Computing Through .NET Framework (CE525)

private void fve_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;

Zeal Raval Computer Engineering


23SOECE13030 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 (foat.Parse(inp.Text) >= foat.Parse(inp.Text))

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

else

inp.Clear();

private void add_Click(object sender, EventArgs e)

num = foat.Parse(inp.Text);
inp.Clear();

inp.Focus();

count = 1;

private void sub_Click(object sender, EventArgs e)

Zeal Raval Computer Engineering

23SOECE13030 Enterprise Computing Through .NET Framework (CE525)

num = foat.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 2;

private void mul_Click(object sender, EventArgs e)

num = foat.Parse(inp.Text);

inp.Clear();

inp.Focus();
count = 3;

private void div_Click(object sender, EventArgs e)

num = foat.Parse(inp.Text);

inp.Clear();

inp.Focus();

count = 4;

private void per_Click(object sender, EventArgs e)

num = foat.Parse(inp.Text);

Zeal Raval Computer Engineering

23SOECE13030 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 + foat.Parse(inp.Text);

inp.Text = ans.ToString();

break;

case 2:

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

inp.Text = ans.ToString();

break;

case 3:

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

inp.Text = ans.ToString();

break;

Zeal Raval Computer Engineering


23SOECE13030 Enterprise Computing Through .NET Framework (CE525)

case 4:

ans = num / foat.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 fag = 0;

string text = inp.Text;

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

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

{
fag = 1; break;

else

fag = 0;

Zeal Raval Computer Engineering

23SOECE13030 Enterprise Computing Through .NET Framework (CE525)

if (fag == 0)

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

Output:
Zeal Raval Computer Engineering

23SOECE13030 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)

Zeal Raval Computer Engineering

23SOECE13030 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;

Zeal Raval Computer Engineering


23SOECE13030 Enterprise Computing Through .NET Framework (CE525)

Output:
Zeal Raval Computer Engineering

You might also like