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

namespace WindowsFormsApplication5
{
    public partial class frmlogin : Form
    {
        public frmlogin()
        {
            InitializeComponent();
        }

        private void btnlogin_Click(object sender, EventArgs e)
        {

            #region validation
            try
            {
                String con = WindowsFormsApplication5.Properties.Settings.Default.libraryConnectionString;
                SqlConnection conn = new SqlConnection(con);
                conn.Open();
                SqlCommand com = new SqlCommand();
                com.Connection = conn;
                com.CommandType = CommandType.Text;
                com.CommandText = "SELECT [roll] FROM [member] WHERE (([lname] = @lname) AND ([code] = @code))";
                com.Parameters.AddWithValue("@lname", txbln.Text);
                com.Parameters.AddWithValue("@code", Convert.ToDecimal(txbcode.Text));


                SqlDataAdapter da = new SqlDataAdapter(com);
                lblstate.Text = (da.SelectCommand.ExecuteScalar()).ToString();
                if (lblstate.Text == "owner")
                {
                    frmmain fm = new frmmain();
                    fm.Show();
                    
                }
                else
                {
                    MessageBox.Show("please enter valid owner information");

                }
            }

            catch (Exception s)
            {
                MessageBox.Show(s.ToString());
            }
            #endregion
        }

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