예제 #1
0
        public bool checkLogin(string txtName, string txtPass, studentDataSet dts)
        {
            DataTable dt = new DataTable();

            if (dts.student.Count() > 0)
            {
                dt = dts.Tables["Student"];
                var q = from qds in dt.AsEnumerable()
                        where qds.Field <string>("S_ID").ToString().Trim() == txtName.ToString().Trim() &&
                        qds.Field <string>("S_cardID").ToString().Trim() == txtPass.ToString().Trim()
                        select new
                {
                    userID   = qds.Field <string>("S_ID").ToString(),
                    userpass = qds.Field <string>("S_cardID").ToString()
                };
                if (q.Count() <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: kimkub/Login-C-
        private void button1_Click(object sender, EventArgs e)
        {
            student        c      = new student();
            bool           resLog = false;
            studentDataSet ds     = studentDataSet;

            resLog = c.checkLogin(textBox1.Text, textBox2.Text, ds);
            if (resLog)
            {
                Form2 frm1 = new Form2();
                frm1.ShowDialog();
                frm1.Activate();
                this.Hide();
                this.Close();
            }
            else
            {
                MessageBox.Show("ใส่ข้อมูลผิด");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }
        }