Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("Username dan Password harus diisi !");
                txtUsername.Focus();
            }
            else
            {
                login.setUsername(txtUsername.Text);
                login.setPassword(txtPassword.Text);

                status = impUser.Login(login);

                if (status == false)
                {
                    MessageBox.Show("Login Failed !!");
                    txtUsername.Text = "";
                    txtPassword.Text = "";
                    txtUsername.Focus();
                }
                else
                {
                    MessageBox.Show("Login Success");
                    frmAdmin f = new frmAdmin();
                    f.Show();
                    this.Hide();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inicializa el modulo con el Login y el Splash
        /// </summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            frmSplash frmSplash = new frmSplash();
            frmLogin  frmLogin  = new frmLogin(frmSplash, EnumLoginType.Normal, validateRole: true, role: EnumRole.Manager, changePassword: true);

            frmSplash.Show();
            frmSplash.ShowLogin(ref frmLogin);
            if (frmLogin.IsAuthenticated)
            {
                Context.User = frmLogin.UserData;
                if (Context.User.HasRole(EnumRole.Manager))
                {
                    EventManager.RegisterClassHandler(typeof(AccessText), AccessKeyManager.AccessKeyPressedEvent, new RoutedEventHandler(keyManager_keyPressed));
                    EventManager.RegisterClassHandler(typeof(DataGrid), UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(dataGrid_MouseLeftButtonUp));
                    EventManager.RegisterClassHandler(typeof(ComboBox), UIElement.KeyDownEvent, new KeyEventHandler(cmb_KeyDown));

                    frmAdmin frmMain = new frmAdmin();
                    frmMain.Title = $"{Context.Module} - [{Context.Environment}]";
                    frmMain.ShowDialog();
                    frmSplash.Close();
                }
                else
                {
                    // No tiene permiso para ingresar al modulo
                    UIHelper.ShowMessage("User doesn't have access");
                }
            }
        }
Exemplo n.º 3
0
        private void administratorsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAdmin fr = new frmAdmin();

            fr.MdiParent = this;
            fr.Show();
        }
Exemplo n.º 4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string   name = txtAcc.Text;
            string   pass = txtPass.Text;
            Employee myEm = null;

            foreach (Employee u in myEmployeeList)
            {
                if (u.IdString == name && u.Password == pass)
                {
                    myEm = new Employee(u);
                    break;
                }
            }
            if (myEm == null)
            {
                MessageBox.Show("Tài khoản hoặc mật khẩu không đúng");
                return;
            }

            if (myEm.Status == false)
            {
                MessageBox.Show("Nhân viên này đã không còn làm việc");
                return;
            }

            this.Hide();
            switch (myEm.Permission)
            {
            case ADMIN:
                fAdmin           = new frmAdmin();
                fAdmin.CurEmploy = myEm;
                if (fAdmin.ShowDialog() == DialogResult.Cancel)
                {
                    frmLogin_Load(null, null);
                }
                break;

            case SALE:
                fSale             = new frmSale();
                fSale.CurEmployee = myEm;
                if (fSale.ShowDialog() == DialogResult.Cancel)
                {
                    frmLogin_Load(null, null);
                }
                break;

            case WARE:
                fGood             = new frmGood();
                fGood.CurEmployee = myEm;
                if (fGood.ShowDialog() == DialogResult.Cancel)
                {
                    frmLogin_Load(null, null);
                }
                break;
            }
        }
Exemplo n.º 5
0
 private void btn_Admin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         frmAdmin f = new frmAdmin();
         if (ExistForm(f))
         {
             return;
         }
         f.MdiParent = this;
         f.Show();
     }
     catch { }
 }
Exemplo n.º 6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // ตรวจสอบการป้อนข้อมูล
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("ป้อนข้อมูลให้ครับก่อน", "ผิดพลาด",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // มีการป้อนข้อมูลแล้ว นำ username, password ไปตรวจสอบกับข้อมูลในตาราง
            string connectionString = "server=.\\sqlexpress;database=dbBookShop;integrated security=true";

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                // MessageBox.Show("connect ok");
                // คลาสที่ใช้งานในการ SELECT ข้อมูล sqlDataAdapter, DataTable, คำสั่ง SQL
                //     string sql = "SELECT * FROM tbEmployee WHERE  Username='******' AND Password='******' ";
                string         sql = "SELECT * FROM tbEmployee WHERE Username=@Username AND Password=@Password";
                SqlDataAdapter da  = new SqlDataAdapter(sql, con);
                da.SelectCommand.Parameters.AddWithValue("@Username", txtUsername.Text);
                da.SelectCommand.Parameters.AddWithValue("@Password", txtPassword.Text);
                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count < 1)
                {
                    MessageBox.Show("ไม่พบข้อมูล", "ผิดพลาด",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // กรณีพบข้อมูล ตรวจสอบสถานะผู้ใช้งาน
                if (dt.Rows[0]["PosID"].ToString() == "1")
                {
                    // MessageBox.Show("พนักงานขาย");
                    frmSaleMenu frm = new frmSaleMenu(dt.Rows[0]["EmpName"].ToString(), dt.Rows[0]["EmpID"].ToString());
                    frm.Show();
                    this.Hide();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "2")
                {
                    // MessageBox.Show("พนักงานคลังสินค้า");
                    int      EmpID = int.Parse(dt.Rows[0]["EmpID"].ToString());
                    frmStock frm   = new frmStock(EmpID);
                    frm.Show();
                    this.Hide();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "3")
                {
                    //  MessageBox.Show("ผู้จัดการร้าน");
                    frmManager frm = new frmManager();
                    frm.Show();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "4")
                {
                    /// MessageBox.Show("ผู้ดูแลระบบ");
                    frmAdmin frm = new frmAdmin(dt.Rows[0]["EmpName"].ToString());
                    frm.Show();
                }
            }
        }