コード例 #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridView1.RowCount != 0)
            {
                try
                {
                    var dc = new ClassSRMDataContext(Config.connection);

                    byte[] imageData = imageToByteArray(img.Image);
                    int    id        = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
                    dc.UpdateStudent(id, (int)lookUpEdit2.EditValue, txtName.Text, txtLName.Text, txtFName.Text, cmbGender.Text, imageData);
                    tblStudentBindingSource.EndEdit();
                    dc = new ClassSRMDataContext(Config.connection);
                    XtraMessageBox.Show("دانش آموز موردنظر با موفقیت ویرایش شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadStudent();
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                XtraMessageBox.Show("اطلاعاتی برای ویرایش وجود ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }