Exemple #1
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var txt = (sender as Button).Name;
                switch (txt)
                {
                case "okLogin":
                    var bSuc = AccountCtlMain.Verification(xLoginNo, txtBoxLoginPwd1.Password);
                    if (!bSuc)
                    {
                        MessageBox.Show("密码错误");
                        return;
                    }
                    MainWindow mainWindow = new MainWindow();
                    App.Current.MainWindow = mainWindow;
                    this.Close();
                    //显示主窗体
                    mainWindow.Show();
                    break;

                case "closeLogin":
                case "cancelLogin":
                    Close();
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #2
0
 static int usrAdd(string[] args)
 {
     if (ContainsOpt(args, "-f"))
     {
         var no    = GetParm(args, 1);
         var name  = GetParm(args, 2);
         var apwd1 = GetParm(args, 3);
         var apwd2 = GetParm(args, 4);
         if (apwd1 != apwd2)
         {
             logger().Error("Two times input password mismatch.");
             return(0);
         }
         AccountCtlMain.AddUser(no, name, apwd1);
     }
     else
     {
         var no   = GetParm(args, 1);
         var name = GetParm(args, 2);
         Console.Write("Please input user's password : "******"Confirm password : "******"Two times input password mismatch.");
             return(0);
         }
         AccountCtlMain.AddUser(no, name, apwd1);
     }
     return(0);
 }
