/// <summary>
        /// 显示文件,不包括PDF文件
        /// </summary>
        /// <param name="FileDataAttachmentGuid"></param>
        public void OpenFile(string FileDataAttachmentGuid)
        {
            FileDataManage FileDataManage = new FileDataManage();
            DataTable      dtl            = FileDataManage.GetFileDataAttachmentByAttachmentGuid(FileDataAttachmentGuid);

            if (dtl.Rows.Count > 0)
            {
                Byte[] bytes             = (Byte[])dtl.Rows[0]["FileContent"];
                string strFileSourceName = dtl.Rows[0]["FileSourceName"].ToString();

                Random ran = new Random();
                int    num = ran.Next(1, 10);

                //先将文件下载到本地
                txtFilePath.Text = Application.StartupPath + @"\FileAttachment\" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + num.ToString() + strFileSourceName;
                FileStream fs = new FileStream(txtFilePath.Text, FileMode.OpenOrCreate, FileAccess.Write);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();

                try
                {
                    //打开文件
                    Process p = new Process();
                    p.StartInfo.FileName  = txtFilePath.Text;
                    p.StartInfo.Arguments = "/FileAttachment";
                    p.Start();
                }
                catch
                {
                    this.ShowAlertMessage("当前文件无法打开,本地没有安装此文件的安装程序!");
                }
            }
        }
        private void btnSelectFileID_Click(object sender, EventArgs e)
        {
            frmSelectFile frmSelectFile = new frmSelectFile();

            frmSelectFile.ShowDialog();



            if (frmSelectFile.Tag != null)
            {
                //取出选择的文件Guid
                List <string> lstGuid = frmSelectFile.Tag as List <string>;


                //选择的文件填充
                if (lstGuid.Count > 0)
                {
                    FileDataManage FileDataManage = new FileDataManage();
                    FileData       filedata       = new FileData();
                    filedata = FileDataManage.GetFileData(lstGuid[0]);

                    txtFileID.Text       = filedata.FileID;
                    txtFileID.Tag        = filedata.FileGuID;
                    txtFileName.Text     = filedata.FileName;
                    txtOldVersionID.Text = filedata.VersionID;
                }
            }
        }
示例#3
0
        //下载
        private void repositoryItemButtonEdit2_Click(object sender, EventArgs e)
        {
            //获取当前文件的FileDataAttachmentGuid
            if (gridView2.RowCount > 0)
            {
                //得到当前登陆人员所在部门
                EmployeeManage EmployeeManage = new EmployeeManage();
                string         strDept        = EmployeeManage.GetEmpDeptByEmpName(SysParams.UserName);

                string strEmpGuid = EmployeeManage.GetEmpGuIDByEmpName(SysParams.UserName);

                string strFileGuID = ((DataRowView)(gridView1.GetFocusedRow())).Row["FileGuid"].ToString();

                if (rightgroupManage.IsOperateRightByUserID(SysParams.UserID, "FileAllView", "Qry") == false)
                {
                    //判断是否有下载权限
                    FileApplyManage FileApplyManage = new FileApplyManage();
                    if (FileApplyManage.IsDownloadByUserID(strEmpGuid, strDept, strFileGuID) == false)
                    {
                        this.ShowAlertMessage("你没有权限下载此文件!");
                        return;
                    }


                    // this.ShowAlertMessage("你没有权限下载此文件!");
                    // return;
                }



                string guid = ((DataRowView)(gridView2.GetFocusedRow())).Row["FileDataAttachmentGuid"].ToString();



                FileDataManage FileDataManage = new FileDataManage();
                DataTable      dtl            = FileDataManage.GetFileDataAttachmentByAttachmentGuid(guid);

                if (dtl.Rows.Count > 0)
                {
                    Byte[] bytes = (Byte[])dtl.Rows[0]["FileContent"];


                    //先将文件下载到本地
                    SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
                    SaveFileDialog1.FileName = dtl.Rows[0]["FileSourceName"].ToString();
                    SaveFileDialog1.Filter   = "All   files   (*.*)|*.* ";

                    SaveFileDialog1.RestoreDirectory = true;

                    if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        string     strfilepath = SaveFileDialog1.FileName;
                        FileStream fs          = new FileStream(strfilepath, FileMode.OpenOrCreate, FileAccess.Write);
                        fs.Write(bytes, 0, bytes.Length);
                        fs.Close();
                    }
                }
            }
        }
        public frmFileChangeRecord(string fileGuid)
        {
            InitializeComponent();

            FileDataManage FileDataManage = new FileDataManage();

            gridControl1.DataSource = FileDataManage.GetFileChangeRecord(fileGuid);
        }
示例#5
0
        private void btnQry_Click(object sender, EventArgs e)
        {
            string strsql = " where 1=1 ";

            if (txtFileClass.Text.Trim() != "")
            {
                strsql = strsql + " and FileType='" + txtFileClass.Tag.ToString() + "'";
            }

            if (txtFileID.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and FileID like '" + txtFileID.Text.Trim().Replace("'", "''") + "%'";
            }


            if (txtFileName.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and FileName like '" + txtFileName.Text.Trim().Replace("'", "''") + "%'";
            }


            if (txtControlType.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and ControlType = '" + txtControlType.Tag.ToString() + "'";
            }


            if (txtProductName.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and ProductName like '" + txtProductName.Text.Trim().Replace("'", "''") + "%'";
            }


            if (txtFileApplyPerson.Text.Trim() != "")
            {
                strsql = strsql + " and PersonGuID='" + txtFileApplyPerson.Tag.ToString() + "'";
            }


            if (txtDownDept.Text.Trim() != "")
            {
                strsql = strsql + " and FileApplyDept='" + txtDownDept.Tag.ToString() + "'";
            }



            FileDataManage FileDataManage = new FileDataManage();

            this.gridControl2.DataSource = FileDataManage.GetFileFFCountBySQL(strsql);
        }
示例#6
0
        /// <summary>
        /// 显示pdf文件
        /// </summary>
        /// <param name="FileDataAttachmentGuid"></param>
        public void ViewPDF(string FileDataAttachmentGuid)
        {
            FileDataManage FileDataManage = new FileDataManage();
            DataTable      dtl            = FileDataManage.GetFileDataAttachmentByAttachmentGuid(FileDataAttachmentGuid);

            if (dtl.Rows.Count > 0)
            {
                Byte[] bytes = (Byte[])dtl.Rows[0]["FileContent"];

                Random ran = new Random();
                int    num = ran.Next(1, 10);


                //先将文件下载到本地
                //判断目录是否存在,如果不存在,则创建
                if (Directory.Exists(Application.StartupPath + @"\FileAttachment") == false)
                {
                    Directory.CreateDirectory(Application.StartupPath + @"\FileAttachment");
                }

                txtFilePath.Text = Application.StartupPath + @"\FileAttachment\" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + num.ToString() + ".pdf";
                FileStream fs = new FileStream(txtFilePath.Text, FileMode.OpenOrCreate, FileAccess.Write);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();


                //加密PDF文件,加密后不可复制与打印---此方法有些版本pdf会报错
                // PDFSecurity(txtFilePath.Text, txtFilePath.Text, false, "P@ssw0rd");


                //加密PDF文件,加密后不可复制与打印
                pdfreadonly(txtFilePath.Text);

                //载入pdf文件
                axAcroPDF1.LoadFile(txtFilePath.Text);
                axAcroPDF1.setShowToolbar(false);
                axAcroPDF1.setZoom(100);

                this.ShowDialog();
            }
        }
        private void btnAddDetail_Click(object sender, EventArgs e)
        {
            FileDataManage          FileDataManage          = new FileDataManage();
            frmSelectFile_InStorage frmSelectFile_InStorage = new frmSelectFile_InStorage();

            frmSelectFile_InStorage.ShowDialog();



            if (frmSelectFile_InStorage.Tag != null)
            {
                //取出选择的文件Guid
                List <string> lstGuid = frmSelectFile_InStorage.Tag as List <string>;


                //选择的文件填充
                if (lstGuid.Count > 0)
                {
                    //得到文件的信息
                    for (int i = 0; i < lstGuid.Count; i++)
                    {
                        FileData filedata = new FileData();
                        filedata = FileDataManage.GetFileData(lstGuid[i]);

                        //填充数据
                        gridView1.AddNewRow();
                        gridView1.SetFocusedRowCellValue(gridFileGuID, filedata.FileGuID);
                        gridView1.SetFocusedRowCellValue(gridFileID, filedata.FileID);
                        gridView1.SetFocusedRowCellValue(gridFileName, filedata.FileName);
                        gridView1.SetFocusedRowCellValue(gridVersionID, filedata.VersionID);
                        gridView1.SetFocusedRowCellValue(gridPublishDate, DateTime.Parse(filedata.PublishDate.ToString()).ToString("yyyy-MM-dd"));
                        gridView1.SetFocusedRowCellValue(gridFileTypeName, FileDataManage.GetFileTypeName(filedata.FileType));
                        gridView1.SetFocusedRowCellValue(gridFileTypeName, FileDataManage.GetFileTypeName(filedata.FileType));
                        gridView1.SetFocusedRowCellValue(gridControlTypeName, base.GetBasicDataNameByID(filedata.ControlType));
                    }
                }
            }
        }
示例#8
0
        //查询
        private void btnQry_Click(object sender, EventArgs e)
        {
            FileDataManage FileDataManage = new FileDataManage();
            string         strsql         = " where 1=1 ";

            if (txtFileClass.Text.Trim() != "")
            {
                DataTable dtl = FileDataManage.GetSubFileType(txtFileClass.Tag.ToString());
                for (int i = 0; i < dtl.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        strsql = strsql + "and  (FileType='" + dtl.Rows[i]["InterID"].ToString() + "'";
                    }
                    else
                    {
                        strsql = strsql + " or  FileType='" + dtl.Rows[i]["InterID"].ToString() + "'";
                    }
                }

                if (dtl.Rows.Count > 0)
                {
                    strsql = strsql + " )";
                }
            }

            if (txtFileID.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and FileID like '" + txtFileID.Text.Trim().Replace("'", "''") + "%'";
            }


            if (txtFileName.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and FileName like '" + txtFileName.Text.Trim().Replace("'", "''") + "%'";
            }


            if (txtControlType.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and ControlType = '" + txtControlType.Tag.ToString() + "'";
            }


            if (txtProductName.Text.Trim().Replace("'", "''") != "")
            {
                strsql = strsql + " and ProductName like '" + txtProductName.Text.Trim().Replace("'", "''") + "%'";
            }

            if (dtBeginDate.Text.Trim() != "")
            {
                strsql = strsql + "  and PublishDate>='" + dtBeginDate.Text.Trim() + " 00:00:00'";
            }


            if (dtEndDate.Text.Trim() != "")
            {
                strsql = strsql + " and  PublishDate<='" + dtEndDate.Text.Trim() + " 23:59:59'";
            }

            //格式化文件类别子类为一级类别名称
            FileDataManage.GetSubFileType2("");


            this.gridControl1.DataSource = FileDataManage.GetFileDataBySQL_en(strsql);
        }
示例#9
0
        //保存
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtFileClass.Text.Trim() == "")
            {
                this.ShowAlertMessage("请选择文件类别!");
                return;
            }

            if (txtFileClass.Text.Trim() == "文件类别")
            {
                this.ShowAlertMessage("请选择其它的文件类别,[文件类别]为根类别不能选择!");
                return;
            }

            if (txtFileID.Text.Trim() == "")
            {
                this.ShowAlertMessage("请输入文件编号!");
                txtFileName.Focus();
                return;
            }
            if (txtFileName.Text.Trim() == "")
            {
                this.ShowAlertMessage("请输入文件名称!");
                txtFileName.Focus();
                return;
            }
            if (txtWriteDept.Text.Trim() == "")
            {
                this.ShowAlertMessage("请输入编写单位!");
                txtWriteDept.Focus();
                return;
            }

            if (txtVersionID.Text.Trim() == "")
            {
                this.ShowAlertMessage("请输入版本!");
                txtVersionID.Focus();
                return;
            }

            if (dePublishDate.Text == "")
            {
                this.ShowAlertMessage("请输入发布日期!");
                dePublishDate.Focus();
                return;
            }



            FileDataManage FileDataManage = new FileDataManage();


            //判断当前文件编号是否已经存在相同的,如果已经存在则给出提示
            if (FileDataManage.IsExistFile(txtGuid.Text, txtFileID.Text.Replace("'", "''"), txtVersionID.Text.Replace("'", "''"), IsEdit))
            {
                this.ShowAlertMessage("你输入的文件信息[文件编号+版本]已经存在,请修改后再确定!");
                return;
            }


            FileData FileData = new FileData();

            FileData.FileGuID = txtGuid.Text.Replace("'", "''");
            FileData.FileID   = txtFileID.Text.Replace("'", "''");
            FileData.FileName = txtFileName.Text.Replace("'", "''");
            if (txtControlType.Tag != null)
            {
                FileData.ControlType = txtControlType.Tag.ToString();
            }
            else
            {
                FileData.ControlType = "";
            }
            if (txtWriteDept.Tag != null)
            {
                FileData.WriteDept = txtWriteDept.Tag.ToString();
            }
            else
            {
                FileData.WriteDept = "";
            }
            FileData.FileType = txtFileClass.Tag.ToString();

            FileData.Remark = txtRemark.Text.Trim().Replace("'", "''");

            FileData.ProductName = txtProductName.Text.Replace("'", "''");

            FileData.VersionID = txtVersionID.Text.Replace("'", "''");

            if (chkStop.Checked == true)
            {
                FileData.IsEnable = 1; //停用
            }
            else
            {
                FileData.IsEnable = 0;//可用
            }

            FileData.PublishDate = DateTime.Parse(dePublishDate.Text);

            FileData.CreateDate = DateTime.Parse(txtCreateDate.Text);

            FileData.CreateGuid = txtCreateGuid.Tag.ToString();


            //判断附件是否被修改过,根据文件大小,文件名相同大小相同则没有修改过,如果不同则修改过
            try
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    int intFileLength = FileDataManage.GetFileLength(FileData.FileGuID, lst[i].FileSourceName);
                    if (intFileLength != lst[i].FileContent.Length)
                    {
                        FileDataManage.AddFileChangeRecord(FileData.FileGuID, lst[i].FileSourceName, SysParams.UserID);
                    }
                }
            }catch
            {
            }


            //保存
            FileDataManage.SaveFile(FileData, lst);



            //写日志
            SysLog.AddOperateLog(SysParams.UserName, "文件数据", "新增或编辑", SysParams.UserName + "用户新增或编辑了文件,文件:" + FileData.FileGuID + "," + FileData.FileID + "," + FileData.FileName);

            IsEdit = true;

            //刷新
            string strsql = " where FileType='" + txtFileClass.Tag.ToString() + "'";

            frmFileManage.frmfileManage.LoadFileData(strsql);


            this.ShowMessage("保存成功!");
        }
