using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EX2
{
    public partial class frmSearch : Form
    {
        public frmSearch()
        {
            InitializeComponent();
            studentBindingSource.SuspendBinding();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmSearch_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'studentDataSet.Student' table. You can move, or remove it, as needed.
            this.studentTableAdapter.Fill(this.studentDataSet.Student);

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            int find = studentBindingSource.Find("code", txtSearchCode.Text.Trim());
            if (find >= 0)
            {
                studentBindingSource.ResumeBinding();
                studentBindingSource.Position = find;

                txtAverage.Text = Convert.ToString((float.Parse(txtCourseScore1.Text.Trim()) + float.Parse(txtCourseScore2.Text.Trim()) + float.Parse(txtCourseScore3.Text.Trim()))/3);
            }
            else
            {
                studentBindingSource.SuspendBinding();
                txtAverage.Text = "";
                MessageBox.Show("دانش آموز موزد نظر یافت نشد ", "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}
