Example #1
0
 private void ms_main_edit_Click(object sender, EventArgs e)
 {
     if (dgv_main.SelectedRows.Count > 0)
     {
         int          id   = Convert.ToInt32(dgv_main.SelectedRows[0].Cells[0].Value.ToString());
         frm_add_edit edit = new frm_add_edit();
         edit.id   = id;
         edit.Text = "ویرایش";
         var person = (from persons in db.tbl_persons
                       where persons.Id == id
                       select persons).Single();
         edit.txt_firstname.Text   = person.firstname;
         edit.txt_lastname.Text    = person.lastname;
         edit.txt_phonenumber.Text = person.phonenumber;
         edit.txt_description.Text = person.description;
         if (edit.ShowDialog() == DialogResult.OK)
         {
             db = new DataBaseDataContext();
             var query = from persons in db.tbl_persons
                         select persons;
             dgv_main.DataSource = query;
         }
     }
     else
     {
         MessageBox.Show("لطفاً یک گزینه را اتنخاب کنید.", "ویرایش مخاطب", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #2
0
        private void ms_main_add_Click(object sender, EventArgs e)
        {
            frm_add_edit add = new frm_add_edit();

            if (add.ShowDialog() == DialogResult.OK)
            {
                db = new DataBaseDataContext();
                var query = from persons in db.tbl_persons
                            select persons;
                dgv_main.DataSource = query;
            }
        }