Exemplo n.º 1
0
        public void initManager()
        {
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            var rdr = mysql.ReadData("SELECT * FROM manager;");

            managerLinkLists = new LinkList <ManagerAccount>();
            if (rdr.HasRows)
            {
                //managerLists = new List<ManagerAccount>();

                while (rdr.Read())
                {
                    Console.WriteLine("{0} {1} {2} {3}", rdr.GetInt32(0), rdr.GetString(1),
                                      rdr.GetString(2), rdr.GetString(3));
                    ManagerAccount manager = new ManagerAccount();
                    manager.ID       = rdr.GetInt32(0);
                    manager.Username = rdr.GetString(1);
                    manager.Password = rdr.GetString(2);
                    manager.Level    = rdr.GetInt32(3);
                    //managerLists.Add(manager);
                    managerLinkLists.Add(manager);
                }
            }
            mysql.Close();
        }
Exemplo n.º 2
0
        private void bt_bus_del_Click(object sender, RoutedEventArgs e)
        {
            if (tbBus.Text.Equals(""))
            {
                lbNotice.Content = "未输入公交号!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.UpdateData("DELETE FROM businfo WHERE no = '" + tbBus.Text + "';") > 0)
            {
                //链表!!
                for (int i = 1; i <= busLinkList.Length(); i++)
                {
                    if (busLinkList.IndexOf(i).BusNo.Equals(tbBus.Text))
                    {
                        busLinkList.Delete(i);
                    }
                }
                //链表!!
                lbNotice.Content = "删除成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "删除失败。";
            }
            mysql.Close();
        }
Exemplo n.º 3
0
        private void bt_bus_edit_Click(object sender, RoutedEventArgs e)
        {
            if (busListBox.SelectedIndex == -1)
            {
                lbNotice.Content = "未选中编辑对象!";
                return;
            }
            try
            {
                Int32.Parse(tbBus.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "公交必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.UpdateData("UPDATE businfo SET no = '" + tbBus.Text + "' WHERE id = " + busLinkList.IndexOf(busListBox.SelectedIndex + 1).ID + ";") > 0)
            {
                //链表!!

                busLinkList.IndexOf(stationListBox.SelectedIndex + 1).BusNo = Int32.Parse(tbBus.Text);
                //链表!!
                lbNotice.Content = "更新成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "更新失败。";
            }
            mysql.Close();
        }
Exemplo n.º 4
0
        private void bt_acc_del_Click(object sender, RoutedEventArgs e)
        {
            if (tbAcc.Text.Equals(""))
            {
                lbNotice.Content = "未输入用户名";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.UpdateData("DELETE FROM manager WHERE username = '******';") > 0)
            {
                //链表!!
                for (int i = 1; i <= managerLinkLists.Length(); i++)
                {
                    if (managerLinkLists.IndexOf(i).Username.Equals(tbAcc.Text))
                    {
                        managerLinkLists.Delete(i);
                    }
                }
                //链表!!
                lbNotice.Content = "删除成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "删除失败。";
            }
            mysql.Close();
        }
Exemplo n.º 5
0
        private void bt_station_del_Click(object sender, RoutedEventArgs e)
        {
            if (tbStation.Text.Equals(""))
            {
                lbNotice.Content = "未输入站点名!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.UpdateData("DELETE FROM station WHERE name = '" + tbStation.Text + "';") > 0)
            {
                //链表!!
                for (int i = 1; i <= stationLinkList.Length(); i++)
                {
                    if (stationLinkList.IndexOf(i).Name.Equals(tbStation.Text))
                    {
                        stationLinkList.Delete(i);
                    }
                }
                //链表!!
                lbNotice.Content = "删除成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "删除失败。";
            }
            mysql.Close();
        }
Exemplo n.º 6
0
        public void initBus()
        {
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            var rdr = mysql.ReadData("SELECT * FROM businfo;");

            busLinkList = new LinkList <Bus>();
            if (rdr.HasRows)
            {
                //busList = new List<Bus>();

                while (rdr.Read())
                {
                    Console.WriteLine("{0} {1} {2}", rdr.GetInt32(0), rdr.GetInt32(1),
                                      rdr.GetString(2));
                    Bus bus = new Bus();
                    bus.ID    = rdr.GetInt32(0);
                    bus.BusNo = rdr.GetInt32(1);
                    //busList.Add(bus);
                    busLinkList.Add(bus);
                }
            }
            mysql.Close();
        }
Exemplo n.º 7
0
        public void initStation()
        {
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            var rdr = mysql.ReadData("SELECT * FROM station;");

            stationLinkList = new LinkList <Station>();
            if (rdr.HasRows)
            {
                //stationList = new List<Station>();

                while (rdr.Read())
                {
                    Console.WriteLine("{0} {1} {2}", rdr.GetInt32(0), rdr.GetString(1),
                                      rdr.GetInt32(2));
                    Station station = new Station();
                    station.ID       = rdr.GetInt32(0);
                    station.Name     = rdr.GetString(1);
                    station.Distance = rdr.GetInt32(2);
                    //stationList.Add(station);
                    stationLinkList.Add(station);
                }
            }
            mysql.Close();
        }
Exemplo n.º 8
0
        private void bt_acc_add_Click(object sender, RoutedEventArgs e)
        {
            if (tbAcc.Text.Equals("") || tbPw.Text.Equals("") || tbLv.Text.Equals(""))
            {
                lbNotice.Content = "信息输入不完整!";
                return;
            }
            try
            {
                Int32.Parse(tbLv.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "权限必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.InsertData("manager", "", tbAcc.Text, tbPw.Text, tbLv.Text) > 0)
            {
                //链表!!
                ManagerAccount manager = new ManagerAccount();
                manager.ID       = managerLinkLists.Length() + 1;
                manager.Username = tbAcc.Text;
                manager.Password = tbPw.Text;
                manager.Level    = Int32.Parse(tbLv.Text);
                managerLinkLists.Add(manager);
                //链表!!
                lbNotice.Content = "添加成功。";
                //initManager();
                initListBox();
            }
            else
            {
                lbNotice.Content = "添加失败。";
            }
            mysql.Close();
        }
Exemplo n.º 9
0
        private void bt_station_add_Click(object sender, RoutedEventArgs e)
        {
            if (tbStation.Text.Equals("") || tbDis.Text.Equals(""))
            {
                lbNotice.Content = "信息输入不完整!";
                return;
            }
            try
            {
                Int32.Parse(tbDis.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "里程必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.InsertData("station", "", tbStation.Text, tbDis.Text) > 0)
            {
                //链表!!
                Station station = new Station();
                station.ID       = stationLinkList.Length() + 1;
                station.Name     = tbStation.Text;
                station.Distance = Int32.Parse(tbDis.Text);
                stationLinkList.Add(station);
                //链表!!
                lbNotice.Content = "添加成功。";
                //initManager();
                initListBox();
            }
            else
            {
                lbNotice.Content = "添加失败。";
            }
            mysql.Close();
        }
Exemplo n.º 10
0
        private void bt_bus_add_Click(object sender, RoutedEventArgs e)
        {
            if (tbBus.Text.Equals(""))
            {
                lbNotice.Content = "未输入公交号!";
                return;
            }
            try
            {
                Int32.Parse(tbBus.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "公交必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.InsertData("businfo", "", tbBus.Text, "") > 0)
            {
                //链表!!
                Bus bus = new Bus();
                bus.ID    = busLinkList.Length() + 1;
                bus.BusNo = Int32.Parse(tbBus.Text);
                busLinkList.Add(bus);
                //链表!!
                lbNotice.Content = "添加成功。";
                //initManager();
                initListBox();
            }
            else
            {
                lbNotice.Content = "添加失败。";
            }
            mysql.Close();
        }
Exemplo n.º 11
0
        private void bt_station_edit_Click(object sender, RoutedEventArgs e)
        {
            if (stationListBox.SelectedIndex == -1)
            {
                lbNotice.Content = "未选中编辑对象!";
                return;
            }
            try
            {
                Int32.Parse(tbDis.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "里程必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            string sql = "UPDATE station SET name = '" + tbStation.Text + "',distance = '" + tbDis.Text + "' WHERE id = " + stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).ID + ";";

            if (mysql.UpdateData(sql) > 0)
            {
                //链表!!

                stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).Distance = Int32.Parse(tbDis.Text);
                stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).Name     = tbStation.Text;
                //链表!!
                lbNotice.Content = "更新成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "更新失败。";
            }
            mysql.Close();
        }
Exemplo n.º 12
0
        private void bt_acc_edit_Click(object sender, RoutedEventArgs e)
        {
            if (userListBox.SelectedIndex == -1)
            {
                lbNotice.Content = "未选中编辑对象!";
                return;
            }
            try
            {
                Int32.Parse(tbLv.Text);
            }
            catch (FormatException error)
            {
                lbNotice.Content = "权限必须是数字!";
                return;
            }
            MysqlUtil mysql = new MysqlUtil();

            mysql.GetConnection();
            if (mysql.UpdateData("UPDATE manager SET username = '******',password = '******',level = '" + tbLv.Text + "' WHERE id = " + managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).ID + ";") > 0)
            {
                //链表!!

                managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Level    = Int32.Parse(tbLv.Text);
                managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Username = tbAcc.Text;
                managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Password = tbPw.Text;
                //链表!!
                lbNotice.Content = "更新成功。";
                initListBox();
            }
            else
            {
                lbNotice.Content = "更新失败。";
            }
            mysql.Close();
        }