コード例 #1
0
 public void DeleteTheTu(int maTheTu)
 {
     try
     {
         TheTu theTu = context.TheTus.Where(x => x.MaTheTu == maTheTu).Single <TheTu>();
         context.TheTus.Remove(theTu);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #2
0
        public int AddTheTu(TheTu theTu)
        {
            try
            {
                context.TheTus.Add(theTu);
                context.SaveChanges();

                int maTheTu = theTu.MaTheTu;
                return(maTheTu);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #3
0
 public void UpdateTheTu(TheTu theTuUpdate)
 {
     try
     {
         TheTu theTu = context.TheTus.Where(x => x.MaTheTu == theTuUpdate.MaTheTu).Single <TheTu>();
         theTu.MaNguoi        = theTuUpdate.MaNguoi;
         theTu.LoaiTheTu      = theTuUpdate.LoaiTheTu;
         theTu.NoiDungThe     = theTuUpdate.NoiDungThe;
         theTu.ThoiGianDangKy = theTuUpdate.ThoiGianDangKy;
         theTu.TrangThai      = theTuUpdate.TrangThai;
         context.SaveChanges();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
コード例 #4
0
        static void Main(string[] args)
        {
            LinkedList <Admin> ListAdmin = Admin.GetFile();
            LinkedList <TheTu> ListTheTu = TheTu.GetFile();

mainMenu:
            switch (Menu.MainMenu())
            {
            case 1:
loginAdminMenu:
                bool adminLogin = Menu.LoginAdminMenu(ListAdmin);
adminMenu:
                if (adminLogin)
                {
                    switch (Menu.AdminMenu())
                    {
                    case 1:
                        Admin.RenderAccount(ListTheTu, "");
                        Support.PressKeyToExit();
                        goto adminMenu;

                    case 2:
                        Admin.CreateAccount(ListTheTu);
                        Support.PressKeyToExit();
                        goto adminMenu;

                    case 3:
                        Admin.DeleteAccount(ListTheTu);
                        Support.PressKeyToExit();
                        goto adminMenu;

                    case 4:
                        Admin.UnLockAccount(ListTheTu);
                        Support.PressKeyToExit();
                        goto adminMenu;

                    default:
                        Support.Await(true, "Dang Xuat Thanh Cong!", "");
                        goto mainMenu;
                    }
                }
                else
                {
                    goto loginAdminMenu;
                }

            case 2:
                User userLogin = Menu.LoginUserMenu(ListTheTu);
userMenu:
                switch (Menu.UserMenu())
                {
                case 1:
                    User.ShowInfo(userLogin);
                    Support.PressKeyToExit();
                    goto userMenu;

                case 2:
                    User.Withdrawal(userLogin);
                    Support.PressKeyToExit();
                    goto userMenu;

                case 3:
                    User.Transfers(userLogin);
                    Support.PressKeyToExit();
                    goto userMenu;

                case 4:
                    User.RenderTransaction(userLogin);
                    Support.PressKeyToExit();
                    goto userMenu;

                case 5:
                    User.ChangePin(ListTheTu, userLogin);
                    Support.PressKeyToExit();
                    goto userMenu;

                default:
                    Support.Await(true, "Dang Xuat Thanh Cong!", "");
                    goto mainMenu;
                }

            case 3:
                Menu.InfoTeam();
                Support.PressKeyToExit();
                goto mainMenu;

            default:
                break;
            }
        }
コード例 #5
0
        public static User LoginUserMenu(LinkedList <TheTu> ListTheTu)
        {
back:
            long id; int pin;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*********************************");
            Console.Write("*");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("\tDANG NHAP USER\t");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\t*");
            Console.WriteLine("*********************************");
            // user
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("ID:\t");
            Console.ResetColor();
            long.TryParse(Console.ReadLine(), out id);
            // pass
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("Pin:\t");
            Console.ResetColor();
            int.TryParse(Support.HidePass(), out pin);
            Console.WriteLine();

            bool status = false;

            // checkpass
            for (LinkedListNode <TheTu> p = ListTheTu.First; p != null; p = p.Next)
            {
                if (id == p.Value.Id)
                {
                    if (p.Value.Locked)
                    {
                        Support.Await(false, "", "Tai khoan nay da bi khoa!");
                        break;
                    }
                    else if (p.Value.Wrong < 2)
                    {
                        if (pin == p.Value.Pin)
                        {
                            status = true;
                            Support.Await(true, "Dang nhap thanh cong!", "");
                        }
                        else
                        {
                            p.Value.Wrong++;
                            Support.Await(false, "", "Tai khoan hoac mat khau khong chinh xac!");
                        }
                    }
                    else
                    {
                        p.Value.Locked = true;
                        TheTu.SaveFile(ListTheTu);
                        Support.Await(false, "", "Tai khoan bi khoa do nhap sai qua 3 lan!");
                        Thread.Sleep(1000);
                    }
                    break;
                }
            }
            if (status)
            {
                return(User.GetFile(id));
            }
            else
            {
                goto back;
            }
        }