コード例 #1
0
ファイル: callLogsFrm.cs プロジェクト: dotlenter/KeanGab
        private void closePb_Click(object sender, EventArgs e)
        {
            selectionFrm newFrm = new selectionFrm();

            newFrm.passID = usrID;
            newFrm.Show();
            this.Dispose(false);
            garCol.FlushMemory();
        }
コード例 #2
0
        private void btLogin_Click(object sender, EventArgs e)
        {
            string EncryptF1 = "";
            string EncryptF2 = "";

            #region $Ciph
            char[] Shift1 = new char[26] {
                'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
            };

            string PlaintText = passwordTxt.Text.ToUpper();

            for (int c = 0; c < PlaintText.Length; c++)
            {
                char check_Alph = PlaintText[c];

                for (int s = 0; s < Shift1.Length; s++)
                {
                    if (check_Alph == Shift1[s])
                    {
                        int letCount = 0;
                        letCount = s + Shifts;

                        if (letCount > 25)
                        {
                            int letCiph = letCount - Shift1.Length;

                            EncryptF1 += Shift1[letCiph].ToString();
                        }
                        else
                        {
                            EncryptF1 += Shift1[letCount].ToString();
                        }
                    }
                }
            }
            PlaintText = EncryptF1;

            for (int c = 0; c < PlaintText.Length; c++)
            {
                char check_Alph = PlaintText[c];

                for (int s = 0; s < Shift1.Length; s++)
                {
                    if (check_Alph == Shift1[s])
                    {
                        int letCount = 0;
                        letCount = s + Freq2;

                        if (letCount > 25)
                        {
                            int letCiph = letCount - Shift1.Length;

                            EncryptF2 += Shift1[letCiph].ToString();
                        }
                        else
                        {
                            EncryptF2 += Shift1[letCount].ToString();
                        }
                    }
                }
            }

            #endregion

            using (dbconn_main = dbpath.getdbConnection())
            {
                try { dbconn_main.Open(); }
                catch { OnInformation.ShowDialog(); garCol.FlushMemory(); db_handShake = 0; }

                if (db_handShake == 1)
                {
                    using (commnd = new SqlCommand("SELECT usrnme FROM tbUser WHERE usrnme = @username", dbconn_main))
                    {
                        commnd.Parameters.AddWithValue("@username", usernameTxt.Text);
                        dataReader = commnd.ExecuteReader();
                        int userAlive = 0;
                        while (dataReader.Read())
                        {
                            userAlive++;
                        }
                        dataReader.Close();
                        if (userAlive > 0)
                        {
                            int    userAuth  = 0;
                            int    id        = 0;
                            string userType  = "";
                            string logStatus = "";
                            using (commnd = new SqlCommand("SELECT * FROM tbUser WHERE usrnme = @username AND paswrd = @password", dbconn_main))
                            {
                                commnd.Parameters.AddWithValue("@username", usernameTxt.Text);
                                commnd.Parameters.AddWithValue("@password", EncryptF2);
                                dataReader = commnd.ExecuteReader();
                                while (dataReader.Read())
                                {
                                    id        = dataReader.GetInt32(0);
                                    userType  = dataReader[3].ToString();
                                    logStatus = dataReader[4].ToString();
                                    userAuth++;
                                }
                                dataReader.Close();
                                if (userAuth > 0)
                                {
                                    if (logStatus.ToLower() == "off")
                                    {
                                        Forms.selectionFrm menuFrm = new Forms.selectionFrm();
                                        menuFrm.passID = id;
                                        menuFrm.Show();
                                        userAuth = 0;
                                        this.Hide();
                                        garCol.FlushMemory();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Online!");
                                    }
                                }
                                else
                                {
                                    OnWrngAcct.Exlamation_lbl.Text = "Invalid Password!";
                                }
                            }
                        }
                        else
                        {
                            OnWrngAcct.Exlamation_lbl.Text = "Account not found!";
                            OnWrngAcct.ShowDialog();
                            garCol.FlushMemory();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Online!");
                }
            }
        }