Пример #1
0
 //点击登录
 protected void BtnLogin_Click(object sender, EventArgs e)
 {
     //判断输入是否为空
     if (tbName.Text == string.Empty && tbPwd.Text == string.Empty)
     {
         Response.Write("<script>alert('请输入用户名或密码!');</script>");
     }
     //用户输入不为空
     else
     {
         //判断输入的字符串是否匹配正则
         if (Regex.IsMatch(tbName.Text, "^[A-Za-z]{1,10}$"))
         {
             //调用查询方法
             if (BLLCustomer.BLLSelectCustomer(tbName.Text, tbPwd.Text))
             {
                 //存储该用户
                 MODCustomer Customer = new MODCustomer();
                 Session["CustomerName"] = Customer.UserID;
                 Response.Redirect("/load.aspx");
             }
             else
             {
                 //不存在该用户
                 Response.Write("<script>alert('用户名或密码错误');</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('用户名或密码错误');</script>");
         }
     }
 }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         gvUser.DataSource = BLLCustomer.BLLSelectCustomerAll();
         gvUser.DataBind();
     }
 }
Пример #3
0
        private static void PrintCustomers()
        {
            List <Customer> customers = BLLCustomer.ReturnAllCustomers();

            foreach (var customer in customers)
            {
                Console.WriteLine(customer.CustomerID + " " + customer.CustomerName + " " + customer.CustomerAdress + " " + customer.CustomerPhone);
            }
        }
        private void PopulateCustomerDroplist()
        {
            List <Customer> customers = BLLCustomer.ReturnAllCustomers();

            foreach (var c in customers)
            {
                ListItem currentCustomer = new ListItem(c.CustomerName, c.CustomerID.ToString());
                dropdown_customerids.Items.Add(currentCustomer);
            }
        }
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            int   movieToBeHiredID = int.Parse(dropdown_movieids.SelectedValue);
            Movie movieToBeHired   = BLLMovie.ReturnMovieWithID(movieToBeHiredID);

            int      customerThatsHiringID = int.Parse(dropdown_customerids.SelectedValue);
            Customer customerThatsHiring   = BLLCustomer.ReturnCustomerWithID(customerThatsHiringID);

            BLLRentedMovie.HireMovie(customerThatsHiring, movieToBeHired);
            lbl_resultMSG.Text = customerThatsHiring.CustomerName + " hired " + movieToBeHired.MovieName;
        }
Пример #6
0
        private static void RegisterNewCustomer()
        {
            Console.WriteLine("Enter name >> ");
            string customername = Console.ReadLine();

            Console.WriteLine("Enter address >> ");
            string customeraddress = Console.ReadLine();

            Console.WriteLine("Enter phone >> ");
            string customerphone = Console.ReadLine();

            bool success = BLLCustomer.RegisterNewCustomer(new Customer(customername, customeraddress, customerphone));

            Console.WriteLine(success ? $"Customer {customername} Registered" : "Customer Registration Failed");
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            string customername    = txt_customername.Text;
            string customeraddress = txt_customeradress.Text;
            string customerphone   = txt_customerphone.Text;

            bool registratrionSucceeded = BLLCustomer.RegisterNewCustomer(new Customer(customername, customeraddress, customerphone));

            if (registratrionSucceeded)
            {
                lbl_customerregistrationMSG.Text = $"Customer {customername} Registered";
            }
            else
            {
                lbl_customerregistrationMSG.Text = $"Customer Registration Failed";
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <Customer> customers = BLLCustomer.ReturnAllCustomers();

            StringBuilder sb = new StringBuilder();

            sb.Append("All Registered Customers:");
            sb.Append("<br/><br/>");
            sb.Append("..............................");
            sb.Append("<br/><br/>");
            foreach (var customer in customers)
            {
                sb.Append(string.Format($"CustomerID: {customer.CustomerID} <br/>CustomerName: {customer.CustomerName} <br/>CustomerAddress: {customer.CustomerAdress} <br/>CustomerPhone: {customer.CustomerPhone}"));
                sb.Append("<br/><br/>");
            }
            sb.Append("..............................");
            customerslisted.InnerHtml = sb.ToString();
        }
Пример #9
0
        //编辑之后更新事件
        protected void gvUser_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            MODCustomer customer = new MODCustomer();

            customer.UserID   = (int)gvUser.DataKeys[e.RowIndex].Value;
            customer.UserName = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[2].Controls[0])).Text;
            customer.Login    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[3].Controls[0])).Text;
            customer.Pwd      = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[4].Controls[0])).Text;
            customer.Address  = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[5].Controls[0])).Text;
            customer.Phone    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[6].Controls[0])).Text;
            customer.Email    = ((TextBox)(gvUser.Rows[e.RowIndex].Cells[7].Controls[0])).Text;
            if (BLLCustomer.Uptade(customer))
            {
                gvUser.EditIndex = -1;
                Response.Write("<script>alert('修改成功')</script>");
                gvUser.DataSource = BLLCustomer.BLLSelectCustomerAll();
                gvUser.DataBind();
            }
        }
