Пример #1
0
 private void submitLogin()
 {
     using (snEntities db = DBX.DataSet())
     {
         users user = db.users.Where(u => u.username.Trim() == this.txtUser.Text.Trim() && u.userpassword.Trim() == this.txtPassword.Text.Trim()).FirstOrDefault();
         if (user != null)
         {
             if (user.level == (int)USER_LEVEL.ADMIN)
             {
                 this.loged_in_user = user;
                 this.DialogResult  = DialogResult.OK;
                 this.Close();
             }
             else
             {
                 mac_allowed mac = db.mac_allowed.Where(m => m.mac_address.Trim() == this.main_form.my_mac.Trim()).FirstOrDefault();
                 if (mac != null)
                 {
                     this.loged_in_user = user;
                     this.DialogResult  = DialogResult.OK;
                     this.Close();
                 }
                 else
                 {
                     MessageAlert.Show("เครื่องของท่านไม่ได้รับอนุญาตให้เข้าระบบ", "Error", MessageAlertButtons.OK, MessageAlertIcons.STOP);
                     return;
                 }
             }
         }
         else
         {
             MessageAlert.Show("รหัสผู้ใช้/รหัสผ่าน ไม่ถูกต้อง", "Error", MessageAlertButtons.OK, MessageAlertIcons.STOP);
         }
     }
 }
Пример #2
0
        private void IstabListDialog_Load(object sender, EventArgs e)
        {
            this.SetBounds(this.point_to_screen.X, this.point_to_screen.Y, this.Width, this.Height);
            this.bs             = new BindingSource();
            this.bs.DataSource  = this.istabs;
            this.dgv.DataSource = this.bs;

            using (snEntities db = DBX.DataSet())
            {
                this.istabs = db.istab.Where(i => i.tabtyp == this.tabtyp).ToList().ToViewModel();
                this.bs.ResetBindings(true);
                this.bs.DataSource = this.istabs;
            }

            istabVM istab = this.istabs.Where(i => i.typcod == this.initial_typcod).FirstOrDefault();

            if (istab != null)
            {
                this.dgv.Rows.Cast <DataGridViewRow>().Where(r => (string)r.Cells["col_typcod"].Value == this.initial_typcod).First().Cells["col_typcod"].Selected = true;
            }
        }