Example #1
0
        private void dgvContact_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string firstName, lastName, fullName;

            string[] arrName;
            string[] lastArr = new string[2];
            int      n       = dgvContact.CurrentRow.Index;

            fullName = dgvContact.Rows[n].Cells["FullName"].Value.ToString().Trim();
            arrName  = InternalGui.TachChuoi(fullName);

            for (int i = 0; i < arrName.Length - 1; i++)
            {
                lastArr[0] += " " + arrName[i];
                lastArr[1]  = arrName[arrName.Length - 1];
            }

            firstName         = lastArr[0];
            lastName          = lastArr[1];
            btnDelete.Enabled = true;
            btnUpdate.Enabled = false;
            TextDisable();

            txtID.Text        = dgvContact.Rows[n].Cells["ID"].Value.ToString();
            txtFirstName.Text = firstName;
            txtLastName.Text  = lastName;
            txtAddress.Text   = dgvContact.Rows[n].Cells["Address"].Value.ToString().Trim();
            txtPhone.Text     = dgvContact.Rows[n].Cells["Phone"].Value.ToString().Trim();
            txtGroup.Text     = dgvContact.Rows[n].Cells["Group"].Value.ToString();
        }
Example #2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string fullName = InternalGui.NoiChuoi(txtFirstName.Text, txtLastName.Text);
            bool   inserted = NewContactBus.Insert(fullName, txtGroup.Text, txtAddress.Text, txtPhone.Text);

            if (inserted)
            {
                MessageBox.Show("Insert successful");
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Example #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string fullName = InternalGui.NoiChuoi(txtFirstName.Text, txtLastName.Text);
            bool   updated  = objBus.Update(int.Parse(txtID.Text), fullName, txtGroup.Text, txtAddress.Text, txtPhone.Text);

            if (updated)
            {
                MessageBox.Show("Update successful");
                FrmContact_Load(sender, e);
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }