You are on page 1of 4

Question # 1: Create a Application in which you have to use 4 Controls, application interface

and design is your choice but u have to use these controls properly in some kind of logical
connection in working.

(a) Tree View (b) List View ( c) Combo Box

Question # 2: Create a project of Employee (Eid, Ename, ESalary, EDesignation, DOB,


EJoingDate)

(a) Create a form that Add Employee with Query: AddEmployeeForm


(b) Add Employee Data on AddEmployeeForm having Employee Image.

ANS]1 Tree view

CODE: private void button1_Click(object sender, EventArgs e)


{
treeView1.Nodes.Add("Name");
treeView1.Nodes.Add("class");
treeView1.Nodes.Add("Semister");

B]List view
CODE:
private void button2_Click(object sender, EventArgs e)
{
ListViewItem lvi = new ListViewItem(textBox1.Text);
lvi.SubItems.Add(textBox2.Text);
lvi.SubItems.Add(textBox3.Text);
listView1.Items.Add(lvi);
textBox1.Text =
""; textBox2.Text
= "";
textBox3.Text =
"";

}
C] Combox
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;
using System.Data.SqlClient;

namespace WindowsFormsApplication22
{
public partial class Add : Form
{
public Add()
{
InitializeComponent();
}
string lastDir;
string filenaem;
private void label7_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files( *.png; *.jpg; *.bmp;)|*.png; *.jpg; *.bmp";
if (lastDir == null)
open.InitialDirectory = @"c:\";
else
open.InitialDirectory = lastDir;
if (open.ShowDialog() == DialogResult.OK)
{
filenaem = System.IO.Path.GetFullPath(open.FileName);
lastDir = open.FileName;
label7.Text = lastDir;
pictureBox1.Image = new Bitmap(open.FileName);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;

}
}

private void button1_Click(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection("Data Source=DESKTOP-
EDK6EVJ\\SQLEXPRESS;Initial Catalog=project;Integrated Security=True;");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "insert into
shopping(product,category,amount,unitprice,picturepath)values("+"'"+textBox1.Text+"','"
+textBox3.Text+"',"+Convert.ToInt32(textBox4.Text)
+","+Convert.ToInt32(textBox5.Text)
+",'"+ lblpath.Text + "')";
MessageBox.Show(cmd.CommandText);
cmd.CommandType = CommandType.Text;

try
{
int n;

n = cmd.ExecuteNonQuery();
if (n > 0)
MessageBox.Show("Record stored successfully");
else
MessageBox.Show("Error");
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}

private void label3_Click(object sender, EventArgs e)


{

}
}
}

You might also like