private void соединениеСБДToolStripMenuItem_Click(object sender, EventArgs e) { mdlData.ready = true; mdlData.CounterClear(); mdlData.ConnectDataBase(); if (mdlData.WindowChildCustomer == true || mdlData.WindowChildSellers == true) { MessageBox.Show("База уже загружена. Сначала закройте все окна.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //Проверяем есть ли таблицы в базе данных путем их последовательного открытия SqlCommand cmd = mdlData.cnn.CreateCommand(); try { cmd.CommandText = "SELECT * FROM object"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT * FROM company"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT * FROM customer"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT * FROM sellers"; cmd.ExecuteNonQuery(); /*cmd.CommandText = "BACKUP DATABASE mo55 TO DISK = 'c:\\mo55documents\\mo55_" + DateTime.Now.ToString("ddMMyyyy--HH-mm-ss") + ".bak'"; * cmd.ExecuteNonQuery();*/ } //В случае возникновения хотя бы одной ошибки, фиксируем ее catch (SqlException ex) { statusStrip1.Items.Clear(); statusStrip1.Items.Add(DateTime.Now.ToLongTimeString() + ": " + ex.Message); mdlData.ready = false; } //Если все прошло успешно if (mdlData.ready != false) { редактироватьToolStripMenuItem.Visible = true; видToolStripMenuItem.Visible = true; //SaveToolStripMenuItem.Enabled = true; AddToolStripMenuItem.Enabled = true; OpenToolStripMenuItem.Enabled = true; toolStripDropDownButton1.Enabled = true; toolStripDropDownButton1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.document_add_icon)); toolStripDropDownButton1.Image = null; toolStripDropDownButton2.Enabled = true; toolStripDropDownButton2.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.blue_scanner)); toolStripDropDownButton2.Image = null; toolStripButton2.Enabled = true; toolStripButton2.BackgroundImage = ((System.Drawing.Image)(Properties.Resources._1)); toolStripButton2.Image = null; toolStripButton3.Enabled = true; toolStripButton3.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.wheel)); toolStripButton3.Image = null; toolStripComboBox1.Enabled = true; InnerTableFill("Customer", ref TabCustomer); InnerTableFill("Sellers", ref TabSellers); InnerTableFill("Company", ref TabCompany); InnerTableFill("Object", ref TabObject); statusStrip1.Items.Add(DateTime.Now.ToLongTimeString() + ConsoleMessageBox.LoadDBTrue); CreateCollection(); LinkingCollection(); statusStrip1.Items.Clear(); statusStrip1.Items.Add(DateTime.Now.ToLongTimeString() + ConsoleMessageBox.LoadCollTrue); mdlData.cnn.Close(); statusStrip1.Items.Clear(); statusStrip1.Items.Add(DateTime.Now.ToLongTimeString() + ConsoleMessageBox.SessionClose); toolStripComboBox1.Items.Add("Покупатели"); toolStripComboBox1.Items.Add("Продавцы"); DocCustomerPdf new2MDIChild = new DocCustomerPdf(); new2MDIChild.MdiParent = this; new2MDIChild.FormClosed += new FormClosedEventHandler(NotifyAboutClosedChildForm); new2MDIChild.Show(); DocPdf newMDIChild = new DocPdf(); newMDIChild.MdiParent = this; newMDIChild.FormClosed += new FormClosedEventHandler(NotifyAboutClosedChildForm); newMDIChild.Show(); HorizontallyTileMyWindows(sender, e); } else { statusStrip1.Items.Add(DateTime.Now.ToLongTimeString() + ConsoleMessageBox.LoadDBFalse); } }
public frmKalendarSellers(DocPdf form) { InitializeComponent(); _owner = form; }