Пример #1
0
        private void btn_Demo_Click(object sender, EventArgs e)
        {
            Hide();
            frm_Main Main = new frm_Main();

            Main.combo_Users.SelectedValue = 1;
            Main.Demo = true;
            Main.Show();
        }
Пример #2
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                try
                {
                    var user = new User();
                    user.UserName = txtUsername.Text;
                    user.Password = txtPassword.Text;

                    var record = UserDataAccess.findByUserId(user);

                    if (record == null)
                    {
                        MessageBox.Show("User-ID not found.Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        // check if user profile is inactive
                        if (record.IsRemoved == true)
                        {
                            MessageBox.Show("Inactive user profile", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            // check for the password
                            if (record.Password == txtPassword.Text)
                            {
                                // show home form
                                var role     = record.Role;
                                var userName = record.UserName;

                                var main = new frm_Main(userName, role);
                                main.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("Incorrect password.Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Server   = textBox_Server.Text;
            Properties.Settings.Default.DataBase = textBox_DataBase.Text;
            Properties.Settings.Default.Mode     = radio_Windows.Checked == true ? "Windows" : "SQL";
            Properties.Settings.Default.ID       = textBox_ID.Text;
            Properties.Settings.Default.Password = textBox_Password.Text;

            frm_Main Main = new frm_Main();

            Properties.Settings.Default.Save();
            Main.Show();
            Hide();
        }
Пример #4
0
        private void btn_Run_Click(object sender, EventArgs e)
        {
            if (txt_Run.Text.Length != 6)
            {
                return;
            }

            int q = (Convert.ToInt32(txt_Authorization.Text.Substring(1, 1)) * 5);
            int w = (Convert.ToInt32(txt_Authorization.Text.Substring(2, 1)) * 4);
            int t = (Convert.ToInt32(txt_Authorization.Text.Substring(3, 1)) * 8);
            int r = (Convert.ToInt32(txt_Authorization.Text.Substring(4, 1)) * 6);


            string txt     = txt_Run.Text.Substring(0, 4);
            int    AddDays = Convert.ToInt32(txt_Run.Text.Substring(4, 2));
            string run     = q.ToString().Substring(0, 1) + w.ToString().Substring(0, 1) + t.ToString().Substring(0, 1) + r.ToString().Substring(0, 1);

            if (AddDays == 38)
            {
                AddDays = 3650;
            }
            else if (AddDays > 70)
            {
                AddDays = 70;
            }

            if (txt == run)
            {
                string i = Encrypt(id);
                //File.WriteAllText(path,i);
                Properties.Settings.Default.ID        = i;
                Properties.Settings.Default.d         = Encrypt(ExpireDate(AddDays));
                Properties.Settings.Default.LoginUser = "******";
                Properties.Settings.Default.Save();

                Hide();
                frm_Main Main = new frm_Main();
                Main.Show();
            }
            else
            {
                Application.Exit();
            }
        }
Пример #5
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            BL.BL.Users users = new BL.BL.Users();

            users.Name     = txt_Name.Text;
            users.Password = txt_Password.Text;

            DataTable dt = new DataTable();

            dt = users.Select();

            foreach (DataRow r in dt.Rows)
            {
                if ((r["Email"].ToString() == users.Name || r["Mobile"].ToString() == txt_Name.Text.Trim()) && r["Password"].ToString() == users.Password)
                {
                    Hide();
                    string c = CheckAth();
                    if (c == "OK")
                    {
                        frm_Main Main = new frm_Main();
                        UserID = Convert.ToInt32(r["ID"]);
                        Main.combo_Users.SelectedValue = UserID;
                        Main.Show();
                        Properties.Settings.Default.LoginUser = txt_Name.Text;
                        Properties.Settings.Default.Save();
                        return;
                    }
                    else
                    {
                        frm_PreventNo p = new frm_PreventNo();
                        p.UserID = Convert.ToInt16(r["ID"]);
                        p.Case   = c;
                        p.ShowDialog();
                        return;
                    }
                }
            }
            MessageBox.Show("أسم المستخدم أو كلمة المرور غير صحيحة", "خطأ في بيانات الدخول", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
        private void bt_dangnhap_Click(object sender, EventArgs e)
        {
            DataTable dt = dangNhapModel.check_TaiKhoan(txtTenDangNhap.Text,txtMatKhau.Text);

            try
            {
                if (txtTenDangNhap.Text == "")
                {
                    MessageBox.Show("Tài khoản chưa được nhập");
                    txtTenDangNhap.Focus();
                }
                else if (txtMatKhau.Text == "")
                {
                    MessageBox.Show("Mật khẩu chưa được nhập");
                    txtMatKhau.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() != dt.Rows[0][0].ToString() && txtMatKhau.Text == dt.Rows[0][1].ToString())
                {
                    MessageBox.Show("Tên đăng nhập không đúng");
                    txtTenDangNhap.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() == dt.Rows[0][0].ToString() && txtMatKhau.Text != dt.Rows[0][1].ToString())
                {
                    MessageBox.Show("Mật khẩu không đúng");
                    txtMatKhau.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() == dt.Rows[0][0].ToString() && txtMatKhau.Text == dt.Rows[0][1].ToString())
                {
                    frm_Main main = new frm_Main();
                    main.Show();
                    this.Hide();
                }
            }
            catch
            {
                MessageBox.Show("Tên đăng nhập và Mật khẩu không đúng");
            }
        }
Пример #7
0
        private void bntdangnhap_Click(object sender, EventArgs e)
        {
            SqlParameter para1   = new SqlParameter("@taikhoan", txtuser.Text);
            SqlParameter para2   = new SqlParameter("@matkhau", txtpass.Text);
            DataTable    dulieu  = dt.sqlLayDuLieu("PSP_NhanVien_test", para1, para2);
            SqlParameter para3   = new SqlParameter("@TaiKhoan", txtuser.Text);
            DataTable    dulieu1 = dt.sqlLayDuLieu("PSP_NhanVien_Loai", para3);



            if (dulieu.Rows.Count < 1)
            {
                MessageBox.Show("Tài khoản không đúng !");
            }
            else
            {
                quyen = dulieu1.Rows[0]["LoaiTK"].ToString();
                tk    = txtuser.Text;
                frm_Main frm = new frm_Main();
                frm.Show();
                this.Hide();
            }
        }
Пример #8
0
 private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.Hide();
     MainFrm.Show();
 }
Пример #9
0
        private void btn_Demo_Click_1(object sender, EventArgs e)
        {
            frm_Main Main = new frm_Main();

            Main.Show();
        }