示例#1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            bool is_Check = false;

            foreach (TreeNode c_node in tv_Info.Nodes[0].Nodes)
            {
                if (c_node.Checked)
                {
                    is_Check = true;
                    break;
                }
            }
            if (!is_Check)
            {
                TXMessageBoxExtensions.Info("请选择需要删除的记录!");
                return;
            }

            //if (_frmFileMain.axpdfInterface1.FileName != null && _frmFileMain.axpdfInterface1.FileName.Length > 0)
            //    _frmFileMain.axpdfInterface1.CloseFile();

            if (_Action_Flg == 1)
            {
                BLL.T_FileList_BLL     FileList_BLL     = new BLL.T_FileList_BLL();
                BLL.T_CellAndEFile_BLL CellAndEFile_BLL = new BLL.T_CellAndEFile_BLL();
                //归档类别
                DataTable tbl_FileInfo = FileList_BLL.GetFileByGDID(Globals.ProjectNO, _TNode.Name);

                foreach (TreeNode f_node in tv_Info.Nodes[0].Nodes)
                {
                    if (!f_node.Checked || f_node.ImageIndex == 4)
                    {
                        continue;
                    }
                    //归档类别
                    DataRow[] file_rows = tbl_FileInfo.Select("FileID='" + f_node.Name + "'");

                    if (file_rows != null && file_rows.Length > 0)
                    {
                        if (file_rows[0]["filepath"] != null && file_rows[0]["filepath"].ToString().Trim() != "")
                        {
                            if (System.IO.File.Exists(Globals.ProjectPath + file_rows[0]["filepath"].ToString()))
                            {
                                System.IO.File.Delete(Globals.ProjectPath + file_rows[0]["filepath"].ToString());
                            }
                        }
                        IList <MDL.T_CellAndEFile> cellList =
                            CellAndEFile_BLL.FindByGdFileID(f_node.Name, Globals.ProjectNO);

                        foreach (MDL.T_CellAndEFile cellMDL in cellList)
                        {
                            if (cellMDL != null &&
                                System.IO.File.Exists(Globals.ProjectPath + cellMDL.filepath) &&
                                !string.IsNullOrWhiteSpace(cellMDL.filepath) &&
                                cellMDL.filepath.EndsWith(".cll"))   //原件
                            {
                                cellMDL.GdFileID = "";
                                CellAndEFile_BLL.Update(cellMDL);
                            }
                            else
                            {
                                if (System.IO.File.Exists(Globals.ProjectPath + cellMDL.filepath))
                                {
                                    System.IO.File.Delete(Globals.ProjectPath + cellMDL.filepath);
                                }
                                if (System.IO.File.Exists(Globals.ProjectPath + cellMDL.fileTreePath))
                                {
                                    System.IO.File.Delete(Globals.ProjectPath + cellMDL.fileTreePath);
                                }

                                MyCommon.DeleteOldEfile(cellMDL.CellID, Globals.ProjectNO);  //删除电子文件对应的原文信息
                                CellAndEFile_BLL.Delete(cellMDL.CellID, Globals.ProjectNO);
                            }
                        }
                        FileList_BLL.Delete(f_node.Name, Globals.ProjectNO);
                    }
                }
            }
            else if (_Action_Flg == 2)
            {
                //删除电子文件
                BLL.T_CellAndEFile_BLL     CellAndEFile_BLL = new BLL.T_CellAndEFile_BLL();
                IList <MDL.T_CellAndEFile> cellList         =
                    CellAndEFile_BLL.FindByGdFileID(tv_Info.Nodes[0].Name, Globals.ProjectNO);

                foreach (TreeNode c_node in tv_Info.Nodes[0].Nodes)
                {
                    if (c_node.Checked)
                    {
                        MDL.T_CellAndEFile cellMDL = CellAndEFile_BLL.Find(c_node.Name, Globals.ProjectNO);

                        if (cellMDL != null &&
                            System.IO.File.Exists(Globals.ProjectPath + cellMDL.filepath) &&
                            !string.IsNullOrWhiteSpace(cellMDL.filepath) &&
                            cellMDL.filepath.EndsWith(".cll"))//原件
                        {
                            cellMDL.GdFileID = "";
                            CellAndEFile_BLL.Update(cellMDL);
                        }
                        else
                        {
                            if (System.IO.File.Exists(Globals.ProjectPath + cellMDL.filepath))
                            {
                                System.IO.File.Delete(Globals.ProjectPath + cellMDL.filepath);
                            }
                            if (System.IO.File.Exists(Globals.ProjectPath + cellMDL.fileTreePath))
                            {
                                System.IO.File.Delete(Globals.ProjectPath + cellMDL.fileTreePath);
                            }

                            MyCommon.DeleteOldEfile(cellMDL.CellID, Globals.ProjectNO);  //删除电子文件对应的原文信息
                            CellAndEFile_BLL.Delete(cellMDL.CellID, Globals.ProjectNO);
                        }
                    }
                }
            }
            TXMessageBoxExtensions.Info("删除成功!");
            this.DialogResult = DialogResult.OK;
        }