// Sự kiện load dgv_TienCong
        private void dgv_load()
        {
            DataTable dt = new DataTable();

            dt = TIENCONG_DAO.LietKeTienCong();
            dgvTienCong.DataSource = dt;
            for (int i = 0; i < dgvTienCong.Rows.Count - 1; i++)
            {
                dgvTienCong.Rows[i].Cells[0].Value = i + 1;
            }
        }
        // sự kiện nhấn nút lưu
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string ten;
            int    tien;

            if (btnNew.Enabled || btnUpdate.Enabled)
            {
                if (txtTenTienCong.Text.ToString() == "")
                {
                    MessageBox.Show("Chưa nhập tên tiền công");
                }
                else
                {
                    ten = Convert.ToString(txtTenTienCong.Text);
                }
                if (txtTienCong.Text != null)
                {
                    int n = 0;
                    if (int.TryParse(this.txtTienCong.Text, out n))
                    {
                        tien = Convert.ToInt32(txtTienCong.Text);
                        TIENCONG_DTO tc  = new TIENCONG_DTO(txtTenTienCong.Text, tien);
                        TIENCONG_DTO tc1 = new TIENCONG_DTO(Convert.ToInt32(txtMaTienCong.Text), txtTenTienCong.Text, tien);
                        if (btnNew.Enabled)
                        {
                            DialogResult dr;
                            dr = MessageBox.Show("Bạn có muốn thêm loại tiền công '" + txtTenTienCong.Text + "' hay không ?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                            if (dr == DialogResult.OK)
                            {
                                TIENCONG_DAO.ThemTienCong(tc);
                            }
                            dgv_load();
                            dgvTienCong.CurrentCell         = dgvTienCong.Rows[dgvTienCong.Rows.Count - 2].Cells[0];
                            dgvTienCong.CurrentRow.Selected = true;
                            txtMaTienCong.Text  = Convert.ToString(dgvTienCong.Rows[dgvTienCong.Rows.Count - 2].Cells["MaTienCong"].Value);
                            txtTenTienCong.Text = Convert.ToString(dgvTienCong.Rows[dgvTienCong.Rows.Count - 2].Cells["TenTienCong"].Value);
                            txtTienCong.Text    = Convert.ToString(dgvTienCong.Rows[dgvTienCong.Rows.Count - 2].Cells["TienCong"].Value);
                        }
                        if (btnUpdate.Enabled)
                        {
                            DialogResult dr;
                            dr = MessageBox.Show("Bạn có muốn cập nhật loại tiền công '" + txtTenTienCong.Text + "' hay không ?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                            if (dr == DialogResult.OK)
                            {
                                TIENCONG_DAO.CapNhatTienCong(tc1);
                            }
                            dgv_load();
                            dgvTienCong.CurrentCell         = dgvTienCong.Rows[ChiMuc].Cells[0];
                            dgvTienCong.CurrentRow.Selected = true;
                            txtMaTienCong.Text  = Convert.ToString(dgvTienCong.Rows[ChiMuc].Cells["MaTienCong"].Value);
                            txtTenTienCong.Text = Convert.ToString(dgvTienCong.Rows[ChiMuc].Cells["TenTienCong"].Value);
                            txtTienCong.Text    = Convert.ToString(dgvTienCong.Rows[ChiMuc].Cells["TienCong"].Value);
                        }
                    }
                    else
                    {
                        if (txtTienCong.Text.ToString() != "")
                        {
                            MessageBox.Show("Số tiền phải là ký số");
                        }
                    }
                }
                btnSave.Enabled         = false;
                btnNew.Enabled          = true;
                btnNew.Enabled          = true;
                txtMaTienCong.ReadOnly  = true;
                txtTenTienCong.ReadOnly = true;
                txtTienCong.ReadOnly    = true;
            }
        }