示例#10
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="MaterialGuid"></param>
        private void FillData(string FileGuid)
        {
            FileDataManage FileDataManage = new FileDataManage();

            DataTable dtl = FileDataManage.GetFileDataByFileGuID(FileGuid);

            if (dtl.Rows.Count > 0)
            {
                txtGuid.Text        = dtl.Rows[0]["FileGuID"].ToString();
                txtFileID.Text      = dtl.Rows[0]["FileID"].ToString();
                txtFileName.Text    = dtl.Rows[0]["FileName"].ToString();
                txtControlType.Text = dtl.Rows[0]["ControlTypeName"].ToString();
                txtControlType.Tag  = dtl.Rows[0]["ControlType"].ToString();

                txtWriteDept.Text = dtl.Rows[0]["WriteDeptName"].ToString();
                txtWriteDept.Tag  = dtl.Rows[0]["WriteDept"].ToString();

                txtFileClass.Text = dtl.Rows[0]["FileTypeName"].ToString();
                txtFileClass.Tag  = dtl.Rows[0]["FileType"].ToString();

                txtRemark.Text    = dtl.Rows[0]["Remark"].ToString();
                txtVersionID.Text = dtl.Rows[0]["VersionID"].ToString();


                dePublishDate.Text = DateTime.Parse(dtl.Rows[0]["PublishDate"].ToString()).ToString("yyyy-MM-dd");



                if (dtl.Rows[0]["IsEnable"].ToString().Trim() == "1")
                {
                    chkStop.Checked = true;
                }

                txtProductName.Text = dtl.Rows[0]["ProductName"].ToString().Trim();

                txtCreateGuid.Text = dtl.Rows[0]["CreateName"].ToString().Trim();
                txtCreateGuid.Tag  = dtl.Rows[0]["CreateGuid"].ToString().Trim();
                txtCreateDate.Text = dtl.Rows[0]["CreateDate"].ToString().Trim();


                if (dtl.Rows[0]["CreateGuid"].ToString().Trim() != SysParams.UserID)
                {
                    btnSave.Enabled              = false;
                    btnDelFile.Enabled           = false;
                    btnAddFileAttachment.Enabled = false;
                }
            }



            //加载明细数据
            FileDataAttachmentManage FileDataAttachmentManage = new FileDataAttachmentManage();
            DataTable dtlDetail = FileDataAttachmentManage.GetFileDataAttachmentByFileGuID(FileGuid);

            for (int i = 0; i < dtlDetail.Rows.Count; i++)
            {
                byte[] bytefile = (byte[])dtlDetail.Rows[i]["FileContent"];

                FileDataAttachment FileDataAttachment = new FileDataAttachment();
                FileDataAttachment.FileDataAttachmentGuid = dtlDetail.Rows[i]["FileDataAttachmentGuid"].ToString();
                FileDataAttachment.FileGuID       = dtlDetail.Rows[i]["FileGuID"].ToString();
                FileDataAttachment.FileContent    = bytefile;
                FileDataAttachment.FileSourceName = dtlDetail.Rows[i]["FileSourceName"].ToString();

                lst.Add(FileDataAttachment);

                //文件增加到chklist中
                ListItem item = new ListItem();
                item.Text  = FileDataAttachment.FileSourceName;
                item.Value = FileDataAttachment.FileDataAttachmentGuid;
                chklstFile.Items.Add(item);
            }
        }