private void button3_Click(object sender, EventArgs e) { string empid = textBox1.Text; employeetab emp = ed.employeetabs.Single(e1 => e1.empid == empid); //To Retrieve one single record from the database for the given empid. emp.empid = textBox1.Text; // Mapping the data to the column in the table emp.empname = textBox2.Text.ToString(); // Mapping the data to the column in the table emp.empdep = textBox3.Text.ToString(); // Mapping the data to the column in the table //emp.EMP_LOCATION = txtEmpLocation.Text.ToString(); // Mapping the data to the column in the table if (imagename != "") { FileStream fs; fs = new FileStream(@imagename, FileMode.Open, FileAccess.Read); //a byte array to read the image byte[] picbyte = new byte[fs.Length]; fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); emp.empimage = picbyte; ed.SubmitChanges(); imagename = ""; } MessageBox.Show("Record Updated"); }
private void button2_Click(object sender, EventArgs e) { string empid = textBox1.Text.ToString(); //Here "ed" is the employeeDataContext employeetab emp = ed.employeetabs.Single(e1 => e1.empid == empid); //To Retrieve one single record from the database for the given empid. if (emp != null) { ed.employeetabs.DeleteOnSubmit(emp); ed.SubmitChanges(); MessageBox.Show("Record Deleted"); } }
private void button1_Click(object sender, EventArgs e) { employeetab empTable = new employeetab(); // calling the employee class in the employee.designer.cs file var empid = from data in ed.employeetabs where data.empid == textBox1.Text.ToString() select data; if (!empid.Any()) { if (imagename != "") { FileStream fs; fs = new FileStream(@imagename, FileMode.Open, FileAccess.Read); //a byte array to read the image byte[] picbyte = new byte[fs.Length]; fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); empTable.empid = textBox1.Text; empTable.empname = textBox2.Text.ToString(); empTable.empdep = textBox3.Text.ToString(); empTable.empimage = picbyte; ed.employeetabs.InsertOnSubmit(empTable); ed.SubmitChanges(); MessageBox.Show("Record Inserted Successfully"); } } else { MessageBox.Show("Record allready existing"); } }
partial void Deleteemployeetab(employeetab instance);
partial void Updateemployeetab(employeetab instance);
partial void Insertemployeetab(employeetab instance);