private void button1_Click(object sender, EventArgs e) { try { String firstname = textBox1.Text; String lastname = textBox2.Text; String contact = textBox3.Text; String email = textBox4.Text; DateTime db = dateTimePicker1.Value; int gender; if (radioButton1.Checked == true) { gender = 1; } else { gender = 2; } String cmd = String.Format("INSERT INTO Person(FirstName,LastName,Contact,Email,DateOfBirth,Gender) values('{0}','{1}','{2}','{3}','{4}','{5}' )", firstname, lastname, contact, email, db, gender); int rows = DbConnect.getInstance().exectuteQuery(cmd); MessageBox.Show(String.Format("{0} rows affected", rows)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { string query = string.Format("insert into Project(Description,Title) values('{0}','{1}')", richTextBox1.Text, textBox1.Text); DbConnect.getInstance().exectuteQuery(query); MessageBox.Show("Data Inserted Successfully..."); } catch (Exception ex) { MessageBox.Show("Error " + ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { String designation = comboBox1.Text; String salary = textBox2.Text; String cmd = String.Format("INSERT INTO Advisor(Designation,Salary) values('{0}','{1} )", designation, salary); int rows = DbConnect.getInstance().exectuteQuery(cmd); MessageBox.Show(String.Format("{0} rows affected", rows)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { String name = textBox1.Text; String totalmarks = textBox2.Text; String totalweightage = textBox3.Text; String cmd = String.Format("INSERT INTO Evaluation(Name,TotalMarks,TotalWeightage) values('{0}','{1}','{2}' )", name, totalmarks, totalweightage); int rows = DbConnect.getInstance().exectuteQuery(cmd); MessageBox.Show(String.Format("{0} rows affected", rows)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ProRecords_Load(object sender, EventArgs e) { String cmd = "Select * from Project"; var reader = DbConnect.getInstance().getData(cmd); List <Projects> project = new List <Projects>(); while (reader.Read()) { Projects pro = new Projects(); pro.ID = (int)reader.GetValue(0); pro.description = reader.GetString(1); pro.title = reader.GetString(2); project.Add(pro); } dataGridView1.DataSource = project; }
private void button1_Click(object sender, EventArgs e) { connect.Open(); try { String firstname = textBox1.Text; String lastname = textBox2.Text; String contact = textBox3.Text; String email = textBox4.Text; DateTime db = dateTimePicker1.Value; int gender; if (radioButton1.Checked == true) { gender = 1; } else { gender = 2; } String str = String.Format("INSERT INTO Person(FirstName,LastName,Contact,Email,DateOfBirth,Gender) values('{0}','{1}','{2}','{3}','{4}','{5}' )", firstname, lastname, contact, email, db, gender); int rows = DbConnect.getInstance().exectuteQuery(str); SqlCommand sc = new SqlCommand("select IDENT_CURRENT('Person')", connect); int s = Convert.ToInt32(sc.ExecuteScalar()); SqlCommand sc1 = new SqlCommand("Insert into Student Values (@Id,@RegistrationNo)", connect); sc1.CommandType = CommandType.Text; sc1.Parameters.AddWithValue("@Id", s); sc1.Parameters.AddWithValue("@RegistrationNo", textBox5.Text); sc1.ExecuteNonQuery(); connect.Close(); MessageBox.Show(String.Format("{0} rows affected", rows)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Report1_Load(object sender, EventArgs e) { String cmd = "SELECT GroupStudent.GroupId,Student.RegistrationNo,GroupProject.ProjectId,Project.Title,Project.Description,ProjectAdvisor.AdvisorId,ProjectAdvisor.AdvisorRole from GroupStudent INNER JOIN Student on GroupStudent.StudentId = Student.Id inner join GroupProject on GroupStudent.GroupId=GroupProject.GroupId inner join Project on GroupProject.ProjectId=Project.Id inner join ProjectAdvisor on GroupProject.ProjectId=ProjectAdvisor.ProjectId"; var reader = DbConnect.getInstance().getData(cmd); List <Report> project = new List <Report>(); while (reader.Read()) { Report pro = new Report(); pro.GroupID = (int)reader.GetValue(0); pro.RegistrationNo = reader.GetString(1); pro.ProjectID = (int)reader.GetValue(2); pro.title = reader.GetString(3); pro.description = reader.GetString(4); pro.AdvisorId = (int)reader.GetValue(5); pro.AdvisorRole = (int)reader.GetValue(6); project.Add(pro); } dataGridView1.DataSource = project; }
private void StdRecords_Load(object sender, EventArgs e) { String cmd = "Select * from Person"; var reader = DbConnect.getInstance().getData(cmd); List <Student> students = new List <Student>(); while (reader.Read()) { Student std = new Student(); std.ID = (int)reader.GetValue(0); std.firstname = reader.GetString(1); std.lastname = reader.GetString(2); std.contact = reader.GetString(3); std.email = reader.GetString(4); std.dob = reader.GetDateTime(5); std.gender = (int)reader.GetValue(6); students.Add(std); } dataGridView1.DataSource = students; }
private void Report2_Load(object sender, EventArgs e) { String cmd = "SELECT GroupStudent.GroupId,Student.RegistrationNo,GroupProject.ProjectId,Project.Title,Project.Description,GroupEvaluation.ObtainedMarks,Evaluation.Name from GroupStudent INNER JOIN Student on GroupStudent.StudentId=Student.Id inner join GroupProject on GroupStudent.GroupId=GroupProject.GroupId inner join Project on GroupProject.ProjectId=Project.Id inner join GroupEvaluation on GroupProject.GroupId=GroupEvaluation.GroupId inner join Evaluation on GroupEvaluation.EvaluationId=Evaluation.Id"; var reader = DbConnect.getInstance().getData(cmd); List <ReportClass> project = new List <ReportClass>(); while (reader.Read()) { ReportClass pro = new ReportClass(); pro.GroupID = (int)reader.GetValue(0); pro.RegistrationNo = reader.GetString(1); pro.ProjectID = (int)reader.GetValue(2); pro.title = reader.GetString(3); pro.description = reader.GetString(4); pro.ObtainedMarks = (int)reader.GetValue(5); pro.Name = reader.GetString(6); project.Add(pro); } dataGridView1.DataSource = project; }
public Group_Project() { InitializeComponent(); DbConnect.getInstance().ConnectionString = "Data Source=DESKTOP-TOIHAAB;Initial Catalog=ProjectA;User ID=sa;Password=java"; }
public Report1() { InitializeComponent(); DbConnect.getInstance().ConnectionString = "Data Source=DESKTOP-TOIHAAB;Initial Catalog=ProjectA;Persist Security Info=True;User ID=sa;Password=java"; }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { DbConnect.getInstance().closeConnection(); }