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

namespace LibraryMembers
{
    public partial class frmLaghveoviiat : Form
    {
        public void dbConnection()
        {
            clsGrideview dbCon1 = new clsGrideview();
            dataGridView1.DataSource = dbCon1.dbConnection(@"SELECT dbo.MemberList1.* FROM dbo.MemberList1");

        }

        public void dbConnection2()
        {
            clsForCombo cmbP = new clsForCombo();
            comboBox1.DataSource = cmbP.dbConnection2(@"SELECT StateID, MemberState FROM dbo.MemberState");
            comboBox1.ValueMember = "StateID";
            comboBox1.DisplayMember = "MemberState";
        }

        public void uPdatesConnection()
        {
            clsUpdate dbUpdate = new clsUpdate();
            dbUpdate.updateSql(@"update Members set memberState=" + " '" + comboBox1.SelectedValue + "' " + "where MemBerID=" + " '" + textBox1.Text + "'  ");
            dbConnection();
        }

        public frmLaghveoviiat()
        {
            InitializeComponent();
        }

        private void frmLaghveoviiat_Load(object sender, EventArgs e)
        {
            dbConnection();
            dbConnection2();
        }

        private void btnCancelmem_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("تمامی فیلدها بایستی دارای مقدار باشند");
            }
            else
            {
                uPdatesConnection();
                dbConnection();
                dbConnection2();

            }

        }
    }
}