Пример #10
0
        //确认修改数据
        protected void Button1_Click1(object sender, EventArgs e)
        {
            //实例化数据类
            MODCustomer customer = new MODCustomer();

            customer.UserName = TextBox1.Text;
            customer.Login    = TextBox2.Text;
            customer.Pwd      = TextBox3.Text;
            customer.Address  = TextBox4.Text;
            customer.Phone    = TextBox5.Text;
            customer.Email    = TextBox6.Text;
            //调用新增方法
            if (BLLCustomer.BLLAddCustomer(customer))
            {
                Response.Write("<script>alert('新增成功')</script>");
                //刷新数据
                gvUser.DataSource = BLLCustomer.BLLSelectCustomerAll();
                gvUser.DataBind();
            }
            else
            {
                Response.Write("<script>alert('新增失败')</script>");
            }
        }
Пример #11
0
        public static void Run()
        {
            Console.WriteLine("1. Print all Customers");
            Console.WriteLine("2. Register new customer");
            Console.WriteLine("3. Print movies (and currently hired movies)");
            Console.WriteLine("4. Hire Movie");
            Console.WriteLine("5. Return Movie");
            Console.WriteLine("6. Register New Movie");
            Console.WriteLine("e. Exit application");
            string choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                PrintCustomers();
                Console.ReadKey();
                Console.Clear();
                break;

            case "2":
                RegisterNewCustomer();
                Console.ReadKey();
                Console.Clear();
                break;

            case "3":
                PrintMovies();
                PrintRentedMovies();
                Console.ReadKey();
                Console.Clear();
                break;

            case "4":
                #region retrieve availabla movies to hire
                List <Movie> availableMovies = BLLMovie.ReturnAvailableMovies();   //TODO: returning movies that should not be available
                Console.WriteLine("Currently available movies: ");
                foreach (var m in availableMovies)
                {
                    Console.WriteLine(m.MovieId + " " + m.MovieName);
                }
                Console.WriteLine("Choose which movie to hire >> ");
                int   movieToBeHiredID = int.Parse(Console.ReadLine());
                Movie movieToBeHired   = BLLMovie.ReturnMovieWithID(movieToBeHiredID);

                Console.WriteLine(movieToBeHired.MovieName + " (" + movieToBeHired.Genre.GenreName + ") was choosen");
                Console.WriteLine();
                #endregion

                #region choose who will hire the movie
                List <Customer> customers = BLLCustomer.ReturnAllCustomers();
                foreach (var c in customers)
                {
                    Console.WriteLine(c.CustomerID + " " + c.CustomerName);
                }
                Console.Write("Who is going to make the hire >> ");
                int      customerThatsHiringID = int.Parse(Console.ReadLine());
                Customer customerThatsHiring   = BLLCustomer.ReturnCustomerWithID(customerThatsHiringID);
                #endregion

                BLLRentedMovie.HireMovie(customerThatsHiring, movieToBeHired);

                Console.WriteLine();
                Console.ReadKey();
                Console.Clear();
                break;

            case "5":
                List <RentedMovie> rentals = BLLRentedMovie.GetRentedMovies();   //todo:
                foreach (var rental in rentals)
                {
                    Console.WriteLine(rental.RentedID + " " + rental.Movie.MovieName + " HIRED BY: " + rental.Customer.CustomerName);
                }
                Console.Write("Which movie do you wish to return? >> ");
                int  rentIDToReturn    = int.Parse(Console.ReadLine());
                bool returnSuccessfull = BLLRentedMovie.RemoveRentedMovie(rentIDToReturn);
                Console.WriteLine(returnSuccessfull ? "movie returned successfully" : "movie was not returned");
                Console.ReadKey();
                Console.Clear();
                break;

            case "6":
                RegisterNewMovie();
                break;

            case "e":
                userQuit = true;
                Console.Clear();
                Console.WriteLine("Goodbye...");
                break;

            default:
                Console.WriteLine("Please enter a valid command");
                Console.ReadKey();
                Console.Clear();
                break;
            }
        }
Пример #12
0
 //点击取消
 protected void gvUser_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     this.gvUser.EditIndex = -1;
     gvUser.DataSource     = BLLCustomer.BLLSelectCustomerAll();
     gvUser.DataBind();
 }
Пример #13
0
 //点击编辑
 protected void gvUser_RowEditing(object sender, GridViewEditEventArgs e)
 {
     this.gvUser.EditIndex = e.NewEditIndex;
     gvUser.DataSource     = BLLCustomer.BLLSelectCustomerAll();
     gvUser.DataBind();
 }