private void btnSave_Click(object sender, EventArgs e) { try { var dc = new ClassSRMDataContext(Config.connection); var val = 0; var tosifi = Config.ReadSetting("Tosifi System"); if (tosifi == "true") { switch (cmbScore2.SelectedIndex) { case 0: val = 20; break; case 1: val = 18; break; case 2: val = 15; break; case 3: val = 10; break; } dc.InsertEvaBook((int)cmbStudent.EditValue, val, cmbBook.Text, txtDate.Text, txtDesc.Text); if (val > 17) { dc.InsertActPoint((int)cmbStudent.EditValue, 2, txtDate.Text, txtDesc.Text); } else if (val <= 17 && val >= 15) { dc.InsertActPoint((int)cmbStudent.EditValue, 1, txtDate.Text, txtDesc.Text); } } else { val = (int)txtScore.Value; dc.InsertEvaBook((int)cmbStudent.EditValue, (int)txtScore.Value, cmbBook.Text, txtDate.Text, txtDesc.Text); if (val > 17) { dc.InsertActPoint((int)cmbStudent.EditValue, 2, txtDate.Text, txtDesc.Text); } else if (val <= 17 && val >= 15) { dc.InsertActPoint((int)cmbStudent.EditValue, 1, txtDate.Text, txtDesc.Text); } } XtraMessageBox.Show("امتیاز موردنظر با موفقیت ثبت شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information); if (isQuastion) { this.Close(); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } }