Example #1
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 #2
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;
            }
        }