コード例 #1
0
        public frmMain()
        {
            InitializeComponent();

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;


            trainfile = "customer.txt";

            this.lblStatus.Visible = false;

            //read information in customer file
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file = new System.IO.StreamReader(trainfile);

            while ((line = file.ReadLine()) != null)
            {
                string[] split = line.Split(' ');

                Customer cus = new Customer();

                cus.setName(split[0]);

                cus.setAge(Int32.Parse(split[1]));
                cus.setGender(Int32.Parse(split[2]));
                cus.setIncoming(Int32.Parse(split[3]));
                cus.setNumcard(Int32.Parse(split[4]));
                cus.setResponse(Int32.Parse(split[5]));

                lCustomer.Add(cus);

                counter = counter + 1;
            }

            file.Close();

            this.lblTotal.Text = "/ " + counter;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: nvnhcmus/kNN
        public frmMain()
        {
            InitializeComponent();

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            trainfile = "customer.txt";

            this.lblStatus.Visible = false;

            //read information in customer file
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file = new System.IO.StreamReader(trainfile);

            while ((line = file.ReadLine()) != null)
            {
                string[] split = line.Split(' ');

                Customer cus = new Customer();

                cus.setName(split[0]);

                cus.setAge(Int32.Parse(split[1]));
                cus.setGender(Int32.Parse(split[2]));
                cus.setIncoming(Int32.Parse(split[3]));
                cus.setNumcard(Int32.Parse(split[4]));
                cus.setResponse(Int32.Parse(split[5]));

                lCustomer.Add(cus);

                counter = counter + 1;
            }

            file.Close();

            this.lblTotal.Text = "/ " + counter;
        }
コード例 #3
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog cFile = new OpenFileDialog();   //open file windows

            cFile.Filter = "classify customer file|*.txt"; //filter only open .txt file

            cFile.ShowDialog();

            customerfile      = cFile.FileName;
            this.txtFile.Text = cFile.FileName;//get path file


            //read data into unknown customerset
            //read information in customer file
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file = new System.IO.StreamReader(customerfile);

            while ((line = file.ReadLine()) != null)
            {
                string[] split = line.Split(' ');


                Customer cus = new Customer();

                cus.setName(split[0]);

                cus.setAge(Int32.Parse(split[1]));
                cus.setGender(Int32.Parse(split[2]));
                cus.setIncoming(Int32.Parse(split[3]));
                cus.setNumcard(Int32.Parse(split[4]));
                cus.setResponse(-1);

                uCustomer.Add(cus);
            }

            file.Close();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: nvnhcmus/kNN
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog cFile = new OpenFileDialog();//open file windows
            cFile.Filter = "classify customer file|*.txt";//filter only open .txt file

            cFile.ShowDialog();

            customerfile = cFile.FileName;
            this.txtFile.Text = cFile.FileName;//get path file

            //read data into unknown customerset
            //read information in customer file
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file = new System.IO.StreamReader( customerfile );

            while ((line = file.ReadLine()) != null)
            {
                string[] split = line.Split(' ');

                Customer cus = new Customer();

                cus.setName(split[0]);

                cus.setAge(Int32.Parse(split[1]));
                cus.setGender(Int32.Parse(split[2]));
                cus.setIncoming(Int32.Parse(split[3]));
                cus.setNumcard(Int32.Parse(split[4]));
                cus.setResponse(-1);

                uCustomer.Add(cus);
            }

            file.Close();
        }