Пример #1
0
 private void toolStripButton5_Click(object sender, EventArgs e)
 {
     if (SearchV == null)
     {
         SearchV             = new SearchVendor();
         SearchV.MdiParent   = this;
         SearchV.FormClosed += new FormClosedEventHandler(SearchV_FormClosed);
         SearchV.Show();
         //this.Close();
     }
     else
     {
         SearchV.Activate();
     }
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (vendorIDtxt.Text != "" && phonetxt.Text != "" && addresstxt.Text != "" && citytxt.Text != "" && countrytxt.Text != "" && phonetxt.Text != "" &&
                companytxt.Text != "" && typetxt.Text != "" && titletxt.Text != "" && firstnametxt.Text != "" && surnametxt.Text != "" && emailtxt.Text != "")
            {
                int v;
                if (Int32.TryParse(phonetxt.Text.Trim(), out v))
                {
                    con.Open();

                    string query = "INSERT TBL_VENDOR VALUES (" + vendorIDtxt.Text.Trim() + ", " + phonetxt.Text.Trim() + ", '" + addresstxt.Text.Trim() + "' ,  '" + companytxt.Text.Trim() + "' , '" + typetxt.Text.Trim() +
                                   "',  '" + countrytxt.Text.Trim() + "',' " + citytxt.Text.Trim() + "', '" + titletxt.Text.Trim() + "', '" + firstnametxt.Text.Trim() + "', '" + surnametxt.Text.Trim() + "', '" + emailtxt.Text.Trim() + "') ;";
                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.ExecuteNonQuery();
                    con.Close();

                    MessageBox.Show("New Vendor has been added!");
                    this.Close();


                    if (SV == null)
                    {
                        SV             = new SearchVendor();
                        SV.MdiParent   = this.MdiParent;
                        SV.FormClosed += new FormClosedEventHandler(SV_FormClosed);
                        SV.Show();
                        //this.Close();
                    }
                    else
                    {
                        SV.Activate();
                        SV.FormClosed += new FormClosedEventHandler(SV_FormClosed);
                        SV.Show();
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Not appropriate values entered.");
                }
            }
            else
            {
                MessageBox.Show("Not all fields filled.");
            }
        }