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(); DataGridView1.Columns.Insert(SelectHeaderColumnIndex, dtCol); tableColList.Insert(SelectHeaderColumnIndex, tableCol); Sqlite.InsertColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, SelectHeaderColumnIndex, tableCol); Sqlite.UpdateProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, DataGridView1.RowCount, DataGridView1.ColumnCount); } SelectHeaderColumnIndex = -1; } }
private void customerComboBox_KeyPress(object sender, KeyPressEventArgs e) { TABLECOLUMN tableCol; if (e.KeyChar == (Char)13) { if (stationComboBox.Text != "" && modelComboBox.Text != "" && customerComboBox.Text != "") { if (Sqlite.SelectProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text) == 1) { return; } tableColList.Clear(); DataGridView1.Rows.Clear(); DataGridView1.Columns.Clear(); DataGridView1.ColumnCount = 10; int size = Convert.ToInt32(DataGridView1.DefaultCellStyle.Font.Size); for (int i = 0; i < DataGridView1.ColumnCount; i++) { DataGridView1.Columns[i].Width = size * 6; 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].Height = size + 15; DataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString(); } DataGridView1.CurrentCell.Selected = false; int rows = DataGridView1.Rows.Count; int columns = DataGridView1.Columns.Count; Sqlite.InsertProduct(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, rows, columns); for (int i = 0; i < tableColList.Count; i++) { tableCol = tableColList[i]; Sqlite.InsertColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, i, tableCol); } this.ActiveControl = DataGridView1; } } else { if (!LoginForm.Login) { e.Handled = true; } } }