Exemplo n.º 1
0
        /// <summary>
        /// 创建选择的数据
        /// </summary>
        private void DeleteSelectedData(object state)
        {
            bool   bIfSucc      = false;
            string strErrMessag = "未知错误";

            SetButtonEnabled(false);
            try
            {
                if (this._FormIfClose)
                {
                    return;
                }
                Model.SelecedTreeNodeData objSelecedTreeNodeData = (Model.SelecedTreeNodeData)state;
                if (!(objSelecedTreeNodeData.SelectedDataList == null || objSelecedTreeNodeData.SelectedDataList.Count == 0))
                {
                    IDAL.IBuilding objDalBuilding = DALFactory.DALFactory.Building();
                    IDAL.ISys      objDalSys      = DALFactory.DALFactory.Sys();
                    foreach (Model.NodeData objData in objSelecedTreeNodeData.SelectedDataList)
                    {
                        if (objData.Flag.Equals(-1))
                        {
                            //全部
                            bIfSucc = objDalSys.DeleteData(0);
                        }
                        else if (objData.Flag >= 0 && objData.Flag <= 3)
                        {
                            bool bSucc = objDalBuilding.Delete(objData.ID);
                            if (bSucc)
                            {
                                bIfSucc = bSucc;
                            }
                        }
                    }
                }
                if (bIfSucc)
                {
                    InitTree();
                }
            }
            catch (Exception err)
            {
                strErrMessag = err.Message;
            }
            if (bIfSucc)
            {
                RefreshTreeByThread();
            }
            SetButtonEnabled(true);
            if (bIfSucc)
            {
                CMessageBox.ShowSucc("恭喜您,删除成功!", Config.DialogTitle);
                //当建筑信息删除时,通知其他已开启的树
                Manager.GetInstance().BuildingDataChangeNotice();
            }
            else
            {
                CMessageBox.ShowError(string.Format("对不起,删除失败,错误原因:\r\n{0}", strErrMessag), Config.DialogTitle);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建全部数据
        /// </summary>
        private void DeleteAllData(object state)
        {
            bool   bIfSucc      = false;
            string strErrMessag = "未知错误";

            SetButtonEnabled(false);
            try
            {
                if (this._FormIfClose)
                {
                    return;
                }
                IDAL.ISys objDal = DALFactory.DALFactory.Sys();
                bIfSucc = objDal.DeleteData(0);
                if (bIfSucc)
                {
                    InitTree();
                }
            }
            catch (Exception err)
            {
                strErrMessag = err.Message;
            }
            if (bIfSucc)
            {
                RefreshTreeByThread();
            }
            //SetButtonEnabled(true);
            if (bIfSucc)
            {
                CMessageBox.ShowSucc("恭喜您,删除成功!", Config.DialogTitle);
                //当建筑信息删除时,通知其他已开启的树
                //Manager.GetInstance().BuildingDataChangeNotice();
            }
            else
            {
                CMessageBox.ShowError(string.Format("对不起,删除失败,错误原因:\r\n{0}", strErrMessag), Config.DialogTitle);
            }
        }