示例#1
0
        private void btnSaveNew_Click(object sender, EventArgs e)
        {
            PersonalContact personalContact = new PersonalContact();

            personalContact.ContactFName    = tbFname.Text;
            personalContact.ContactLName    = tbLname.Text;
            personalContact.ContactAddress  = tbAddress.Text;
            personalContact.ContactPostcode = tbPostcode.Text;
            personalContact.ContactCity     = tbCity.Text;
            personalContact.ContactCompany  = tbCompany.Text;
            personalContact.ContactEmail    = tbEmail.Text;
            personalContact.ContactTel      = tbConTel.Text;
            personalContact.PersonalHomeTel = tbHomeTel.Text;
            dbConn.InsertPersonal(personalContact);
            tbFname.Enabled        = false;
            tbLname.Enabled        = false;
            tbAddress.Enabled      = false;
            tbPostcode.Enabled     = false;
            tbCity.Enabled         = false;
            tbCompany.Enabled      = false;
            tbEmail.Enabled        = false;
            tbConTel.Enabled       = false;
            tbHomeTel.Enabled      = false;
            btnUpdate.Enabled      = true;
            btnDelete.Enabled      = true;
            btnSaveNew.Enabled     = true;
            DGBpersonal.DataSource = dbConn.getAllPersonal();
        }
示例#2
0
        private void btnSaveSelected_Click(object sender, EventArgs e)
        {
            int             index           = Int32.Parse(DGBpersonal.SelectedCells[0].Value.ToString());
            PersonalContact personalContact = new PersonalContact();

            personalContact.ContactID       = index;
            personalContact.ContactFName    = tbFname.Text;
            personalContact.ContactLName    = tbLname.Text;
            personalContact.ContactAddress  = tbAddress.Text;
            personalContact.ContactPostcode = tbPostcode.Text;
            personalContact.ContactCity     = tbCity.Text;
            personalContact.ContactCompany  = tbCompany.Text;
            personalContact.ContactEmail    = tbEmail.Text;
            personalContact.ContactTel      = tbConTel.Text;
            personalContact.PersonalHomeTel = tbHomeTel.Text;
            dbConn.UpdatePersonal(personalContact);
            DGBpersonal.DataSource  = dbConn.getAllPersonal();
            tbFname.Enabled         = false;
            tbLname.Enabled         = false;
            tbAddress.Enabled       = false;
            tbPostcode.Enabled      = false;
            tbCity.Enabled          = false;
            tbCompany.Enabled       = false;
            tbEmail.Enabled         = false;
            tbConTel.Enabled        = false;
            tbHomeTel.Enabled       = false;
            btnUpdate.Enabled       = true;
            btnDelete.Enabled       = true;
            btnSaveSelected.Enabled = false;
            btnAddNew.Enabled       = true;
        }
示例#3
0
        public void InsertPersonal(PersonalContact personalContact)
        {
            using (var conn = new MySqlConnection(connString))

            {
                conn.Open();
                using (var cmd = new MySqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = "CALL insertPersonal (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9);";
                    cmd.Parameters.AddWithValue("p1", personalContact.ContactFName);
                    cmd.Parameters.AddWithValue("p2", personalContact.ContactLName);
                    cmd.Parameters.AddWithValue("p3", personalContact.ContactAddress);
                    cmd.Parameters.AddWithValue("p4", personalContact.ContactPostcode);
                    cmd.Parameters.AddWithValue("p5", personalContact.ContactCity);
                    cmd.Parameters.AddWithValue("p6", personalContact.ContactCompany);
                    cmd.Parameters.AddWithValue("p7", personalContact.ContactEmail);
                    cmd.Parameters.AddWithValue("p8", personalContact.ContactTel);
                    cmd.Parameters.AddWithValue("p9", personalContact.PersonalHomeTel);
                    cmd.ExecuteNonQuery();
                }
            }
        }