コード例 #1
0
        public void ChangeAccount(String anumber)
        {
            var cacount = _model.GetByAccountNumber(anumber);

            while (true)
            {
                Console.WriteLine("---------------Change Information-----------------");
                Console.WriteLine("1, Change username.");
                Console.WriteLine("2, Change password.");
                Console.WriteLine("3, Change identity card.");
                Console.WriteLine("4, Change full name.");
                Console.WriteLine("5, Change email.");
                Console.WriteLine("6, Change phone number.");
                Console.WriteLine("7, Change address.");
                Console.WriteLine("8, Change dob.");
                Console.WriteLine("9, Change gender.");
                Console.WriteLine("10, Lock account");
                Console.WriteLine("11, Exit!");
                Console.WriteLine("--------------------------------------------------");
                Console.WriteLine("Please enter choice: ");
                int choice = Int32.Parse(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    Console.WriteLine("You choice change username.");
                    Console.WriteLine("Please enter username.");
                    string cusername = Console.ReadLine();
                    _model.uAUserName(anumber, cusername);
                    string name1           = cacount.UserName;
                    string contentusername = "******" + name1 + " to " + cusername;
                    _change.InsertChange(anumber, contentusername);
                    Console.WriteLine("Change username success");
                    break;

                case 2:
                    Console.WriteLine("You choice change password.");
                    Console.WriteLine("Please enter password.");
                    string cpassword = Console.ReadLine();
                    _model.uAPassword(anumber, cpassword);
                    string password1       = cacount.Password;
                    string contentpassword = "******" + password1 + " to " + cpassword;
                    _change.InsertChange(anumber, contentpassword);
                    Console.WriteLine("Change password success");
                    break;

                case 3:
                    Console.WriteLine("You choice change identity card.");
                    Console.WriteLine("Please enter identity card.");
                    string cidentitycard = Console.ReadLine();
                    _model.uAIdentityCard(anumber, cidentitycard);
                    string card1       = cacount.IdentityCard;
                    string contentcard = "Change identity card from " + card1 + " to " + cidentitycard;
                    _change.InsertChange(anumber, contentcard);
                    Console.WriteLine("Change identity card success");
                    break;

                case 4:
                    Console.WriteLine("You choice change full name.");
                    Console.WriteLine("Please enter full name.");
                    string cfullname = Console.ReadLine();
                    _model.uAFullName(anumber, cfullname);
                    string fullname1       = cacount.FullName;
                    string contentfullname = "Change full name from " + fullname1 + " to " + cfullname;
                    _change.InsertChange(anumber, contentfullname);
                    Console.WriteLine("Change full name success");
                    break;

                case 5:
                    Console.WriteLine("You choice change email.");
                    Console.WriteLine("Please enter email.");
                    string cemail = Console.ReadLine();
                    _model.uAEmail(anumber, cemail);
                    string email1       = cacount.Email;
                    string contentemail = "Change email from " + email1 + " to " + cemail;
                    _change.InsertChange(anumber, contentemail);
                    Console.WriteLine("Change email success");
                    break;

                case 6:
                    Console.WriteLine("You choice change phone number.");
                    Console.WriteLine("Please enter phone number.");
                    string cphonenumber = Console.ReadLine();
                    _model.uAPhoneNumber(anumber, cphonenumber);
                    string phonenumber        = cacount.PhoneNumber;
                    string contentphonenumber = "Change phone number from " + phonenumber + " to " + cphonenumber;
                    _change.InsertChange(anumber, contentphonenumber);
                    Console.WriteLine("Change phone number success");
                    break;

                case 7:
                    Console.WriteLine("You choice change address.");
                    Console.WriteLine("Please enter address.");
                    string caddress = Console.ReadLine();
                    _model.uAAddress(anumber, caddress);
                    string address1       = cacount.Address;
                    string contentaddress = "Change address from " + address1 + " to " + caddress;
                    _change.InsertChange(anumber, contentaddress);
                    Console.WriteLine("Change address success");
                    break;

                case 8:
                    Console.WriteLine("You choice change dob.");
                    Console.WriteLine("Please enter dob.");
                    string cdob = Console.ReadLine();
                    _model.uADob(anumber, cdob);
                    string dob1       = cacount.Dob;
                    string contentdob = "Change dob from " + dob1 + " to " + cdob;
                    _change.InsertChange(anumber, contentdob);
                    Console.WriteLine("Change dob success");
                    break;

                case 9:
                    Console.WriteLine("You choice change gender.");
                    Console.WriteLine("Please enter gender.");
                    string cgender = Console.ReadLine();
                    _model.uAGender(anumber, cgender);
                    int    gender1       = cacount.Gender;
                    string contentgender = "Change gender from " + gender1 + " to " + cgender;
                    _change.InsertChange(anumber, contentgender);
                    Console.WriteLine("Change gender success");
                    break;

                case 10:
                    Console.WriteLine("You choice Lock account.");
                    _model.AccountLock(anumber);
                    break;

                case 11:
                    Console.WriteLine("Exit! Bye bye");
                    break;

                default:
                    Console.WriteLine("You enter fails. Please enter again!");
                    break;
                }

                if (choice == 10)
                {
                    DbConnection.Instance().CloseConnection();
                    break;
                }
                if (choice == 11)
                {
                    break;
                }
            }
        }