Esempio n. 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            ///说明:表格保存流程
            ///1单个表格保存
            ///选择“组卷类别”,保存时,将文件和当前表格文件拷贝到归档类别下面
            /// 修改时,如果如果是当个表格就直接将文件条目,改变到新归档类别下
            ///
            ///2多个表格保存,就在多个目录下都创建一个目录,每个目录对应一个电子表格
            ///
            ///3文件保存
            ///3.1 将文件下所有表格指定到同目录下
            ///3.2 将没有设置目录的表格指定到一个目录下
            ///

            _gdID = getCheckBoxID();
            if (string.IsNullOrEmpty(_gdID))
            {
                TXMessageBoxExtensions.Info("提示:请选择归档类别!");
                return;
            }
            else
            {
                if (_a_flg == 1)//单个表格
                {
                    #region
                    BLL.T_FileList_BLL     File_BLL = new BLL.T_FileList_BLL();
                    BLL.T_CellAndEFile_BLL Cell_BLL = new BLL.T_CellAndEFile_BLL();
                    MDL.T_CellAndEFile     cell_MDL = Cell_BLL.Find(_CellID, Globals.ProjectNO);
                    MDL.T_FileList         File_MDL = File_BLL.Find(_FileID, Globals.ProjectNO);

                    if (cell_MDL != null && File_MDL != null)
                    {
                        //判断是否存在以前的记录
                        if (string.IsNullOrEmpty(cell_MDL.GdFileID))
                        {
                            //无记录,第一次直接添加
                            SaveInfo(1, File_MDL, cell_MDL, File_BLL, Cell_BLL);
                        }
                        else
                        {
                            ///存在记录
                            ///如果只有当前电子表格的,就将文件一起修改到最新归档目录下
                            ///如果文件目录下有多个表格,就再创建一条记录,最后一条记录,就修改文件归档类别
                            IList <MDL.T_CellAndEFile> CellMDL_list =
                                Cell_BLL.FindByGdFileID(cell_MDL.GdFileID, Globals.ProjectNO);

                            if (CellMDL_list != null && CellMDL_list.Count > 0)
                            {
                                if (CellMDL_list.Count == 1)
                                {
                                    ///一条记录,多条改成一条,只要是最后一个电子文件,调整时,就是将文件归档分类修改
                                    MDL.T_FileList FileCheck_MDL = File_BLL.Find(cell_MDL.GdFileID, Globals.ProjectNO);
                                    if (FileCheck_MDL != null)
                                    {
                                        SaveInfo(2, FileCheck_MDL, null, File_BLL, null);
                                    }
                                    else
                                    {
                                        ///记录不存在,重新创建
                                        SaveInfo(1, File_MDL, cell_MDL, File_BLL, Cell_BLL);
                                    }
                                }
                                else if (CellMDL_list.Count > 1)
                                {
                                    ///多条记录 ,产生一条,新的文件条目,将电子文件挂到当前条目下
                                    SaveInfo(1, File_MDL, cell_MDL, File_BLL, Cell_BLL);
                                }
                            }
                        }
                        TXMessageBoxExtensions.Info("提示:保存成功!");
                        this.Close();
                    }
                    #endregion
                }
                else if (_a_flg == 2)//多个表格
                {
                    #region
                    BLL.T_FileList_BLL     File_BLL = new BLL.T_FileList_BLL();
                    BLL.T_CellAndEFile_BLL Cell_BLL = new BLL.T_CellAndEFile_BLL();
                    MDL.T_FileList         File_MDL = File_BLL.Find(_FileID, Globals.ProjectNO);

                    if (File_MDL != null)
                    {
                        SaveInfo(3, File_MDL, null, File_BLL, Cell_BLL);
                        TXMessageBoxExtensions.Info("提示:保存成功!");
                        this.Close();
                    }
                    #endregion
                }
                else if (_a_flg == 3)//文件
                {
                    #region
                    BLL.T_FileList_BLL     File_BLL = new BLL.T_FileList_BLL();
                    BLL.T_CellAndEFile_BLL Cell_BLL = new BLL.T_CellAndEFile_BLL();
                    MDL.T_FileList         File_MDL = File_BLL.Find(_FileID, Globals.ProjectNO);
                    ArrayList gdFileList            = new ArrayList();

                    if (File_MDL != null)
                    {
                        IList <MDL.T_CellAndEFile> CellMDL_list =
                            Cell_BLL.FindByFileIDAndNOCell(_FileID, Globals.ProjectNO);

                        if (CellMDL_list != null && CellMDL_list.Count > 0)
                        {
                            File_MDL.FromFileID       = File_MDL.FileID;
                            File_MDL.FileID           = Guid.NewGuid().ToString();
                            File_MDL.GDID             = _gdID;
                            File_MDL.FL               = 1;
                            File_MDL.GdFileOrderIndex =
                                File_BLL.GetMaxGdFileOrderIndex(File_MDL.GDID, Globals.ProjectNO) + 1;
                            File_BLL.Add(File_MDL);

                            foreach (MDL.T_CellAndEFile cell_m in CellMDL_list)
                            {
                                if (!string.IsNullOrEmpty(cell_m.GdFileID))
                                {
                                    gdFileList.Add(cell_m.GdFileID);
                                }

                                cell_m.GdFileID     = File_MDL.FileID;
                                cell_m.GdOrderIndex =
                                    Cell_BLL.GetMaxGdFileOrderIndex(cell_m.GdFileID, Globals.ProjectNO) + 1;
                                Cell_BLL.Update(cell_m);
                            }
                        }
                        //表格更新完成之后,再删除
                        for (int i = 0; i < gdFileList.Count; i++)
                        {
                            string gdf_id = gdFileList[i].ToString();

                            MDL.T_FileList file_mdl_del =
                                File_BLL.Find(gdf_id, Globals.ProjectNO);

                            if (file_mdl_del != null)
                            {
                                IList <MDL.T_CellAndEFile> CellMDL_checklist =
                                    Cell_BLL.FindByGdFileID(gdf_id, Globals.ProjectNO);

                                if (CellMDL_checklist == null ||
                                    CellMDL_checklist.Count == 0)
                                {
                                    //文件条目只有一条记录的,就删掉
                                    File_BLL.Delete(file_mdl_del);
                                }
                            }
                        }
                    }
                    #endregion
                }
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private void SaveInfo(int a_flg, MDL.T_FileList File_MDL, MDL.T_CellAndEFile Cell_MDL,
                              BLL.T_FileList_BLL File_BLL, BLL.T_CellAndEFile_BLL Cell_BLL)
        {
            switch (a_flg)
            {
            case 1:    //首次或多条记录 添加
                File_MDL.ParentID         = _gdID;
                File_MDL.FromFileID       = File_MDL.FileID;
                File_MDL.FileID           = Guid.NewGuid().ToString();
                File_MDL.GDID             = _gdID;
                File_MDL.FL               = 1;
                File_MDL.GdFileOrderIndex =
                    File_BLL.GetMaxGdFileOrderIndex(File_MDL.GDID, Globals.ProjectNO) + 1;
                File_BLL.Add(File_MDL);
                if (Cell_MDL != null)
                {
                    Cell_MDL.GdFileID     = File_MDL.FileID;
                    Cell_MDL.DoStatus     = 1;
                    Cell_MDL.GdOrderIndex =
                        Cell_BLL.GetMaxGdFileOrderIndex(Cell_MDL.GdFileID, Globals.ProjectNO) + 1;
                    Cell_BLL.Update(Cell_MDL);

                    //添加原文信息
                    if (File.Exists(Globals.ProjectPath + Cell_MDL.filepath))
                    {
                        MyCommon.InsertOldEfile(Cell_MDL.CellID, Globals.ProjectNO, Globals.LoginUser, "资料用表-保存并归档-首次或多条记录 添加", Globals.ProjectPath + Cell_MDL.filepath);
                    }
                }
                break;

            case 2:    //一条记录,修改文件级
                File_MDL.GDID             = _gdID;
                File_MDL.GdFileOrderIndex =
                    File_BLL.GetMaxGdFileOrderIndex(File_MDL.GDID, Globals.ProjectNO) + 1;
                File_BLL.Update(File_MDL);
                break;

            case 3:    //多个表格设置 以前的文件条目是否要删除?还是不动
                File_MDL.ParentID   = _gdID;
                File_MDL.FromFileID = File_MDL.FileID;
                File_MDL.FileID     = Guid.NewGuid().ToString();
                File_MDL.GDID       = _gdID;
                File_MDL.FL         = 1;
                File_BLL.Add(File_MDL);

                ArrayList gdFileList = new ArrayList();

                string[] cell_list = _CellID.Split(new char[] { ';' });
                foreach (string c_id in cell_list)
                {
                    if (c_id != null && c_id.Trim() == "")
                    {
                        continue;
                    }

                    MDL.T_CellAndEFile cell_m =
                        Cell_BLL.Find(c_id, Globals.ProjectNO);

                    if (!string.IsNullOrWhiteSpace(cell_m.GdFileID))
                    {
                        gdFileList.Add(cell_m.GdFileID);
                    }

                    if (cell_m != null)
                    {
                        cell_m.GdFileID     = File_MDL.FileID;
                        cell_m.DoStatus     = 1;
                        cell_m.GdOrderIndex =
                            Cell_BLL.GetMaxGdFileOrderIndex(cell_m.GdFileID, Globals.ProjectNO) + 1;
                        Cell_BLL.Update(cell_m);

                        //添加原文信息
                        if (File.Exists(Globals.ProjectPath + cell_m.filepath))
                        {
                            MyCommon.InsertOldEfile(cell_m.CellID, Globals.ProjectNO, Globals.LoginUser, "资料用表-保存并归档-多个表格设置", Globals.ProjectPath + cell_m.filepath);
                        }
                    }
                }
                //修改前可以判断下文件级,如果要删除,就在修改前删除
                //表格更新完成之后,再删除
                for (int i = 0; i < gdFileList.Count; i++)
                {
                    string         gdf_id       = gdFileList[i].ToString();
                    MDL.T_FileList file_mdl_del =
                        File_BLL.Find(gdf_id, Globals.ProjectNO);

                    if (file_mdl_del != null)
                    {
                        IList <MDL.T_CellAndEFile> CellMDL_checklist =
                            Cell_BLL.FindByGdFileID(gdf_id, Globals.ProjectNO);

                        if (CellMDL_checklist == null ||
                            CellMDL_checklist.Count == 0)
                        {
                            //文件条目只有一条记录的,就删掉
                            File_BLL.Delete(file_mdl_del);
                        }
                    }
                }
                break;
            }
        }