Ejemplo n.º 1
0
        private void Functions_Delete()
        {
            try
            {
                if (!this.NVSQuyen_Core.RIGHT_DEL)
                {
                    NoteBox.Show("Bạn không có quyền sử dụng chức năng này.", "Thông báo", NoteBoxLevel.Note);
                    return;
                }
                FunctionsInfo _FunctionsInfo = new FunctionsInfo();
                _FunctionsInfo = (FunctionsInfo)dgFunctions.SelectedItem;

                ArrayList arrdelete = new ArrayList();
                arrdelete.Add(_FunctionsInfo);
                BuidlTreeFuction(_FunctionsInfo, (ArrayList)dgFunctions.ItemsSource, ref arrdelete);

                if (arrdelete.Count > 0)
                {
                    MessageBoxResult rs = NoteBox.Show("Bạn có muốn xóa chức năng này hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (rs == MessageBoxResult.Yes)
                    {
                        foreach (FunctionsInfo item in arrdelete)
                        {
                            c_FunctionsController.Function_Delete(item.id, item.name);
                        }
                        NoteBox.Show("Xóa dữ liệu thành công", "", NoteBoxLevel.Note);
                        LoadData();
                        if (dgFunctions.Items.Count > 0)
                        {
                            dgFunctions.SelectedIndex = 0;
                        }
                        dgFunctions.Focus();
                    }
                    else if (rs == MessageBoxResult.No)
                    {
                        dgFunctions.Focus();
                    }
                }
                else
                {
                    NoteBox.Show("Bạn chưa chọn dòng muốn xóa. Hãy chọn lại", "Thông báo", NoteBoxLevel.Note);
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }