Esempio n. 1
0
        private void gv_Attachment_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (gv_Attachment.FocusedRowHandle < 0)
                {
                    return;
                }
                FileUtils.ClearDirectory(Application.StartupPath + "\\Temp");
                var imageId  = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
                var fileName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();

                var attachementBll   = new EqptAttachment();
                var attachementModel = attachementBll.GetModel(imageId);

                var fs = new FileStream(Application.StartupPath + "\\Temp\\" + fileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(attachementModel.Attachment, 0, attachementModel.Attachment.Length);
                bw.Close();
                fs.Close();


                Process.Start(Application.StartupPath + "\\Temp\\" + fileName);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("打开出错!", "提示");
            }
        }
Esempio n. 2
0
        private void btn_DownloadAttachment_Click(object sender, EventArgs e)
        {
            if (gv_Attachment.FocusedRowHandle < 0)
            {
                XtraMessageBox.Show("当前未选中任何附件!", "提示");
                return;
            }
            var attachmentId   = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
            var attachmentName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();
            var saveFileDialog = new SaveFileDialog()
            {
                Filter = string.Format("*.{0}|*.{0}", Path.GetExtension(attachmentName)), FileName = attachmentName
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                var eqptAttachmentBll   = new EqptAttachment();
                var eqptAttachmentModel = eqptAttachmentBll.GetModel(attachmentId);
                var fs = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(eqptAttachmentModel.Attachment, 0, eqptAttachmentModel.Attachment.Length);
                bw.Close();
                fs.Close();

                XtraMessageBox.Show("下载成功!", "提示");
            }
        }
Esempio n. 3
0
        private void btn_AddAttachment_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (var fsRead = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    if (fsRead.CanRead)
                    {
                        var eqptAttachmentBll   = new EqptAttachment();
                        var eqptAttachmentModel = new Model.EqptAttachment();
                        var fsSize = Convert.ToInt32(fsRead.Length);
                        var btRead = new byte[fsSize];
                        fsRead.Read(btRead, 0, fsSize);
                        fsRead.Close();
                        eqptAttachmentModel.Attachment = btRead;
                        eqptAttachmentModel.LayerName  = _layerInfo.LayerName;
                        eqptAttachmentModel.Name       = Path.GetFileName(openFileDialog.FileName);
                        eqptAttachmentModel.SmId       = _smId;

                        XtraMessageBox.Show(eqptAttachmentBll.Add(eqptAttachmentModel) > 0 ? "添加成功!" : "添加失败!", "提示");
                        InitAttachmentGrid();
                    }
                }
            }
        }
Esempio n. 4
0
        private void btn_AddAttachment_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();
            if(openFileDialog.ShowDialog()==DialogResult.OK)
            {
                using (var fsRead = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    if (fsRead.CanRead)
                    {
                        var eqptAttachmentBll = new EqptAttachment();
                        var eqptAttachmentModel = new Model.EqptAttachment();
                        var fsSize = Convert.ToInt32(fsRead.Length);
                        var btRead = new byte[fsSize];
                        fsRead.Read(btRead, 0, fsSize);
                        fsRead.Close();
                        eqptAttachmentModel.Attachment = btRead;
                        eqptAttachmentModel.LayerName = _layerInfo.LayerName;
                        eqptAttachmentModel.Name = Path.GetFileName(openFileDialog.FileName);
                        eqptAttachmentModel.SmId = _smId;

                        XtraMessageBox.Show(eqptAttachmentBll.Add(eqptAttachmentModel) > 0 ? "添加成功!" : "添加失败!", "提示");
                        InitAttachmentGrid();
                    }
                }

            }
        }
Esempio n. 5
0
        private void gv_Attachment_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (gv_Attachment.FocusedRowHandle < 0) return;
                FileUtils.ClearDirectory(Application.StartupPath + "\\Temp");
                var imageId = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
                var fileName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();

                var attachementBll = new EqptAttachment();
                var attachementModel = attachementBll.GetModel(imageId);

                var fs = new FileStream(Application.StartupPath + "\\Temp\\" + fileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(attachementModel.Attachment, 0, attachementModel.Attachment.Length);
                bw.Close();
                fs.Close();

                Process.Start(Application.StartupPath + "\\Temp\\" + fileName);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("打开出错!", "提示");
            }
        }
Esempio n. 6
0
        private void btn_DownloadAttachment_Click(object sender, EventArgs e)
        {
            if(gv_Attachment.FocusedRowHandle<0)
            {
                XtraMessageBox.Show("当前未选中任何附件!", "提示");
                return;
            }
            var attachmentId = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
            var attachmentName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();
            var saveFileDialog = new SaveFileDialog()
                                     {Filter = string.Format("*.{0}|*.{0}", Path.GetExtension(attachmentName)),FileName = attachmentName};
            if(saveFileDialog.ShowDialog()==DialogResult.OK)
            {
                var eqptAttachmentBll = new EqptAttachment();
                var eqptAttachmentModel = eqptAttachmentBll.GetModel(attachmentId);
                var fs = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(eqptAttachmentModel.Attachment, 0, eqptAttachmentModel.Attachment.Length);
                bw.Close();
                fs.Close();

                XtraMessageBox.Show("下载成功!", "提示");
            }
        }