private void XoaCauTraLoiGayNhieu(object sender, EventArgs e)
        {
            if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu trả lời gây nhiễu này không ?", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            DevExpress.XtraEditors.SimpleButton button = sender as DevExpress.XtraEditors.SimpleButton;
            TableLayoutPanel tblPanelDapAn             = button.Parent as TableLayoutPanel;
            int rowIndex = tblPanelMain2.GetRow(tblPanelDapAn);

            //get id cau hoi bi xoa
            int idCauTraLoiBiXoa = Convert.ToInt32(button.Tag);
            //IDEx xác định id ex de xoa trong list cau tra loi
            int idEx           = Convert.ToInt32(tblPanelDapAn.Tag);
            var cauTraLoiBiXoa = CauHoiCurent.ListCauTraLoi.FirstOrDefault(m => m.IdEx == idEx);

            CauHoiCurent.ListCauTraLoi.Remove(cauTraLoiBiXoa);

            //neu khac 0 la cau hoi da ton tai, can xoa
            if (idCauTraLoiBiXoa != 0)
            {
                ListIdCauTraLoiBiXoa.Add(idCauTraLoiBiXoa);
            }

            //remove old controls
            foreach (Control ctrl in tblPanelDapAn.Controls)
            {
                ctrl.Dispose();
            }
            tblPanelDapAn.Controls.Clear();
            tblPanelDapAn.Dispose();

            tblPanelMain2.Controls.Remove(tblPanelDapAn);
            _lstTablePanelGayNhieu.Remove(tblPanelDapAn);

            //decrease row index of panels down 2
            //rename panel
            for (int i = rowIndex + 2; i < tblPanelMain2.RowStyles.Count; i = i + 2)
            {
                tblPanelDapAn = tblPanelMain2.Controls[_nameTablePanelDapAn + i] as TableLayoutPanel;

                if (tblPanelDapAn != null)
                {
                    tblPanelMain2.SetRow(tblPanelDapAn, i - 2);
                    tblPanelDapAn.Name = _nameTablePanelDapAn + (i - 2);
                }
            }

            //remove 2 last rows
            tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2);
            tblPanelMain2.RowCount--;
            tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2);
            tblPanelMain2.RowCount--;
            IsChanged = true;
        }
        private void XoaCauHoiCon(object sender, EventArgs e)
        {
            //Nếu trái it nhất phải = 1
            if (_lstTablePanelCauHoi.Count == 2)
            {
                UICommon.ShowMsgWarningString("Số câu hỏi con không được nhỏ hơn 2 \nBạn không thể xóa!");
                return;
            }

            if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu hỏi này không ?") != DialogResult.Yes)
            {
                return;
            }

            SimpleButton     button        = sender as SimpleButton;
            TableLayoutPanel tblPanelDapAn = button.Parent as TableLayoutPanel;
            int rowIndex = tblPanelMain.GetRow(tblPanelDapAn);

            //get id cau hoi bi xoa
            int idEx = Convert.ToInt32(button.Tag);

            //neu khac 0 la cau hoi da ton tai, can xoa
            var cauHoi = CauHoiCurent.ListCauHoi.FirstOrDefault(m => m.IDEx == idEx);

            if (cauHoi != null && cauHoi.Id > 0)
            {
                ListIdCauHoiBiXoa.Add((int)cauHoi.Id);
                ListIdCauTraLoiBiXoa.Add((int)cauHoi.ListCauTraLoi.FirstOrDefault()?.Id);

                IsChanged = true;
            }

            //remove old controls
            foreach (Control ctrl in tblPanelDapAn.Controls)
            {
                ctrl.Dispose();
            }
            tblPanelDapAn.Controls.Clear();
            tblPanelDapAn.Dispose();

            tblPanelMain.Controls.Remove(tblPanelDapAn);
            _lstTablePanelCauHoi.Remove(tblPanelDapAn);

            //decrease row index of panels down 2
            //rename panel
            for (int i = rowIndex + 2; i < tblPanelMain.RowStyles.Count; i = i + 2)
            {
                tblPanelDapAn = tblPanelMain.Controls[_nameTablePanelCauHoi + i] as TableLayoutPanel;

                if (tblPanelDapAn != null)
                {
                    tblPanelMain.SetRow(tblPanelDapAn, i - 2);
                    tblPanelDapAn.Name = _nameTablePanelCauHoi + (i - 2);
                }
            }

            //remove 2 last rows
            tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2);
            tblPanelMain.RowCount--;
            tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2);
            tblPanelMain.RowCount--;

            // Reset text
            this.ResetTextCauTraLoi();
            ResizeLayoutCauTraLoi(false);
        }