shruti@249-Assignment2
shruti@249-Assignment2
Rollno : 249
Semester: 4
Division : D
C#.net Assignment-2
Question 1:-
Create a C# Winforms to create Registration form, stored in an
oracle database and perform CRUD
operation for the same.
Fields are:
Id, Name
Profile Image(OpenFileDialog)
Gender(Radio)
Country
State
Select Favorite color(ColorDialog)
Hobby
Additionally, you can add the field and controls by your choice
with proper UI design
Output
Code
using Oracle.ManagedDataAccess.Client;
using System.Data;
using System;
namespace question1
public Form1()
InitializeComponent();
try
con1.Open();
}
}
dataAdapter.Fill(dataTable);
dataGridView1.DataSource = dataTable;
string id = textBoxID.Text;
string gender;
if (checked1)
gender = radioButton1.Text;
else
gender = radioButton2.Text;
string hobby;
if (checkBox1.Checked)
{
hobby = checkBox1.Text;
else if (checkBox2.Checked)
hobby = checkBox2.Text;
else if (checkBox3.Checked)
hobby = checkBox3.Text;
else
hobby = checkBox4.Text;
con2.Open();
cmd.ExecuteNonQuery();
con2.Close();
if (dlg.ShowDialog() == DialogResult.OK)
textBoxPath.Text = dlg.FileName;
if (cd.ShowDialog() == DialogResult.OK)
label8.BackColor = cd.Color;
statelist.Clear();
if (comboBox1.SelectedItem.ToString() == "India")
else
con4.Open();
string id = textBoxID.Text;
{
cmd.Parameters.Add(":id", textBoxID.Text);
int d = cmd.ExecuteNonQuery();
if (d > 0)
loaddata();
else
dataAdapter.Fill(dataTable);
dataGridView1.DataSource = dataTable;
cmd.Parameters.Add(":name", textBoxName.Text);
cmd.Parameters.Add(":id", textBoxID.Text);
con.Open();
int ra = cmd.ExecuteNonQuery();
con.Close();
if (ra > 0)
else
loaddata();
}
Question 2:-
Create a WinForms application where users can select a file using
OpenFileDialog,
choose a font using FontDialog, and pick a color using ColorDialog. These
preferences should
FontName,
FontSize,
FontStyle,
ColorCode
using System.Data;
namespace question2
public Form1()
InitializeComponent();
con.Open();
con1.Open();
string iquery = $@"insert into
prefer(userid,filepath,fontname,fontsize,fontstyle,color)
values('{userid}','{filepath}','{fontname}','{fontsize}','{fontstyle}',{color})";
cmd.ExecuteNonQuery();
con1.Close();
if (dlg.ShowDialog() == DialogResult.OK)
textBox2.Text = dlg.FileName;
if (fontDialog.ShowDialog() == DialogResult.OK)
label3.Font = fontDialog.Font;
}
}
if (cd.ShowDialog() == DialogResult.OK)
label4.BackColor = cd.Color;
con.Open();
dataAdapter.Fill(dataTable);
dataGridView1.DataSource = dataTable;
dataGridView1.DataSource = dataTable;