private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                using (FacultyLinqDataContext fup = new FacultyLinqDataContext())
                {
                    FacultyLinqDataContext fupdate = new FacultyLinqDataContext();
                    int          id   = int.Parse(label6.Text);
                    Faculty_Info fobj = fupdate.Faculty_Infos.SingleOrDefault(Faculty_Info => Faculty_Info.Id == id);
                    MessageBox.Show(textBox1.Text);
                    fobj.Name      = textBox1.Text;
                    fobj.Email     = textBox2.Text;
                    fobj.Contact   = textBox3.Text;
                    fobj.Address   = textBox4.Text;
                    fobj.Depatment = textBox5.Text;

                    fupdate.SubmitChanges();

                    MessageBox.Show("Data Updated");
                }
            }
            catch (Exception ex)
            {
                //FacultyLinqDataContext fupdate = new FacultyLinqDataContext();

                //fupdate.SubmitChanges();
                MessageBox.Show(ex.Message);
                ///  textBox1.Text = null;
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                FacultyLinqDataContext db  = new FacultyLinqDataContext();
                Faculty_Info           fac = new Faculty_Info();
                fac.Name            = textBox1.Text;
                fac.Email           = textBox2.Text;
                fac.Contact         = textBox3.Text;
                fac.Address         = textBox4.Text;
                fac.Education       = textBox5.Text;
                fac.Age             = textBox6.Text;
                fac.Sex             = textBox7.Text;
                fac.Religion        = textBox8.Text;
                fac.PreferredCourse = textBox9.Text;
                fac.DayOff          = "Friday";
                fac.Depatment       = textBox13.Text;
                fac.CreatePassword  = textBox12.Text;
                db.Faculty_Infos.InsertOnSubmit(fac);
                db.SubmitChanges();
                File.Copy(temp_a, @"C:\Users\Tomal\Documents\Visual Studio 2013\Projects\Info\AllInfo\facultypropic\" + textBox1.Text + ".jpg");

                MessageBox.Show("Data Inserted");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            FacultyLinqDataContext fdelete = new FacultyLinqDataContext();

            Faculty_Info finfo = fdelete.Faculty_Infos.Single(Faculty_Info => Faculty_Info.Name == textBox1.Text);

            fdelete.Faculty_Infos.DeleteOnSubmit(finfo);

            fdelete.SubmitChanges();
            MessageBox.Show("Data ddeleted");
        }