Exemple #3
0
        static void Main()
        {
            //ConsoleHelper.hideConsole();
            var baseAddress = ConfigurationManager.AppSettings["server_url"];

            Console.WriteLine("Startup:" + baseAddress);
            // Start OWIN host
            using (WebApp.Start <Startup>(url: baseAddress))
            {
                Console.WriteLine("Finance is running...");
                while (true)
                {
                    Console.Write("$ ");
                    string commond = Console.ReadLine();
                    if (!string.IsNullOrEmpty(commond))
                    {
                        switch (commond)
                        {
                        case "init":
                            AccountCtlMain.Init();
                            break;

                        case "clear":
                            Console.Clear();
                            break;

                        case "exit":
                            return;
                        }
                    }
                }
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            try
            {
                var defaultConnectionString = ConfigHelper.XmlReadConnectionString("Finance.exe.config", "default");
                DBHelper.DefaultInstance = new DBHelper(defaultConnectionString);
                Console.Write("login as : ");
                string userName = Console.ReadLine();
LOGIN_FLAG:
                Console.Write("password : "******"Incorrect user name or password.");
                    goto LOGIN_FLAG;
                }
                Console.WriteLine("Welcome to use finance.");

                while (true)
                {
                    Console.Write("$ ");
                    string commond = Console.ReadLine();
                    if (!string.IsNullOrEmpty(commond))
                    {
                        int returnCode = CommondHandler.Process(commond);
                        switch (returnCode)
                        {
                        case -1:
                            Console.WriteLine("Commond handler return code:" + returnCode + ", exit this process.");
                            return;

                        case 1:
                            Console.Clear();
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #5
0
        static int usrPwd(string[] args)
        {
            if (ContainsOpt(args, "-f"))
            {
                var userName = GetParm(args, 1);
                var pwd1     = GetParm(args, 2);
                var pwd2     = GetParm(args, 3);
                if (pwd1 != pwd2)
                {
                    logger().Error("Two times input password mismatch.");
                    return(0);
                }
                AccountCtlMain.ChagePwd(userName, pwd1);
            }
            else
            {
                var userName = GetParm(args, 1);
                Console.Write("Please input user's old password : "******"Please input user's new password : "******"Confirm new password : "******"Two times input password mismatch.");
                        return(0);
                    }
                    AccountCtlMain.ChagePwd(userName, pwd1);
                }
                else
                {
                    Console.WriteLine("Incorrect user name or password.");
                }
            }

            return(0);
        }
Exemple #6
0
        static int Exec(string cmd, string[] args)
        {
            switch (cmd)
            {
            case "init":
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var sure = Console.ReadLine();
                if (sure == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.Init();
                }
                break;

            case "act.print":
                AccountCtlMain.AccoutPrint();
                break;

            case "act.create":
                AccountCtlMain.CreateAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.load":
                AccountCtlMain.LoadAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.unload":
                var parm1 = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes = Console.ReadLine();
                if (yes == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.UnloadAccount(parm1);
                }
                break;

            case "act.init":
                var parm2 = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes1 = Console.ReadLine();
                if (yes1 == "yes" || ContainsOpt(args, "-f"))
                {
                    if (ContainsOpt(args, "-k"))
                    {
                        AccountCtlMain.InitAccount(parm2, "-k");
                    }
                    else
                    {
                        AccountCtlMain.InitAccount(parm2);
                    }
                }
                break;

            case "usr.pwd":
                usrPwd(args);
                break;

            case "usr.add":
                usrAdd(args);
                break;

            case "usr.delete":
                var duserName = GetParm(args, 1);
                logger().Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes2 = Console.ReadLine();
                if (yes2 == "yes" || ContainsOpt(args, "-f"))
                {
                    AccountCtlMain.DeleteUser(duserName);
                }
                break;

            case "usr.print":
                AccountCtlMain.UserPrint();
                break;

            default:
                logger().Debug(string.Format("Don't has this command [{0}].", cmd));
                throw new FinanceException(FinanceResult.IMPERFECT_DATA);
            }
            logger().Warn("执行成功.");
            return(0);
        }
Exemple #7
0
 public static int Test()
 {
     return(AccountCtlMain.Test());
 }
Exemple #8
0
        static int Exec(string cmd, string[] args)
        {
            switch (cmd)
            {
            case "init":
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var sure = Console.ReadLine();
                if (sure == "yes")
                {
                    AccountCtlMain.Init();
                }
                break;

            case "act.print":
                AccountCtlMain.AccoutPrint();
                break;

            case "act.create":
                AccountCtlMain.CreateAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.load":
                AccountCtlMain.LoadAccount(GetParm(args, 1), GetParm(args, 2));
                break;

            case "act.unload":
                var parm1 = GetParm(args, 1);
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes = Console.ReadLine();
                if (yes == "yes")
                {
                    AccountCtlMain.UnloadAccount(parm1);
                }
                break;

            case "act.init":
                var parm2 = GetParm(args, 1);
                logger.Warn("This is a dangerous command. Are you sure you want to execute it?(yes/no)");
                var yes1 = Console.ReadLine();
                if (yes1 == "yes")
                {
                    if (args.Count() > 2)
                    {
                        AccountCtlMain.InitAccount(parm2, GetParm(args, 2));
                    }
                    else
                    {
                        AccountCtlMain.InitAccount(parm2);
                    }
                }
                break;

            case "usr.pwd":
                var userName = GetParm(args, 1);
                Console.Write("Please input user's old password : "******"Please input user's new password : "******"Confirm new password : "******"Two times input password mismatch.");
                        return(0);
                    }
                    AccountCtlMain.ChagePwd(userName, pwd1);
                }
                else
                {
                    Console.WriteLine("Incorrect user name or password.");
                }
                break;

            case "usr.add":
                var no   = GetParm(args, 1);
                var name = GetParm(args, 2);
                Console.Write("Please input user's password : "******"Confirm password : "******"Two times input password mismatch.");
                    return(0);
                }
                AccountCtlMain.AddUser(no, name, apwd1);
                break;

            case "usr.delete":
                var duserName = GetParm(args, 1);
                Console.Write("Please input user's password : "******"Incorrect user name or password.");
                }
                break;

            case "usr.print":
                AccountCtlMain.UserPrint();
                break;

            default:
                logger.Debug(string.Format("Don't has this command [{0}].", cmd));
                throw new FinanceException(FinanceResult.IMPERFECT_DATA);
            }
            logger.Info("execute success.");
            return(0);
        }