コード例 #1
0
        private void btmUpdate_Click(object sender, EventArgs e)
        {
            //get the data from the text box and update it in the field
            c.ContactID = int.Parse(txtboxContactID.Text);
            c.FirstName = txtboxFirstName.Text;
            c.LastName  = txtboxLastName.Text;
            c.ContactNo = txtboxContactNo.Text;
            c.Address   = txtboxAddress.Text;
            c.Gender    = cmbGender.Text;
            //update data in the database

            bool success = c.Update(c);

            if (success == true)
            {
                //succussfully updated
                MessageBox.Show("Contact Successfully Updated");
            }
            else
            {
                //Failed to update contact
                MessageBox.Show("Failed to update the Contact. Try Again");
            }

            //Load data in the grid view
            DataTable dt = c.Select();

            dgvContactList.DataSource = dt;

            //Call the clear method
            Clear();
        }
コード例 #2
0
        // Click event for Update Button
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            // Get the data from textboxes
            c.ContactID = int.Parse(textBoxContactID.Text);
            c.FirstName = textBoxFirstName.Text;
            c.LastName  = textBoxLastName.Text;
            c.ContactNo = textBoxContactNumber.Text;
            c.Address   = textBoxAddress.Text;
            c.Gender    = cmbGender.Text;

            // Update data into db
            bool success = c.Update(c);

            if (success == true)
            {
                // Updated successfully
                MessageBox.Show("Contact had been updated successfully");

                // Load data on Data GridView
                DataTable dt = c.Select();
                dgvContactList.DataSource = dt;

                // Clear fields
                Clear();
            }
            else
            {
                // Failed to update
                MessageBox.Show("Failed to update contact. Try again!");
            }
        }
コード例 #3
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            //Get the data from the text boxes
            c.ContactID   = int.Parse(contactIDForm.Text);
            c.LastName    = lastNameForm.Text;
            c.FirstName   = firstNameForm.Text;
            c.PhoneNumber = phoneNumberForm.Text;
            c.Address     = addressForm.Text;

            //Update data in the database
            bool updateSuccess = c.Update(c);

            if (updateSuccess)
            {
                MessageBox.Show("Contact successfully updated!");
                //Load updated database in the GridView
                DataTable dt = c.Select();
                contactList.DataSource = dt;

                Clear();
            }
            else
            {
                MessageBox.Show("Error updating contact! Please try again.");
            }
        }
