Professional Documents
Culture Documents
Reg.Number:5648/06
Exam of Vb.net Using WindowsApplication&cs
3rd Year
ISM Departement
AS
BEGIN
insert into Screen values(@ScreenId,@ComputerId,@Name,@EntrenceDate,@Functiionalty,@Details,
@Location)
END
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=gestion;Integrated
Security=SSPI")
Dim str As String
Dim sqlInsert As String = "add1'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'"
Dim sqldelete As String = "dele1'{0}'"
Dim sqlsearch As String = "select1 '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',’{8}’"
Dim sqlupdate As String = "update1'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',’{8}’"
Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Form1ToolStripMenuItem.Click
Form1.Visible = True
End Sub
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
'TODO: This line of code loads data into the 'GestionDataSet.computer' table. You can move, or remove it, as
needed.
Me.ComputerTableAdapter.Fill(Me.gestionDataSet.computer)
End Sub
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("The Computer doesn't exist ")
End If
End Sub
End Sub
End Class
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form3
Public objConnection As New SqlConnection("Data Source=James;Initial Catalog=gestion;Integrated
Security=SSPI")
Dim str As String
Dim sqlInsert As String = "access'{0}','{1}','{2}','{3}','{4}','{5}','{6}'"
Dim sqldeletestr As String = "dele2'{0}'"
Dim sqlsearch As String = "searcha2 '{0}','{1}','{2}','{3}','{4}','{5}','{6}'"
Dim sqlupdatestr As String = "update2 '{0}','{1}','{2}','{3}','{4}','{5}','{6}'"
End Sub
End Sub
count += 1
TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)
TextBox7.Text = rd(6)
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")
End If
End Sub
End Sub
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btnupdate.Click
Try
str = String.Format(sqlupdatestr, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text,
TextBox5.Text, TextBox6.Text, CDate(TextBox7.Text))
Dim sql_com As New SqlCommand(str, objConnection)
objConnection.Open()
sql_com.ExecuteNonQuery()
objConnection.Close()
MsgBox("do you want to update your data ")
Me.AccessoryTableAdapter.Fill(Me.VbexamenDataSet.accessory)
sql_com = Nothing
str = ""
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class
Imports System
Imports System.Data
Imports System.Data.SqlClient
End Sub
End Sub
End Sub
count += 1
TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")
End If
End Sub
End Class
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form5
End Sub
End Sub
End Sub
count += 1
TextBox1.Text = rd(0)
TextBox2.Text = rd(1)
TextBox3.Text = rd(2)
TextBox4.Text = rd(3)
TextBox5.Text = rd(4)
TextBox6.Text = rd(5)
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
End While
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
If count = 0 Then
MsgBox("the id doesn't exist ")
End If
End Sub
Code with Cs
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.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string h = "Data source =.;Initial Catalog=gestion;Integrated Security=true";
public Form1()
{
InitializeComponent();
}
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.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form2()
{
InitializeComponent();
}
comboBox1.Enabled = true;
textBox2.Enabled = false;
textBox3.Enabled = false;
dateTimePicker1.Enabled = false;
textBox5.Enabled = false;
textBox6.Enabled = false;
textBox7.Enabled = false;
textBox8.Enabled = false;
textBox9.Enabled = false;
button1.Enabled = false;
button3.Enabled = false;
button5.Enabled = false;
//dataGridView1.Enabled = false;
con.Close();
con.Open();
string h = "select * from Computer";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Computer");
DataView dv = new DataView(ds.Tables["Computer"]);
dataGridView1.DataSource = dv;
}
con.Close();
con.Open();
string c = "select * from Computer where ComputerId='"+comboBox1.SelectedItem+"'";
SqlDataAdapter da2 = new SqlDataAdapter(c,con);
DataSet ds =new DataSet();
da2.Fill(ds,"Computer");
DataView dv =new DataView(ds.Tables["Computer"]);
DataTable dt =ds.Tables["Computer"];
comboBox1.DataBindings.Add("text",dv,"ComputerId");
textBox2.DataBindings.Add("text",dv,"Name");
textBox3.DataBindings.Add("text",dv,"Processor");
dateTimePicker1.DataBindings.Add("text",dv,"EntrenceDate");
textBox5.DataBindings.Add("text",dv,"Functionalty");
textBox6.DataBindings.Add("text",dv,"Details");
textBox7.DataBindings.Add("text",dv,"Status");
textBox8.DataBindings.Add("text",dv,"Network");
textBox9.DataBindings.Add("text",dv,"Location");
con.Close();
Form2_Load(sender, e);
}
}
}
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.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form3()
{
InitializeComponent();
}
comboBox2.SelectedValue= "";
con.Close();
con.Open();
string h = "select * from Screen";
SqlDataAdapter da = new SqlDataAdapter(h, con);
DataSet ds = new DataSet();
da.Fill(ds, "Screen");
DataView dv = new DataView(ds.Tables["Screen"]);
dataGridView1.DataSource = dv;
// b = false;
con.Close();
Form3_Load(sender, e);
}
con.Close();
con.Open();
string c = "select * from Screen where ScreenId='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Screen");
DataView dv = new DataView(ds.Tables["Screen"]);
DataTable dt = ds.Tables["Screen"];
comboBox1.DataBindings.Add("text", dv, "ScreenId");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name1");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functiionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");
}
private void label7_Click(object sender, EventArgs e)
{
}
}
}
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.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form4 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form4()
{
InitializeComponent();
}
// b = false;
con.Close();
Form4_Load(sender, e);
}
con.Close();
con.Open();
string c = "select * from Printer where PrinterId='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Printer");
DataView dv = new DataView(ds.Tables["Printer"]);
DataTable dt = ds.Tables["Printer"];
comboBox1.DataBindings.Add("text", dv, "PrinterId");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");
// b = false;
con.Close();
Form4_Load(sender, e);
}
private void button4_Click(object sender, EventArgs e)
{
comboBox1.Enabled = false;
comboBox2.Enabled = true;
textBox1.Enabled = true;
dateTimePicker1.Enabled =true;
textBox2.Enabled =true;
textBox3.Enabled =true ;
textBox4.Enabled = true;
//button1.Enabled =true;
button2.Enabled = false;
button3.Enabled = true;
button6.Enabled =true;
}
button2.Enabled = true;
//button3.Enabled = false;
// button6.Enabled = true;
}
}
}
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.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form5 : Form
{
private SqlConnection con;
public SqlConnection ccon
{
set { con = value; }
get { return ccon; }
}
public Form5()
{
InitializeComponent();
}
con.Close();
con.Open();
string c = "select * from Accessory where MaterielCode='" + comboBox1.SelectedItem + "'";
SqlDataAdapter da2 = new SqlDataAdapter(c, con);
DataSet ds = new DataSet();
da2.Fill(ds, "Accessory");
DataView dv = new DataView(ds.Tables["Accessory"]);
DataTable dt = ds.Tables["Accessory"];
comboBox1.DataBindings.Add("text", dv, "MaterielCode");
comboBox2.DataBindings.Add("text", dv, "ComputerId");
textBox1.DataBindings.Add("text", dv, "Name");
dateTimePicker1.DataBindings.Add("text", dv, "EntrenceDate");
textBox2.DataBindings.Add("text", dv, "Functionalty");
textBox3.DataBindings.Add("text", dv, "Details");
textBox4.DataBindings.Add("text", dv, "Location");
}
}
}