Beispiel #1
0
        private void toolStripMenuItem4_Owner_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (Form form in Application.OpenForms)
                {
                    if (form.GetType() == typeof(OwnerForm))
                    {
                        form.Activate();
                        return;
                    }
                }

                OwnerForm frm = new OwnerForm(role);
                tabControl1.Show();
                TabPage OwnerTabPage = new TabPage("Собственники");
                tabControl1.TabPages.Add(OwnerTabPage);
                tabControl1.SelectedTab = OwnerTabPage;
                frm.TopLevel            = false;
                frm.Visible             = true;
                frm.FormBorderStyle     = FormBorderStyle.None;
                frm.Dock = DockStyle.Fill;
                OwnerTabPage.Controls.Add(frm);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                logger.Error(exp, "toolStripMenuItem4_Owner_Click");
            }
        }
Beispiel #2
0
 //изменить
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         string    UpdateCurrentOwner = "update d__Owner set Name = '" + textBox1.Text.Trim() + "', FullName = '" + textBox2.Text.Trim() + "' where ID = " + selectID;
         DataTable dtbl = new DataTable();
         dtbl = DbConnection.DBConnect(UpdateCurrentOwner);
         this.Close();
         MessageBox.Show("Запись изменена!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         OwnerForm main = this.Owner as OwnerForm;
         main.btnOwnerReffresh_Click(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);
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string AddNewOwner = "insert into d__Owner " +
                              "values ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "',NULL)";
         DataTable dataTable = new DataTable();
         dataTable = DbConnection.DBConnect(AddNewOwner);
         this.Close();
         MessageBox.Show("Запись добавлена!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         OwnerForm main = this.Owner as OwnerForm;
         main.btnOwnerReffresh_Click(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);
     }
 }