private void toolStripMenuItem2_Station_Click(object sender, EventArgs e) { try { foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(StationForm)) { form.Activate(); return; } } StationForm frm = new StationForm(role, UserID); tabControl1.Show(); TabPage StationTabPage = new TabPage("Станции"); tabControl1.TabPages.Add(StationTabPage); tabControl1.SelectedTab = StationTabPage; frm.TopLevel = false; frm.Visible = true; frm.FormBorderStyle = FormBorderStyle.None; frm.Dock = DockStyle.Fill; StationTabPage.Controls.Add(frm); } catch (Exception exp) { MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Error(exp, "toolStripMenuItem2_Station_Click"); } }
private void button_OK_StationForm_Click(object sender, EventArgs e) { try { string FillStation = "exec [dbo].[FillStation] " + textBox_Add_Code_StationForm.Text.Trim() + "," + textBox_Add_Code6_StationForm.Text.Trim() + "," + textBox_Add_Name_StationForm.Text.Trim() + "','" + User_AID + "'"; string SelectDubl = "select * from d__Station where Code = " + textBox_Add_Code_StationForm.Text.Trim(); DataTable dt = new DataTable(); dt = DbConnection.DBConnect(SelectDubl); if (dt.Rows.Count == 0) { DbConnection.DBConnect(FillStation); this.Close(); MessageBox.Show("Запись добавлена!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); StationForm main = this.Owner as StationForm; main.btn_refsh_station_form_Click_1(null, null); } else { MessageBox.Show("Станция с кодом: " + textBox_Add_Code_StationForm.Text.Trim() + " имеется в справочнике", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (SqlException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exp) { MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button_Updt_OK_StationForm_Click(object sender, EventArgs e) { try { string Updt_CurrentStation = "update d__Station " + "set Name = '" + textBox_Updt_Name_StationForm.Text.Trim() + "', Code = " + Convert.ToInt32(textBox_Updt_Code_StationForm.Text.Trim()) + ", Code6 = " + Convert.ToInt32(textBox_Updt_Code6_StationForm.Text.Trim()) + " " + "where ID = " + selectStationID; DataTable dtbl = new DataTable(); dtbl = DbConnection.DBConnect(Updt_CurrentStation); this.Close(); MessageBox.Show("Станция изменена!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); StationForm main = this.Owner as StationForm; main.btn_refsh_station_form_Click_1(null, null); } catch (SqlException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exp) { MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }