コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String usrname = usrnameTxt.Text, pswd = pswdTxt.Text;

            if (usrname == "" || pswd == "")
            {
                msgerr("Rellene todos los campos!");
                return;
            }
            try
            {
                string ans = Clogin.log_in(usrname, pswd);
                if (ans.Equals("GRANTED"))
                {
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show(this, "Bienvenido!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    msgerr("Usuario o Contraseña Incorrecta");
                }
            }
            catch (Exception ex)
            {
                msgerr(ex.Message);
            }
        }
コード例 #2
0
        public Clogin login(Clogin c)
        {
            var r = db.emps.Where(s => s.username == c.username && s.password == c.password).FirstOrDefault();

            if (r == null)
            {
                return(null);
            }
            Clogin l = new Clogin();

            l.id       = r.id;
            l.username = r.username;
            l.password = r.password;
            l.name     = r.name;
            l.contact  = r.contact;

            return(l);
        }