コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            MAIN mn = new MAIN();

            this.Hide();
            mn.ShowDialog();
        }
コード例 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            oUser    = new DataAccess.User();
            oUtility = new CommonFunction.CommonFunction();

            if (oUtility.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oUtility.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login
            {
                this.Hide();
                this.ShowInTaskbar = false;
                ePublicVariable.eVariable.sUsername = txtUsername.Text;
                ePublicVariable.eVariable.sPassword = txtPassword.Text;
                ePublicVariable.eVariable.sFullname = oUtility.Decrypt(oDefUser.FULLNAME);
                ePublicVariable.eVariable.sRole     = oUtility.Decrypt(oDefUser.ROLE);
                oMainForm = new MAIN();
                oMainForm.ShowDialog();
            }

            else
            {
                #region CheckDatabase

                oDatabase = new DataAccess.SystemFunction();

                if (!oDatabase.IsDatabaseExits())
                {
                    oFrmMsgBox             = new frmMessageBox("DATABASE DOES NOT EXISTS. PLEASE RESTORE FIRST THE DATABASE. THANK YOU");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();

                    Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB();
                    oFrm.ShowDialog();
                }

                #endregion


                #region DBLogin
                if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
                {
                    this.ShowInTaskbar = false;
                    this.Hide();
                    ePublicVariable.eVariable.sUsername = txtUsername.Text;
                    ePublicVariable.eVariable.sPassword = txtPassword.Text;
                    oMainForm = new MAIN();
                    oMainForm.ShowDialog();
                }
                else
                {
                    oFrmMsgBox             = new Forms.frmMessageBox("PLEASE ENTER CORRECT USERNAME AND PASSWORD.");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    txtUsername.Focus();
                }
                #endregion
            }
        }