コード例 #4
0
ファイル: Econtact.cs プロジェクト: jacobgoredema/E-Contact
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            // Get the data from the textbox.
            model.ContactId = int.Parse(txtContactId.Text);
            model.Firstname = txtName.Text;
            model.Lastname  = txtLastname.Text;
            model.Phone     = txtNumber.Text;
            model.Address   = txtAddress.Text;
            model.Gender    = cboGender.Text;

            //update data in database
            bool isSuccess = model.Update(model);

            if (isSuccess == true)
            {
                MessageBox.Show("Contact has ben successfully updated.", "Contact Update", MessageBoxButtons.OK, MessageBoxIcon.Information);

                DataTable dataTable = model.Select();
                dataGridView.DataSource = dataTable;

                Clear();
            }
            else
            {
                MessageBox.Show("Failed to update Contact, please try again.", "Updated Failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: AContact.cs プロジェクト: rickadams2/AContactApp
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            // Get the data from textboxes
            c.ContactID = int.Parse(tbContactID.Text);
            c.FirstName = tbFirstName.Text;
            c.LastName  = tbLastName.Text;
            c.Phone     = maskedTextBox1.Text;
            c.Email     = tbEmail.Text;
            c.Note      = tbNote.Text;
            c.Status    = cmbStatus.Text;
            // Update data in database
            bool success = c.Update(c);

            if (success == true)
            {
                // Updated succesfully
                MessageBox.Show("Contact has been succesfully Updated");
                // Load data on Data Gridview
                DataTable dt = c.Select();
                dgvContactList.DataSource = dt;
                // Call Clear Method

                Clear();
            }
            else
            {
                // Failed to Update
                MessageBox.Show("Failed to update. Try again.");
            }
        }
コード例 #6
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            //Get the Data from textboxes
            c.ContactID = int.Parse(txtboxContactID.Text);
            c.FirstName = txtboxFirstName.Text;
            c.LastName  = txtboxLastName.Text;
            c.ContactNo = txtboxContactNumber.Text;
            c.Address   = txtboxAddress.Text;
            c.Gender    = cmbGender.Text;
            //Update DAta in Database
            bool success = c.Update(c);

            if (success == true)
            {
                //Updated Successfully
                MessageBox.Show("Contact has been successfully Updated.", "EContact", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //Load Data on Data GRidview
                DataTable dt = c.Select();
                dgvContactList.DataSource = dt;
                //Call Clear Method
                Clear();
            }
            else
            {
                //Failed to Update
                MessageBox.Show("Failed to Update Contact.Try Again.", "EContact", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #7
0
ファイル: EContact.cs プロジェクト: raj2784/EContact
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //get update from text boxes
            cc.ContactId = int.Parse(txtboxContactID.Text);
            cc.FirstName = txtboxFirstName.Text;
            cc.LastName  = txtboxLastName.Text;
            cc.Mobile    = txtboxMobile.Text;
            cc.Email     = txtboxEmail.Text;
            cc.Gender    = cmbGender.Text;
            cc.Address   = txtboxAddress.Text;
            //to update data in DB
            bool success = cc.Update(cc);

            if (success == true)
            {
                MessageBox.Show("Contact has been Updated Successfully!");
                Clear();
            }
            else
            {
                MessageBox.Show("Failed to update Contact. please try again!");
            }
            //loading Data to grid-view
            DataTable dt = cc.Select();

            dgvContactlist.DataSource = dt;
        }
コード例 #8
0
        //Update data to database
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            contact.ContactId = int.Parse(txtboxcontactid.Text);
            contact.FirstName = txtboxFirstName.Text;
            contact.LastName  = txtboxLastName.Text;
            contact.ContactNo = txtboxContactNo.Text;
            contact.Address   = txtboxAddress.Text;
            contact.Gender    = txtboxGender.SelectionBoxItem.ToString();

            string        myconstring   = Properties.Settings.Default.constr;
            SqlConnection sqlConnection = new SqlConnection(myconstring);

            sqlConnection.Open();


            bool success = contact.Update(contact);

            if (success == true)
            {
                MessageBox.Show("New Contact updated succesfully");
                Clear();
            }
            else
            {
                MessageBox.Show("Failed to update, Try Again");
            }

            Select();
        }
コード例 #9
0
        private void btnUbdate_Click(object sender, EventArgs e)
        {
            //get the Data from textBoxes
            c.ContactID = int.Parse(txtBoxContactID.Text);
            c.FirstName = txtBoxFirstName.Text;
            c.LastName  = txtBoxLastName.Text;
            c.ContactNo = txtBoxContactNumber.Text;
            c.Address   = txtBoxAddress.Text;
            c.Gender    = cmbGender.Text;
            //this to update the Data in  Database
            bool success = c.Update(c);

            if (success == true)
            {
                //the update is done
                MessageBox.Show("the Contact has been successfully Updated");
                //load Data on Data GRidview
                DataTable dt = c.Select();
                dgvContactList.DataSource = dt;
                // call the clear method
                Clear();
            }
            else
            {
                //Failed to update
                MessageBox.Show("Failed to Update the Contact");
            }
        }
コード例 #10
0
        //Method to UPDATE data
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            //get data from textboxes
            c.IdAbonat      = int.Parse(txtIdAbonat.Text);
            c.Cod_Tipologie = cmbCategorie.Text;
            c.Nume          = txtNume.Text;
            c.Prenume       = txtPrenume.Text;
            c.Tel           = txtTel.Text;
            c.Email         = txtEmail.Text;

            //UPDATE data  in db
            bool success = c.Update(c);

            if (success == true)
            {
                //succesful update
                MessageBox.Show("Actualizare reusita!");
                DataTable dt = c.Select();
            }
            else
            {
                //failed update
                MessageBox.Show("Actualizare esuata");
            }
        }
コード例 #11
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //getting th data from textboxes
            c.ContactID = int.Parse(txtboxContactID.Text);
            c.Firstname = txtboxFirstName.Text;
            c.ContactNo = txtboxContactNumber.Text;
            c.Address   = txtboxAddress.Text;
            c.Gender    = cmbGender.Text;

            //update data in the database
            bool success = c.Update(c);

            if (success == true)
            {
                //success
                MessageBox.Show("Contact has been Successfully updated");

                //load data on DataGridView
                DataTable dt = c.Select();
                dgvContactList.DataSource = dt;

                //clear
                clear();
            }
            else
            {
                MessageBox.Show("Failed to update Contact. Try Again !");
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: imsajid12/ContactHub
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                //Getting data from textboxes
                cc.ContactID = int.Parse(tbContactID.Text);
                cc.FirstName = tbFirstName.Text;
                cc.LastName  = tbLastName.Text;
                cc.EmailId   = tbEmailId.Text;
                cc.ContactNo = tbContactNo.Text;
                cc.Address   = tbAddress.Text;
                cc.Gender    = cmbGender.Text;

                //Updating data in database using Update() method.
                bool Success = cc.Update(cc);
                if (Success == true)
                {
                    MessageBox.Show("Contact has been successfully updated", "Contact Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Load Data in data grid view
                    DataTable Dt = cc.Select();
                    dgvContactList.DataSource = Dt;
                }
                else
                {
                    MessageBox.Show("Failed to update contact, Please try again", "Error in Updation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //Call Method to clear fields
                Clear();

                //Set focus on FrstName textbox
                tbFirstName.Focus();
            }
            catch (Exception)
            {
                MessageBox.Show("To update a contact, You need to select it from the contact list", "Select Contact", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #13
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            c.ContactID  = int.Parse(textBoxContactID.Text);
            c.FirstName  = textBoxFirstName.Text;
            c.LastName   = textBoxLastName.Text;
            c.ConstactNo = textBoxContactNo.Text;
            c.Address    = textBoxAddress.Text;
            c.Gender     = comboBoxGender.Text;

            bool success = c.Update(c);

            if (success == true)
            {
                MessageBox.Show("Contact has been Successfully Updated.");
                DataTable dt = c.Select();
                dataGridViewContactList.DataSource = dt;
                Clear();
            }
            else
            {
                MessageBox.Show("Failed to Update Contact. Try Again.");
            }
        }
コード例 #14
0
ファイル: Econtact.cs プロジェクト: MichaelKilley/Econtact
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            c.ContactID = int.Parse(txtContactID.Text);
            c.FirstName = (txtFirstName.Text).Trim();
            c.LastName  = (txtLastName.Text).Trim();
            c.TelNo     = (txtTelNo.Text).Trim();
            c.MobileNo  = (txtMobile.Text).Trim();
            c.Address   = (txtAddress.Text).Trim();
            c.Gender    = (cboGender.Text).Trim();

            // Update Datbase
            bool success = c.Update(c);

            if (success == true)
            {
                // updated successfully
                MessageBox.Show("Contact has been successfully updated");
                LoadData();
            }
            else
            {
                MessageBox.Show("Contact failed to Update");
            }
        }