コード例 #1
0
        //Load data from excel
        private void LoadData()
        {
            var package = new ExcelPackage(new FileInfo(@"..\Resources\ImportData.xlsx"));

            ExcelWorksheet worksheet = package.Workbook.Worksheets[1];

            for (int i = worksheet.Dimension.Start.Row + 1; i <= worksheet.Dimension.End.Row; i++)
            {
                int j = 1;

                if (worksheet.Cells[i, j].Value == null)
                {
                    continue;
                }
                string name     = worksheet.Cells[i, j++].Value.ToString();
                string userName = worksheet.Cells[i, j++].Value.ToString();
                string roomID   = worksheet.Cells[i, j++].Value.ToString();
                string blockID  = worksheet.Cells[i, j++].Value.ToString();
                string status   = worksheet.Cells[i, j++].Value.ToString();


                CWheelChair cWheel = new CWheelChair()
                {
                    id       = name,
                    userName = userName,
                    roomID   = roomID,
                    blockID  = blockID,
                    status   = status
                };
                list.Add(cWheel);
            }
        }
コード例 #2
0
        private void cbID_TextChanged(object sender, EventArgs e)
        {
            CWheelChair cWheelChair = getCWheelbyID(cbID.Text);

            txbUser.Text  = cWheelChair.userName;
            txbRoom.Text  = cWheelChair.roomID;
            txbBlock.Text = cWheelChair.blockID;
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            CWheelChair oldValue = getCWheelbyID(cbID.Text);
            CWheelChair newValue = new CWheelChair()
            {
                id       = cbID.Text,
                userName = txbUser.Text,
                roomID   = txbRoom.Text,
                blockID  = txbBlock.Text
            };
            int index = list.IndexOf(oldValue);

            if (index != -1)
            {
                list[index] = newValue;
            }
            SaveData();
            Close();
        }
コード例 #4
0
ファイル: Main.cs プロジェクト: khuemh/WAD
        //Create a table of wheelchair data
        private void CreateCustomTable(CWheelChair wheelChair, int i)
        {
            Panel panel = new Panel();

            panel.Name     = "pn" + wheelChair.id;
            panel.Location = new Point(3, i);
            panel.Size     = new Size(537, 34);
            pnWheelChair.Controls.Add(panel);

            //Textbox Name
            TextBox textBox = new TextBox();

            textBox.Name      = "txb" + wheelChair.id + "Name";
            textBox.Text      = wheelChair.id;
            textBox.Location  = new Point(0, 6);
            textBox.ReadOnly  = true;
            textBox.Size      = new Size(124, 20);
            textBox.Cursor    = Cursors.Arrow;
            textBox.GotFocus += textBox_GotFocus;
            panel.Controls.Add(textBox);

            //Textbox User
            TextBox textbUser = new TextBox();

            textbUser.Name      = "txb" + wheelChair.id + "User";
            textbUser.Text      = wheelChair.userName;
            textbUser.ReadOnly  = true;
            textbUser.Location  = new Point(130, 6);
            textbUser.Size      = new Size(100, 20);
            textbUser.Cursor    = Cursors.Arrow;
            textbUser.GotFocus += textBox_GotFocus;
            panel.Controls.Add(textbUser);

            //Textbox Room
            TextBox txbRoom = new TextBox();

            txbRoom.Name      = "txb" + wheelChair.id + "Room";
            txbRoom.Text      = wheelChair.roomID;
            txbRoom.ReadOnly  = true;
            txbRoom.Location  = new Point(236, 6);
            txbRoom.Size      = new Size(100, 20);
            txbRoom.Cursor    = Cursors.Arrow;
            txbRoom.GotFocus += textBox_GotFocus;
            panel.Controls.Add(txbRoom);

            //Textbox Block
            TextBox txbBlock = new TextBox();

            txbBlock.Name      = "txb" + wheelChair.id + "Block";
            txbBlock.Text      = wheelChair.blockID;
            txbBlock.ReadOnly  = true;
            txbBlock.Location  = new Point(342, 6);
            txbBlock.Size      = new Size(100, 20);
            txbBlock.Cursor    = Cursors.Arrow;
            txbBlock.GotFocus += textBox_GotFocus;
            panel.Controls.Add(txbBlock);


            //Textbox Status
            TextBox txbStatus = new TextBox();

            txbStatus.Name      = "txb" + wheelChair.id + "Status";
            txbStatus.ReadOnly  = true;
            txbStatus.Location  = new Point(448, 6);
            txbStatus.BackColor = Color.Green;
            txbStatus.Size      = new Size(86, 20);
            txbStatus.Cursor    = Cursors.Arrow;
            txbStatus.GotFocus += textBox_GotFocus;
            panel.Controls.Add(txbStatus);
        }