public FaceForm() { InitializeComponent(); tabs.Selecting += new TabControlCancelEventHandler(tabs_Selecting); KeyPreview = true; InitialsSettings(); DataGridViewSQLWorker.DataGridSqlFilling(tabDgvs["tabSamples"][0], tabSelects["tabSamples"]); }
//private SerialPortsWorker worker; private void InitialsSettings() { //update message string UpdMsg = $"Переход на новую базу данных"; if (ApplicationDeployment.IsNetworkDeployed) { ApplicationDeployment current = ApplicationDeployment.CurrentDeployment; if (current.IsFirstRun) { MessageBox.Show($"В новой версии программы {Application.ProductVersion}{System.Environment.NewLine}{System.Environment.NewLine}{UpdMsg}{System.Environment.NewLine}{System.Environment.NewLine}Свои комментарии, замечания, сообщения об ошибках Вы можете сообщить мне {System.Environment.NewLine}по почте - [email protected]{System.Environment.NewLine}по телефону - 6 24 36{System.Environment.NewLine}лично{System.Environment.NewLine}С уважением,{System.Environment.NewLine}Борис Румянцев", $"Обновление весовой программы", MessageBoxButtons.OK, MessageBoxIcon.Information); } } tabSelects.Add("tabSamples", "select Country_Code as F_Country_Code , Client_ID as F_Client_ID, Year as F_Year, Sample_Set_ID as F_Sample_Set_ID, Sample_Set_Index as F_Sample_Set_Index from table_Sample_Set order by year,Sample_Set_ID, Country_Code, Client_ID, Sample_Set_Index"); tabSelects.Add("tabStandarts", "select SRM_Set_Name, SRM_Set_Number from table_SRM_Set"); tabSelects.Add("tabMonitors", "select Monitor_Set_Name, Monitor_Set_Number from table_Monitor_Set"); DataGridView[] dgvArray1 = new DataGridView[2]; dgvArray1[0] = dataGridView_SamplesSet; dgvArray1[1] = dataGridView_Samples; DataGridView[] dgvArray2 = new DataGridView[2]; dgvArray2[0] = dataGridView_StandartsSet; dgvArray2[1] = dataGridView_Standarts; DataGridView[] dgvArray3 = new DataGridView[2]; dgvArray3[0] = dataGridView_MonitorsSet; dgvArray3[1] = dataGridView_Monitors; tabDgvs.Add("tabSamples", dgvArray1); tabDgvs.Add("tabStandarts", dgvArray2); tabDgvs.Add("tabMonitors", dgvArray3); tabButtonName.Add("tabSamples", "образеца"); tabButtonName.Add("tabStandarts", "стандарта"); tabButtonName.Add("tabMonitors", "монитора"); tabTables.Add("tabSamples", "table_Sample"); tabTables.Add("tabStandarts", "table_SRM"); tabTables.Add("tabMonitors", "table_Monitor"); string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Text += version.Substring(0, version.Length - 2); DataGridViewSQLWorker.DataGridSqlFilling(dataGridView_SamplesSet, tabSelects["tabSamples"]); DataGridViewSQLWorker.DataGridSqlFilling(dataGridView_StandartsSet, tabSelects["tabStandarts"]); DataGridViewSQLWorker.DataGridSqlFilling(dataGridView_MonitorsSet, tabSelects["tabMonitors"]); }
private void dataGridView_MonitorsSet_CellClick(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex;// get the Row Index // for sorting if (index < 0) { return; } DataGridViewRow selectedRow = dataGridView_MonitorsSet.Rows[index]; string select = $"select Monitor_Number,1 as skip,Monitor_SLI_Weight, Monitor_LLI_Weight from table_Monitor where Monitor_Set_Name = '{selectedRow.Cells[0].Value}' and Monitor_Set_Number = '{selectedRow.Cells[1].Value}'"; DataGridViewSQLWorker.DataGridSqlFilling(dataGridView_Monitors, select); ColorizeAndSelect(dataGridView_Monitors); if (dataGridView_Monitors.RowCount == 0) { return; } dataGridView_Monitors.Focus(); }
// we allow to users save weight (double value) from dgv. Without checking it allows to use sql injections. Let's add ValueType to columns with weight in oder to avoid it. private void dataGridView_SamplesSet_CellClick(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex;// get the Row Index // for sorting if (index < 0) { return; } DataGridViewRow selectedRow = dataGridView_SamplesSet.Rows[index]; string select = $"select F_Sample_Set_Index+A_Sample_ID as A_Sample_ID,A_Client_Sample_ID as A_Client_Sample_ID, P_Weighting_SLI, P_Weighting_LLI from table_Sample where F_Country_Code = '{selectedRow.Cells[0].Value}' and F_Client_ID = '{selectedRow.Cells[1].Value}' and F_Year = '{selectedRow.Cells[2].Value}' and F_Sample_Set_ID = '{selectedRow.Cells[3].Value}' and F_Sample_Set_Index = '{selectedRow.Cells[4].Value}'"; DataGridViewSQLWorker.DataGridSqlFilling(dataGridView_Samples, select); ColorizeAndSelect(dataGridView_Samples); if (dataGridView_Samples.RowCount == 0) { return; } dataGridView_Samples.Columns[1].ReadOnly = true; dataGridView_Samples.Focus(); }