Example #1
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (stationComboBox.Text == "")
            {
                MessageBox.Show("请输入站別", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (modelComboBox.Text == "")
            {
                MessageBox.Show("请输入产品型号", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (customerComboBox.Text == "")
            {
                MessageBox.Show("请输入客戶別", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (MessageBox.Show("确定删除表格啊?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                TableXml.DeletProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text);

                DataGridView1.Rows.Clear();
                DataGridView1.Columns.Clear();
                stationComboBox.Text  = "";
                modelComboBox.Text    = "";
                customerComboBox.Text = "";
            }
        }
Example #2
0
        private void customerComboBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            TABLECOLUMN tableCol;

            if (e.KeyChar == (Char)13)
            {
                if (stationComboBox.Text != "" && modelComboBox.Text != "" && customerComboBox.Text != "")
                {
                    if (TableXml.SelectProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text) == 1)
                    {
                        return;
                    }

                    tableColList.Clear();
                    DataGridView1.Rows.Clear();
                    DataGridView1.Columns.Clear();

                    DataGridView1.ColumnCount = 10;

                    for (int i = 0; i < DataGridView1.ColumnCount; i++)
                    {
                        DataGridView1.Columns[i].Width    = 60;
                        DataGridView1.Columns[i].Name     = Convert.ToChar(i + 65).ToString();
                        DataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;

                        tableCol      = new TABLECOLUMN();
                        tableCol.Name = DataGridView1.Columns[i].Name;

                        tableColList.Add(tableCol);
                    }

                    for (int i = 0; i < 20; i++)
                    {
                        DataGridView1.Rows.Add("");
                        DataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString();
                    }

                    DataGridView1.CurrentCell.Selected = false;

                    int rows    = DataGridView1.Rows.Count;
                    int columns = DataGridView1.Columns.Count;

                    TableXml.InsertProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, rows, columns);
                    for (int i = 0; i < tableColList.Count; i++)
                    {
                        tableCol = tableColList[i];
                        TableXml.InsertColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, i, tableCol);
                    }

                    this.ActiveControl = DataGridView1;
                }
            }
            else
            {
                if (!LoginForm.Login)
                {
                    e.Handled = true;
                }
            }
        }
Example #3
0
        private void customerComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (stationComboBox.Text != "" && modelComboBox.Text != "")
            {
                int         rows    = 0;
                int         columns = 0;
                TABLECOLUMN tableCol;

                tableColList.Clear();
                DataGridView1.Rows.Clear();
                DataGridView1.Columns.Clear();

                TableXml.GetProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, ref rows, ref columns, ref tableColList);

                DataGridView1.ColumnCount = columns;
                for (int i = 0; i < columns; i++)
                {
                    if (i < tableColList.Count)
                    {
                        tableCol = tableColList[i];
                    }
                    else
                    {
                        tableCol = new TABLECOLUMN();
                        tableColList.Add(tableCol);
                    }

                    if (tableCol.Readvalue == 4)
                    {
                        DataGridView1.Columns[i].Width = 100;
                    }
                    else
                    {
                        DataGridView1.Columns[i].Width = 60;
                    }

                    DataGridView1.Columns[i].Name     = tableCol.Name;
                    DataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                }

                for (int i = 0; i < rows; i++)
                {
                    string[] row = new string[columns];
                    DataGridView1.Rows.Add(row);

                    DataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString();
                }

                readBtn.Enabled = true;

                this.ActiveControl = DataGridView1;
            }
        }
Example #4
0
        //-------------------------------------Product Setting-------------------------------------
        private void stationComboBox_GotFocus(object sender, EventArgs e)
        {
            stationComboBox.Items.Clear();

            List <string> stations = new List <string>();

            TableXml.GetStations(ref stations);
            for (int i = 0; i < stations.Count; i++)
            {
                stationComboBox.Items.Add(stations[i]);
            }

            stations.Clear();
            stations = null;
        }
Example #5
0
        private void deleteColumnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectHeaderColumnIndex > -1)
            {
                if (stationComboBox.Text != "" && modelComboBox.Text != "" && customerComboBox.Text != "")
                {
                    tableColList.RemoveAt(SelectHeaderColumnIndex);
                    DataGridView1.Columns.RemoveAt(SelectHeaderColumnIndex);

                    TableXml.DeleteColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, SelectHeaderColumnIndex);
                    TableXml.SaveProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, DataGridView1.RowCount, DataGridView1.ColumnCount);
                }

                SelectHeaderColumnIndex = -1;
            }
        }
Example #6
0
        private void addRowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectHeaderRowIndex > -1)
            {
                DataGridView1.Rows.Insert(SelectHeaderRowIndex);

                for (int i = 0; i < DataGridView1.RowCount; i++)
                {
                    DataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString();
                }

                SelectHeaderRowIndex = -1;

                TableXml.SaveProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, DataGridView1.RowCount, DataGridView1.ColumnCount);
            }
        }
