Design report of movie ticket reservation system

1 Introduction

1.1 task purpose

Using the linked list in data structure as the data structure, combined with the basic knowledge of c# language, write a movie ticket reservation system to apply the knowledge to the actual software development. Understand and master the design method of data structure and algorithm, have preliminary independent analysis and design ability, and preliminarily master the basic methods and skills of problem analysis, system design, program coding, testing and so on in the process of software development: improve the ability to analyze and solve problems independently by comprehensively using the learned theoretical knowledge and methods, and train software development with systematic viewpoint and general specifications of software development, Cultivate the scientific working methods and style that software workers should have.

1.2 demand analysis

Design a practical movie ticket booking system, using SQL Server database and collection and other related data structures, write a system that can register users, log in, query movie information, book movie tickets, unsubscribe movie tickets, delete order records, modify account information and other functions

1.3 detailed functions

1. Registered user

2. Login

3. Verification code

4. Query movie ticket information

5. Book movie tickets and generate orders

6. Unsubscribe

7. Delete order

8. Modify user information

2 outline design

Table 2.1.1 relationship

2.1.2 process logic

Part 3 code design

3.1 business logic implementation

3.1.1 login

 private void button1_Click(object sender, EventArgs e)//Sign in
        {
            string ID = comboBox1.Text;
            string PWD = textBox1.Text;
            if (ID != "" && PWD != "")
            {
                if (ID.Length==11)
                {
                    bool asd = IsHandset(ID);
                    if (asd)
                    {
                        string asdd = "select count(*) from Client where ClientId='" + ID + "'";
                        DBTools bb = new DBTools();
                        int clienID = bb.Login(asdd);

                        if (clienID == 1)
                        {
                            string sql = "select count(*) from Client where ClientId='" + ID + "' and ClientPwd='" + PWD + "'";
                            DBTools cc = new DBTools();
                            int login = cc.Login(sql);
                            if (login == 1)
                            {
                                //After successful verification, pass the user name to the variable username defined by the Program
                                Program.username = comboBox1.Text.Trim();
                                //Defines the value returned when the validation is successful                    
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                            else
                            { MessageBox.Show("Wrong account or password!"); }
                        }
                        else
                        {
                            MessageBox.Show("This user does not exist, please register first");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Incorrect mobile number format");
                    }
                }
                else
                {
                    MessageBox.Show("The mobile phone number is not long enough");
                }  
                }
                else
                    { MessageBox.Show("Please enter your account and password!"); }
        }
        public bool IsHandset(string str_handset)//Check the and legality of mobile phone number
        {
            return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^[1]+[3,9]+\d{9}");
        }

3.1.2 registration

 private void button1_Click(object sender, EventArgs e)//register
        {
            bool kdfg = ksdjhfg();
            if (kdfg==false)
            {
                string ID = comboBox1.Text;
                string PWD = textBox1.Text;
                string quePWD = textBox2.Text;

                if (ID != "" && PWD != "" && quePWD != ""&&textBox3.Text!="")
                {
                    if (ID.Length == 11)
                    {
                        bool asd = IsHandset(ID);
                        if (asd)
                        {
                            if (PWD.Length >= 6 && PWD.Length <= 12)
                            {
                                if (PWD == quePWD)
                                {
                                    if (textBox3.Text==he.ToString())
                                    {
                                        string asdd = @"INSERT INTO [movieDB].[dbo].[Client]
                                   ([ClientId]
                                   ,[ClientPwd])
                             VALUES
                                   ('" + ID + "','" + PWD + "')";
                                        DBTools bb = new DBTools();
                                        int clienID = bb.DonIntsdf(asdd);
                                        if (clienID == 1)
                                        {
                                            MessageBox.Show("login was successful,Return to the login screen immediately", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                            this.Close();
                                        }
                                        else
                                        {
                                            MessageBox.Show("login has failed");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Incorrect verification code");
                                    }
                                    
                                    }else
                                    {
                                        MessageBox.Show("Inconsistent passwords");
                                    }
                            }
                            else
                            {
                                MessageBox.Show("The password length is limited to 6-12 position");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Incorrect mobile number format");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Incorrect length of mobile phone number");
                    }
                }
                else
                { MessageBox.Show("Please improve the information!"); }
            }
            else
            {
                MessageBox.Show("This user is already registered");
            }
        }
        public bool IsHandset(string str_handset)//Verify the legitimacy of mobile phone number
        {
            return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^[1]+[3,9]+\d{9}");
        }
        public bool ksdjhfg()//Verify registration 
        {
            string asdd = "select count(*) from Client where ClientId='" + comboBox1.Text+"'";
            DBTools bb = new DBTools();
            int clienID = bb.Login(asdd);
            if (clienID==1)
            {
                 return true;
            }
            else
            {
               return false;
            }
        }

        private void textBox1_Click(object sender, EventArgs e)//Verify registration
        {
            bool sdfsdf = ksdjhfg();
            if (sdfsdf)
            {
                MessageBox.Show("This user is already registered");
            }
        }
        private void button2_Click(object sender, EventArgs e)//Return to login
        {
            this.Close();
        }
        int he = 0;
        private void button3_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            int number1 = random.Next(0, 10);//Generate a single digit
            int number2 = random.Next(0,10);//Generate one digit
            he = number1 + number1;//close
            textBox4.Text = number1 +"+"+ number1+"=";
        }

3.1.3 advertising

3.1.3 film list reservation

 public Form1()
        {
            InitializeComponent();
        }
        DBTools cc = new DBTools();
        DataSet movie = new DataSet();
        private void button1_Click(object sender, EventArgs e)
        {
            string sql="";
            int movieID = int.Parse(comboBox1.SelectedValue.ToString());
            if (movieID > 0)
            {
                sql = " HouseID=" + movieID;
            }
            dv.RowFilter = sql;
        }
        DataView dv;
        private void Form1_Load(object sender, EventArgs e)//Load department name
        {
            try
            {
                string sql = @"SELECT [HouseID]
                          ,[MovieHouse]
                      FROM [movieDB].[dbo].[MovieHouse]
                    GO";
               movie=cc.QuerByAdapter(sql, "movie");
          
                DataRow row = movie.Tables["movie"].NewRow();
                row[0] = -1;
                row[1] = "Please select";
                movie.Tables["movie"].Rows.InsertAt(row, 0);//Add to the first row of the table
            
                comboBox1.DisplayMember = "MovieHouse";//Displayed value
                comboBox1.ValueMember = "HouseID";//actual value
                comboBox1.DataSource = movie.Tables["movie"];

                string sql2 = @"SELECT [TicketId]
                          ,[MovieName]
                          ,Movie.[HouseID]
                          ,[StartTime]
                          ,[EndTime]
                          ,[TicketPrice]
                          ,[number]
                          ,[MovieHouse]
                      FROM [movieDB].[dbo].[Movie]
                      inner join [movieDB].[dbo].[MovieHouse]
                      on Movie.HouseID=MovieHouse.HouseID";
                movie = cc.QuerByAdapter(sql2, "MovieList");
                dv=new DataView( movie.Tables["MovieList"]);
                dataGridView1.DataSource = dv;
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
          
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string moiveid = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            string sql = @"SELECT [TicketId]
                          ,[MovieHouse]
                          ,[EndTime]
                          ,[TicketPrice]
                          ,[MovieName]
                          ,[StartTime]
                          ,[number]
                      FROM [movieDB].[dbo].[Movie],[movieDB].[dbo].[MovieHouse]
                      where TicketId='" + moiveid + "' and Movie.HouseID=MovieHouse.HouseID";
            movie = cc.QuerByAdapter(sql,"sadfg");
            textBox1.Text = movie.Tables["sadfg"].Rows[0][0].ToString(); //number
            textBox2.Text = movie.Tables["sadfg"].Rows[0][1].ToString(); //cinema
            textBox3.Text = movie.Tables["sadfg"].Rows[0][2].ToString(); //Departure time
            textBox4.Text = movie.Tables["sadfg"].Rows[0][3].ToString();//Membership fare
            textBox5.Text = movie.Tables["sadfg"].Rows[0][4].ToString();//Movie title
            textBox6.Text = movie.Tables["sadfg"].Rows[0][5].ToString();//Opening time
            textBox7.Text = movie.Tables["sadfg"].Rows[0][6].ToString();//Remaining votes
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int sdf = 0;
            Random random = new Random();
            int number=Convert.ToInt32(numericUpDown1.Value);//Number of movie tickets
            string moiveid = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//Theater ID
            string dindanbianh = "";
            if (number<=int.Parse(textBox7.Text.ToString()))
            {
                for (int i = 1; i <= number; i++)
                {
                    int orderId = random.Next(100000, 999999);//Generate a six digit random number as the order number
                    string sql = string.Format(@"INSERT INTO [movieDB].[dbo].[OrderInfo]
                           ([OrderId]
                           ,[TicketId]
                           ,[number]
                           ,[State])
                     VALUES ({0},'{1}','{2}','{3}')
                     ;UPDATE [movieDB].[dbo].[Movie] SET [number]=[number]-{4} WHERE TicketId='{5}'"
                          , orderId, moiveid, number, "Booked", number, moiveid);
                    Convert.ToInt32(cc.DonIntsdf(sql));

                    string sql2 = string.Format(@"INSERT INTO client_order([OrderId],[ClientId])  VALUES ('{0}','{1}')", orderId, Program.username);
                    sdf = Convert.ToInt32(cc.DonIntsdf(sql2));
                    dindanbianh = dindanbianh + orderId;
                }
                if (sdf > 0)
                {
                    MessageBox.Show("Reservation succeeded, order No:" + dindanbianh, "Tips", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("The number of reserved votes cannot exceed the number of remaining votes");
            }
        }

3.1.4 order cancellation and deletion

private string open = "server=.;uid=sa;pwd=sasa;database=movieDB";//Statement to connect to database
        public State()
        {
            InitializeComponent();
        }
        DataSet Moielist = new DataSet();
        private void State_Load(object sender, EventArgs e)
        {
            loadDate();
        }

        private void loadDate()
        {
            DataTable objdt = (DataTable)dataGridView1.DataSource;
            if (objdt != null)
            {
                objdt.Rows.Clear();
            }
            
            dataGridView1.DataSource = objdt;
            SqlConnection conn = new SqlConnection(open);
            string sql = @"SELECT m.[TicketId]
                          ,m.[MovieName]
                          ,h.[MovieHouse]
                          ,m.[StartTime]
                          ,m.[EndTime]
                          ,m.[TicketPrice]
                          ,o.[number]
                          ,o.[OrderId]
                          ,o.[State]
                          ,c.[id]
                      FROM [movieDB].[dbo].[OrderInfo] o
                      left join [movieDB].[dbo].[Movie] m on m.TicketId=o.TicketId
                      left join [movieDB].[dbo].[MovieHouse] h on h.HouseID=m.HouseID
                      left join client_order c on o.OrderId = c.OrderId
                      where c.ClientId='" + Program.username + "'";
            SqlDataAdapter MovieList = new SqlDataAdapter(sql, conn);
            MovieList.Fill(Moielist, "MovieList");
            dataGridView1.DataSource = Moielist.Tables["MovieList"];
        }

        private void tuidinToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a column of data");
                return;
            }
            int a = dataGridView1.SelectedRows[0].Index;
            int OrderId = (int)dataGridView1.Rows[a].Cells["OrderId"].Value;
            string sql = string.Format(@"update OrderInfo set State='{0}' where OrderId='{1}'", "Unsubscribed ", OrderId);
            DBTools bb = new DBTools();
            int i = bb.DonIntsdf(sql);
            if (i > 0)
            {
                MessageBox.Show("Unsubscribe successfully");
                loadDate();
            }
            else
            {
                MessageBox.Show("Unsubscribe failed");
            }
        }

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a column of data");
                return;
            }
            int a = dataGridView1.SelectedRows[0].Index;
            int OrderId = (int)dataGridView1.Rows[a].Cells["OrderId"].Value;
            string state = dataGridView1.Rows[a].Cells["Column8"].Value.ToString().Trim();
            if (state=="Unsubscribed ")
            {
                string sql = string.Format(@"DELETE FROM OrderInfo  where OrderId='{0}'", OrderId);
                DBTools bb = new DBTools();
                string sql2 = string.Format(@"DELETE FROM client_order where OrderId='{0}'", OrderId);
                int i = bb.DonIntsdf(sql);
                if (i > 0)
                {
                    MessageBox.Show("Deleted successfully");
                    loadDate();
                }
                else
                {
                    MessageBox.Show("Delete failed");
                }
            }
            else
            {
                MessageBox.Show("Only unsubscribed orders can be deleted");
            }
        }

In UI design, the right-click menu is used to call methods

3.1.5 viewing and saving account information

 private void PersonalCenter_Load(object sender, EventArgs e)
        {
            string sql = "select * from Client where ClientId='" + Program.username + "'";
            DBTools bb = new DBTools();
            SqlDataReader reder = bb.reader(sql);
            while (reder.Read())
            {
                label2.Text = reder["ClientId"].ToString();
                textBox1.Text = reder["name"].ToString();
                textBox2.Text = reder["age"].ToString();
                textBox3.Text = reder["ClientPwd"].ToString();
            }
          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = string.Format(@"update Client set ClientPwd='{0}',name='{1}',age={2} where ClientId='{3}'",textBox3.Text, textBox1.Text, textBox2.Text,Program.username);
            DBTools bb = new DBTools();
            int i = bb.DonIntsdf(sql);
            if (i > 0)
            {
                MessageBox.Show("Saved successfully");
            }
            else
            {
                MessageBox.Show("Save failed");
            }
        }

4 commissioning results

After repeated tests, a system with simple operation is finally provided, with good fault tolerance and stability. During debugging, there are some small errors, but they are only basic writing errors. In terms of file saving, real-time saving and reading are realized. I have made more efforts in the deletion function, and the overall interface design is more reasonable. For the entered name, whether to delete it after finding the result, and if there is a duplicate name, It will be displayed twice to prompt whether to delete until all records are queried. After that, you can directly delete other records here, because it provides the function of circular deletion.

5 Summary

By doing this course design, I understand and master the design methods of data structure and algorithm, and preliminarily master the basic methods and skills of independent analysis and design, problem analysis in the development process of relic software, system design, program coding and testing, so as to improve my ability to compile technical documents

6 references

[1] Yan Weimin, WU Weimin Data structure (C# language version) [M] Beijing: Tsinghua University Press, 2007

[2] He Qinming, Feng Yan, Chen Yue Course design of data structure Zhejiang: Zhejiang University Press, 2007

[3] Li Chunbao, Tao Hongyan, Jin Jing, Zhao bingxiu Data structure and algorithm tutorial Beijing: Tsinghua University Press, 2007

Posted by digi24 on Mon, 16 May 2022 13:11:13 +0300