找传奇、传世资源到传世资源站!

车队排队系统(进站、出站)源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

用于车辆的排队,包含添加删除,加载等
from clipboard using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            object obj = list2.SelectedItem;
            if (obj == null)
            {
                MessageBox.Show("尚未选择车辆!");
            }
            else
            {
                list1.Items.Add(obj);
                object o2 = obj;
                list2.Items.Remove(o2);
                WriteInFile();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string s = car.Text;
            if (s.Trim() == "" || s == null)
            {
                MessageBox.Show("车辆名称不能为空!");
            }
           else if (list1.Items.Contains(s) || list2.Items.Contains(s))
            {
                MessageBox.Show("该车辆已添加!");
            }
            else
            {
       
                list1.Items.Add(s);
                WriteInFile();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
           object obj = list1.SelectedItem;
            if (obj == null) {
                MessageBox.Show("尚未选择车辆!");
            } else {
                list2.Items.Add(obj);
                object o2 = obj;
                list1.Items.Remove(o2);
                WriteInFile();
            }
            
        }

        private void button4_Click(object sender, EventArgs e)
        {
            object obj = list1.SelectedItem;
            object obj2 = list2.SelectedItem;
            if (obj == null && obj2 == null)
            {
                MessageBox.Show("尚未选择车辆!");
            }
            else
            {
                list1.Items.Remove(obj);
                list2.Items.Remove(obj2);
                WriteInFile();
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            string path = System.Environment.CurrentDirectory;
            string[] ins = File.ReadAllLines(path @"..\in.txt");
            string[] outs = File.ReadAllLines(path @"..\out.txt");

            //添加车辆信息到站内
            if (ins == null || ins.Length < 1 || ins[0].Trim() == "") {

            }
            else
            {
                foreach (string s in ins)
                {
                    list1.Items.Add(s);
                }
            }

            //添加车辆信息到站外
            if (outs == null || outs.Length < 1 || outs[0].Trim() == "")
            {

            }
            else
            {
                foreach (string s in outs)
                {
                    list2.Items.Add(s);
                }
            }

            button5.Visible = false;
        }

        private void WriteInFile()
        {

            string path = System.Environment.CurrentDirectory;  
            string[] ss = new string[list1.Items.Count];
            for (int i = 0; i < list1.Items.Count; i ) {
                ss[i] = list1.Items[i].ToString();
            }

            string[] ss2 = new string[list2.Items.Count];
            for (int i = 0; i < list2.Items.Count; i )
            {
                ss2[i] = list2.Items[i].ToString();
            }

            File.WriteAllLines(path @"..\in.txt", ss);
            File.WriteAllLines(path @"..\out.txt", ss2);
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }
    }
}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复