Example #7
0
        private void modelComboBox_GotFocus(object sender, EventArgs e)
        {
            modelComboBox.Items.Clear();
            if (stationComboBox.Text != "")
            {
                List <string> models = new List <string>();
                TableXml.GetModel(stationComboBox.Text, ref models);

                for (int i = 0; i < models.Count; i++)
                {
                    modelComboBox.Items.Add(models[i]);
                }

                models.Clear();
                models = null;
            }
        }
Example #8
0
        private void DataGridView1_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (!LoginForm.Login)
            {
                return;
            }

            var cellRectangle = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);

            TABLECOLUMN tableCol = tableColList[e.ColumnIndex];

            DataGridView1.Columns[e.ColumnIndex].HeaderCell.Style.BackColor = Color.FromArgb(72, 180, 225);

            int locationX = this.Location.X + DataGridView1.Location.X + cellRectangle.Location.X + 5;
            int locationY = this.Location.Y + DataGridView1.Location.Y + cellRectangle.Location.Y + cellRectangle.Height + 30;

            ColumnForm form = new ColumnForm(e.ColumnIndex, locationX, locationY, tableCol);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                tableCol.Name               = form.ReturnName;
                tableCol.Formula            = form.ReturnFormula;
                tableCol.Min                = form.ReturnMin;
                tableCol.Max                = form.ReturnMax;
                tableCol.Readvalue          = form.ReturnReadvalue;
                tableColList[e.ColumnIndex] = tableCol;

                TableXml.SaveColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, e.ColumnIndex, tableCol);

                DataGridView1.Columns[e.ColumnIndex].Name = tableCol.Name;

                if (tableCol.Readvalue == 4)
                {
                    DataGridView1.Columns[e.ColumnIndex].Width = 100;
                }
                else
                {
                    DataGridView1.Columns[e.ColumnIndex].Width = 60;
                }
            }

            DataGridView1.Columns[e.ColumnIndex].HeaderCell.Style.BackColor = SystemColors.Control;
        }
Example #9
0
        private void customerComboBox_GotFocus(object sender, EventArgs e)
        {
            customerComboBox.Items.Clear();

            if (stationComboBox.Text != "" && modelComboBox.Text != "")
            {
                List <string> customers = new List <string>();

                TableXml.GetCustomers(stationComboBox.Text, modelComboBox.Text, ref customers);

                for (int i = 0; i < customers.Count; i++)
                {
                    customerComboBox.Items.Add(customers[i]);
                }

                customers.Clear();
                customers = null;
            }
        }
Example #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            TableXml.Init();

            string      xmlFile = Application.StartupPath + "\\Setting.xml";
            XmlDocument doc     = new XmlDocument();

            if (File.Exists(xmlFile))
            {
                doc.Load(xmlFile);

                XmlNode node = doc.DocumentElement.SelectSingleNode("/Setting/FilePath");
                if (node != null)
                {
                    filepathTextBox.Text = node.InnerText;
                    folderBrowserDialog1.SelectedPath = filepathTextBox.Text;
                }

                int size;
                node = doc.DocumentElement.SelectSingleNode("/Setting/Font");
                if (node != null)
                {
                    if (Int32.TryParse(node.InnerText, out size))
                    {
                        DataGridView1.DefaultCellStyle.Font = new Font("Microsoft JhengHei", size);
                    }
                }
            }

            try
            {
                Directory.CreateDirectory(folderBrowserDialog1.SelectedPath);
            }
            catch (Exception ex)
            {
                EventLog.Write(ex.Message);
            }
        }
Example #11
0
        private void saveDataToDB()
        {
            string result = "";

            for (int i = 0; i < DataGridView1.Rows.Count; i++)
            {
                for (int j = 0; j < DataGridView1.Columns.Count; j++)
                {
                    result += DataGridView1[j, i].FormattedValue.ToString();

                    if (j == DataGridView1.Columns.Count - 1)
                    {
                        result += "\r\n";
                    }
                    else
                    {
                        result += ",";
                    }
                }
            }

            TableXml.SaveData(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, result, string.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now));
        }
Example #12
0
        private void addColumnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectHeaderColumnIndex > -1)
            {
                if (stationComboBox.Text != "" && modelComboBox.Text != "" && customerComboBox.Text != "")
                {
                    TABLECOLUMN tableCol = new TABLECOLUMN();
                    tableCol.Name = "New";

                    DataGridViewColumn dtCol = new DataGridViewColumn();
                    dtCol.Name         = "New";
                    dtCol.Width        = 60;
                    dtCol.SortMode     = DataGridViewColumnSortMode.NotSortable;
                    dtCol.CellTemplate = new DataGridViewTextBoxCell();

                    tableColList.Insert(SelectHeaderColumnIndex, tableCol);
                    DataGridView1.Columns.Insert(SelectHeaderColumnIndex, dtCol);
                    TableXml.InsertColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, SelectHeaderColumnIndex, tableCol);
                    TableXml.SaveProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, DataGridView1.RowCount, DataGridView1.ColumnCount);
                }

                SelectHeaderColumnIndex = -1;
            }
        }
Example #13
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     tableColList.Clear();
     TableXml.Deinit();
 }