コード例 #3
0
        void login(string username, string password)
        {
            sql     = "SELECT *FROM tbadmin";
            sql_cmd = new MySqlCommand(sql, clsMySQL.sql_con);
            MySqlDataReader rd = sql_cmd.ExecuteReader();

            while (rd.Read())
            {
                usern = rd["username"].ToString();
                pass  = rd["password"].ToString();
            }
            rd.Close();

            if (username == usern && password == pass)
            {
                clsMySQL.userSYS = "Admin";
                MessageBox.Show("You have successfully login", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sql = string.Format("INSERT INTO tblog VALUES (null, '{0}', '{1}','{2}')",
                                    clsMySQL.userSYS, "Login - Admin", DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
                sql_cmd = new MySqlCommand(sql, clsMySQL.sql_con);
                sql_cmd.ExecuteNonQuery();
                MAIN main = new MAIN();
                this.Hide();
                main.ShowDialog();
            }
            else if (username == user1 && password == pass1)
            {
                clsMySQL.userSYS = "User";
                MessageBox.Show("You have successfully login", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sql = string.Format("INSERT INTO tblog VALUES (null, '{0}', '{1}','{2}')",
                                    clsMySQL.userSYS, "Login - User", DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
                sql_cmd = new MySqlCommand(sql, clsMySQL.sql_con);
                sql_cmd.ExecuteNonQuery();
                MAIN main = new MAIN();
                this.Hide();
                main.ShowDialog();
            }
            else
            {
                MessageBox.Show("Incorrect username or password", "Unable to Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Text = "";
            }
        }
コード例 #4
0
        public static void Init_e(string name)
        {
            switch (name)
            {
                case "MAH":
                    try
                    {
                        MAH.TopMost = true;
                        MAH.Show();
                    }
                    catch
                    {
                        MAH = new mahovik {TopMost = true};
                        MAH.Show();
                    }
                    break;
                case "targetCtrl":
                    try
                    {
                        targetCtrl.TopMost = true;
                        targetCtrl.Show();
                    }
                    catch
                    {
                        targetCtrl = new targetControl {TopMost = true};
                        targetCtrl.Show();
                    }
                    break;
                case "OSC":
                    try
                    {
                        OSC.TopMost = true;
                        OSC.Show();
                    }
                    catch
                    {
                        OSC = new Oscilloscope(@"graph\clean.txt") {TopMost = true};
                        OSC.Show();
                    }
                    break;
                case "vi001":
                    try
                    {
                        vi001.ShowDialog();
                    }
                    catch
                    {
                        vi001 = new vi001 {Name = "vi001", Text = "ВИ-001"};
                        vi001.ShowDialog();
                    }
                    break;

                case "uvch":
                    try
                    {
                        uvch.ShowDialog();
                    }
                    catch
                    {
                        uvch = new uvch {Name = "uvch", Text = "Блок УВЧ"};
                        uvch.ShowDialog();
                    }
                    break;

                case "vi002":
                    try
                    {
                        vi002.ShowDialog();
                    }
                    catch
                    {
                        vi002 = new vi001 {Name = "vi002", Text = "ВИ-002"};
                        vi002.ShowDialog();
                    }
                    break;
                case "bk008":
                    try
                    {
                        bk008.ShowDialog();
                    }
                    catch
                    {
                        bk008 = new bk008 {Name = "bk008", Text = "БК-008"};
                        bk008.ShowDialog();
                    }
                    break;
                case "hlp":
                    try
                    {
                        if (hlp.helpEnabled())
                            hlp.Show();
                    }
                    catch
                    {
                        hlp = new helper();
                    }
                    break;

                case "MAIN1":
                    try
                    {
                        MAIN1.ShowDialog();
                    }
                    catch
                    {
                        MAIN1 = new MAIN();
                        MAIN1.ShowDialog();
                    }
                    break;
                case "bv012":
                    try
                    {
                        bv012.ShowDialog();
                    }
                    catch
                    {
                        bv012 = new bv012();
                        bv012.ShowDialog();
                    }
                    break;
                case "bsh0031":
                    try
                    {
                        bsh03.ShowDialog();
                    }
                    catch
                    {
                        bsh03 = new bsh003();
                        bsh03.ShowDialog();
                    }
                    break;

                case "bp103":
                    try
                    {
                        bp13.ShowDialog();
                    }
                    catch
                    {
                        bp13 = new bp103();
                        bp13.ShowDialog();
                    }
                    break;
                case "bp1162":
                    try
                    {
                        bp62.ShowDialog();
                    }
                    catch
                    {
                        bp62 = new bp116();
                        bp62.ShowDialog();
                    }
                    break;
                case "bp1161":
                    try
                    {
                        bp61.ShowDialog();
                    }
                    catch
                    {
                        bp61 = new bp116();
                        bp61.ShowDialog();
                    }
                    break;
                case "bg0022":
                    try
                    {
                        bg22.ShowDialog();
                    }
                    catch
                    {
                        bg22 = new bg002();
                        bg22.ShowDialog();
                    }
                    break;
                case "bg0021":
                    try
                    {
                        bg21.ShowDialog();
                    }
                    catch
                    {
                        bg21 = new bg002();
                        bg21.ShowDialog();
                    }
                    break;
                case "bg0032":
                    try
                    {
                        bg32.ShowDialog();
                    }
                    catch
                    {
                        bg32 = new bg003();
                        bg32.ShowDialog();
                    }
                    break;
                case "bg0031":
                    try
                    {
                        bg31.ShowDialog();
                    }
                    catch
                    {
                        bg31 = new bg003();
                        bg31.ShowDialog();
                    }
                    break;
                case "bg0052":
                    try
                    {
                        bg52.ShowDialog();
                    }
                    catch
                    {
                        bg52 = new bg005();
                        bg52.ShowDialog();
                    }
                    break;
                case "bg0051":
                    try
                    {
                        bg51.ShowDialog();
                    }
                    catch
                    {
                        bg51 = new bg005();
                        bg51.ShowDialog();
                    }
                    break;

                case "bv0041":
                    try
                    {
                        bv41.ShowDialog();
                    }
                    catch
                    {
                        bv41 = new bv004(1);
                        bv41.ShowDialog();
                    }
                    break;
                case "bv0042":
                    try
                    {
                        bv42.ShowDialog();
                    }
                    catch
                    {
                        bv42 = new bv004(2);
                        bv42.ShowDialog();
                    }
                    break;

                case "bm0051":
                    try
                    {
                        bm51.ShowDialog();
                    }
                    catch
                    {
                        bm51 = new bm005();
                        bm51.ShowDialog();
                    }
                    break;
                case "bm0061":
                    try
                    {
                        bm61.ShowDialog();
                    }
                    catch
                    {
                        bm61 = new bm005();
                        bm61.ShowDialog();
                    }
                    break;
                case "bg0042":
                    try
                    {
                        bg0042.ShowDialog();
                    }
                    catch
                    {
                        bg0042 = new bg004();
                        bg0042.ShowDialog();
                    }
                    break;
                case "bg0041":
                    try
                    {
                        bg0041.ShowDialog();
                    }
                    catch
                    {
                        bg0041 = new bg004();
                        bg0041.ShowDialog();
                    }
                    break;
                case "bg0012":
                    try
                    {
                        bg0012.ShowDialog();
                    }
                    catch
                    {
                        bg0012 = new bg001();
                        bg0012.ShowDialog();
                    }
                    break;
                case "bg0011":
                    try
                    {
                        bg0011.ShowDialog();
                    }
                    catch
                    {
                        bg0011 = new bg001();
                        bg0011.ShowDialog();
                    }
                    break;
                case "br0072":
                    try
                    {
                        br72.ShowDialog();
                    }
                    catch
                    {
                        br72 = new br007();
                        br72.ShowDialog();
                    }
                    break;
                case "br0071":
                    try
                    {
                        br71.ShowDialog();
                    }
                    catch
                    {
                        br71 = new br007();
                        br71.ShowDialog();
                    }
                    break;
                case "bv0092":
                    try
                    {
                        bv9kit2.ShowDialog();
                    }
                    catch
                    {
                        bv9kit2 = new bv009();
                        bv9kit2.ShowDialog();
                    }
                    break;
                case "bv0091":
                    try
                    {
                        bv9kit1.ShowDialog();
                    }
                    catch
                    {
                        bv9kit1 = new bv009();
                        bv9kit1.ShowDialog();
                    }
                    break;
                case "bv41":
                    try
                    {
                        bv41.ShowDialog();
                    }
                    catch
                    {
                        bv41 = new bv004(1);
                        bv41.ShowDialog();
                    }
                    break;
                case "bv010":
                    try
                    {
                        bv10.ShowDialog();
                    }
                    catch
                    {
                        bv10 = new bv010();
                        bv10.ShowDialog();
                    }
                    break;
                case "bk8":
                    try
                    {
                        bk8.ShowDialog();
                    }
                    catch
                    {
                        bk8 = new bk008();
                        bk8.ShowDialog();
                    }
                    break;
                case "bv002":
                    try
                    {
                        bv2dal.Name = "bv002";
                        bv2dal.ShowDialog();
                    }
                    catch
                    {
                        bv2dal = new bv001 {Name = "bv002"};
                        bv2dal.ShowDialog();
                    }
                    break;
                case "bv001":

                    try
                    {
                        bv1.Name = "bv001";
                        bv1.ShowDialog();
                    }
                    catch
                    {
                        bv1 = new bv001 {Name = "bv001"};
                        bv1.ShowDialog();
                    }
                    break;
                case "bya1":
                    try
                    {
                        bya1.ShowDialog();
                    }
                    catch
                    {
                        bya1 = new bya001();
                        bya1.ShowDialog();
                    }
                    break;
                case "br0042":
                    try
                    {
                        br42.ShowDialog();
                    }
                    catch
                    {
                        br42 = new br004(2);
                        br42.ShowDialog();
                    }
                    break;
                case "br0041":
                    try
                    {
                        br41.ShowDialog();
                    }
                    catch
                    {
                        br41 = new br004(1);
                        br41.ShowDialog();
                    }
                    break;
                case "bsh0011":
                    try
                    {
                        BSH001.ShowDialog();
                    }
                    catch
                    {
                        BSH001 = new bsh001();
                        BSH001.ShowDialog();
                    }
                    break;
                case "bsh0021":
                    try
                    {
                        BSH002.ShowDialog();
                    }
                    catch
                    {
                        BSH002 = new bsh002();
                        BSH002.ShowDialog();
                    }
                    break;
                case "bk0061":
                    try
                    {
                        bk0061.ShowDialog();
                    }
                    catch
                    {
                        bk0061 = new bk006();
                        bk0061.ShowDialog();
                    }
                    break;
                case "bk0071":
                    try
                    {
                        BK007.ShowDialog();
                    }
                    catch
                    {
                        BK007 = new bk007();
                        BK007.ShowDialog();
                    }
                    break;
                case "bt006":
                    try
                    {
                        BT006.ShowDialog();
                    }
                    catch
                    {
                        BT006 = new bt006();
                        BT006.ShowDialog();
                    }
                    break;
                case "bk005":
                    try
                    {
                        BK005.ShowDialog();
                    }
                    catch
                    {
                        BK005 = new bk005();
                        BK005.ShowDialog();
                    }
                    break;
                case "shp001":
                    try
                    {
                        shp1.ShowDialog();
                    }
                    catch
                    {
                        shp1 = new shp001();
                        shp1.ShowDialog();
                    }
                    break;
                case "bp119":
                    try
                    {
                        bp19.ShowDialog();
                    }
                    catch
                    {
                        bp19 = new bp119();
                        bp19.ShowDialog();
                    }
                    break;
                case "br0031":
                    try
                    {
                        br0031.Name = "br31";
                        br0031.ShowDialog();
                    }
                    catch
                    {
                        br0031 = new br003 {Name = "br31"};
                        br0031.ShowDialog();
                    }
                    break;
                case "br0032":
                    try
                    {
                        br0031.Name = "br32";
                        br0032.ShowDialog();
                    }
                    catch
                    {
                        br0032 = new br003 {Name = "br32"};
                        br0032.ShowDialog();
                    }
                    break;
                case "IKO":
                    try
                    {
                        IKO.ShowDialog();
                    }
                    catch
                    {
                        IKO = new IKO();
                        IKO.ShowDialog();
                    }
                    break;
                case "shp002":
                    try
                    {
                        shp2.ShowDialog();
                    }
                    catch
                    {
                        shp2 = new shp002();
                        shp2.ShowDialog();
                    }
                    break;
                case "tuts":
                    try
                    {
                        tuts1.ShowDialog();
                    }
                    catch
                    {
                        tuts1 = new tuts();
                        tuts1.ShowDialog();
                    }
                    break;
                case "tuts2":
                    try
                    {
                        bya1.Show();
                        tuts1.Show();
                    }
                    catch
                    {
                        tuts1 = new tuts();
                        bya1 = new bya001();
                        bya1.Show();
                        tuts1.Show();
                    }
                    break;
            }
        }
コード例 #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            oUser           = new DataAccess.User();
            oCommonFunction = new CommonFunction.CommonFunction();

            if (oCommonFunction.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oCommonFunction.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login
            {
                this.ShowInTaskbar = false;
                this.Hide();
                oMainForm = new MAIN(txtUsername.Text, txtPassword.Text, oCommonFunction.Decrypt(oDefUser.FULLNAME), oCommonFunction.Decrypt(oDefUser.ROLE));
                oMainForm.ShowDialog();
                return;
            }

            else
            {
                #region CheckDatabase

                oDatabase = new DataAccess.BackupRestoreDB();

                if (!oDatabase.IsDatabaseExits())
                {
                    oFrmMsgBox = new frmMessageBox(ePublicVariable.eVariable.TransactionMessage.THE_DATABASE_DOES_NOT_EXITS.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();

                    Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB();
                    oFrm.ShowDialog();
                }

                #endregion


                #region DBLogin

                if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
                {
                    foreach (DataRow row in oUser.GetUser("username", txtUsername.Text).Rows)
                    {
                        oMUser            = new Model.User();
                        oMUser.USERNAME   = row[0].ToString();
                        oMUser.FULLNAME   = row[1].ToString();
                        oMUser.PASSWORD   = row[2].ToString();
                        oMUser.ROLE       = row[3].ToString();
                        oMUser.CONTACT_NO = row[4].ToString();
                        oMUser.ADDRESS    = row[5].ToString();
                    }

                    this.ShowInTaskbar = false;
                    this.Hide();
                    oMainForm = new MAIN(oMUser);
                    oMainForm.ShowDialog();
                    return;
                }
                else
                {
                    lblNotification.Text = "THE USERNAME AND PASSWORD YOU HAVE ENTERED ARE INCORRECT";
                    txtUsername.Focus();
                }
                #endregion
            }
        }