Exemple #1
0
        public void DANGNHAP()
        {
            string[] result = BUS_Login.Instance.Login(txtID.Text, txtPassword.Text);
            if (string.IsNullOrEmpty(result[1]) || result[1].Contains("Nhân Viên") == true)
            {
                MSBox msb = new MSBox("Error", "ID hoặc Passwork không đúng. Vui lòng kiểm tra lại!", "Đồng ý", MSBox.MSBoxIcon.Error);
                msb.ShowDialog();
            }
            else
            {
                INDEX_User = 0;
                if (chkID.Checked == true && temp.Contains(txtID.Text) == false)
                {
                    string RESULT = BUS_Name_Clone.Instance.Set_UserName(temp, txtID.Text);
                    if (!string.IsNullOrEmpty(RESULT))
                    {
                        MSBox msg = new MSBox("Error", "Không ghi nhớ được tên TK. Vui lòng kiểm tra lại!", "Đồng ý", MSBox.MSBoxIcon.Error);
                        msg.ShowDialog();
                    }
                }

                // input get when you login: index_user, name_position
                if (result[1].Contains("ADMIN") == true)
                {
                    frmMain frmmain = new frmMain();
                    this.Visible = false;
                    frmmain.ShowDialog();

                    this.Visible = true;
                    txtPassword.Clear();
                }
                else
                {
                    INDEX_User = Convert.ToInt32(result[0]);
                    string position = result[1];

                    // update status
                    string error = BUS_Login.Instance.Update_status(INDEX_User, "ONLINE");
                    if (!string.IsNullOrEmpty(error))
                    {
                        MessageBox.Show(error);
                    }
                    else
                    {
                        if (position.Contains("Quản Lý") == true)
                        {
                            frmQuanLyNhanVien frmQL = new frmQuanLyNhanVien();
                            this.Visible = false;
                            frmQL.ShowDialog();

                            this.Visible = true;
                            txtPassword.Clear();
                        }
                        else if (position.Contains("Thu Ngân") == true)
                        {
                            // new form thu ngan
                        }
                        else
                        {
                            // new form thu kho
                        }
                    }
                }
            }
        }