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

namespace BimaryDetect
{
    public partial class frmDarooTypes : Form
    {
        public frmDarooTypes()
        {
            InitializeComponent();
        }

        private void frmDarooTypes_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'bimaryDetectDataSet.DarooTypes' table. You can move, or remove it, as needed.
            this.darooTypesTableAdapter.Fill(this.bimaryDetectDataSet.DarooTypes);
            this.labPos();
        }
        protected void labPos()
        {
            this.label4.Text = this.darooTypesBindingSource.Position + 1 + " از " + this.darooTypesBindingSource.Count;
        }

        private void btmNext_Click(object sender, EventArgs e)
        {
            if (this.darooTypesBindingSource.Position + 1 < this.darooTypesBindingSource.Count)
            {
                this.darooTypesBindingSource.MoveNext();
                this.labPos();
            }
        }

        private void btnLast_Click(object sender, EventArgs e)
        {
            this.darooTypesBindingSource.MoveLast();
            this.labPos();
        }

        private void btnPrevoiuse_Click(object sender, EventArgs e)
        {
            this.darooTypesBindingSource.MovePrevious();
            this.labPos();
        }

        private void btnFirst_Click(object sender, EventArgs e)
        {
            this.darooTypesBindingSource.MoveFirst();
            this.labPos();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            this.darooTypesTableAdapter.Insert(textBox2.Text.Trim());
//            dataGridView1.Refresh();
            this.darooTypesTableAdapter.Fill(this.bimaryDetectDataSet.DarooTypes);
            this.labPos();
            btnInsert.Enabled = false;
            btnNew.Enabled = true;
        }

        private void btnNew_Click(object sender, EventArgs e)
        {
            this.darooTypesBindingSource.AddNew();
            btnInsert.Enabled = true;
            btnNew.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                this.darooTypesTableAdapter.Delete(int.Parse(textBox1.Text.Trim()));
                this.darooTypesTableAdapter.Fill(this.bimaryDetectDataSet.DarooTypes);
                this.labPos();
                MessageBox.Show("نوع دارو حذف شد");
            }
            else
            {
                MessageBox.Show("نوع دارویی انتخاب نشده است");
            }
        }
    }
}