Ejemplo n.º 1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (buttonEdit1.Text == "")
            {
                MessageBox.Show("请选择附件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                System.IO.FileStream fs = new System.IO.FileStream(buttonEdit1.Text, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                byte[] filebt = br.ReadBytes((int)fs.Length);
                br.Close();
                fs.Close();
                string[] str = buttonEdit1.Text.Split("\\".ToCharArray());
                PSP_ImgInfo imgInfo = new PSP_ImgInfo();
                imgInfo.UID = Guid.NewGuid().ToString();
                imgInfo.TreeID = uid;
                imgInfo.Image = filebt;
                imgInfo.Name = str[str.Length - 1];
                imgInfo.Remark = txtRe.Text;
                Services.BaseService.Create<PSP_ImgInfo>(imgInfo);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch
            {
                MessageBox.Show("文件正在使用中,请关闭选择的文件后重试。");
            }
        }
Ejemplo n.º 2
0
        public void OpenFile()
        {
            Itop.Domain.Graphics.PSP_ImgInfo obj = FocusedObject;
            if (obj == null)
            {
                return;
            }
            obj = Services.BaseService.GetOneByKey <Itop.Domain.Graphics.PSP_ImgInfo>(obj.UID);
            BinaryWriter bw;
            FileStream   fs;

            try
            {
                byte[] bt       = obj.Image;
                string filename = obj.Name;
                fs = new FileStream("C:\\" + filename, FileMode.Create, FileAccess.Write);
                bw = new BinaryWriter(fs);
                bw.Write(bt);
                bw.Flush();
                bw.Close();
                fs.Close();
                System.Diagnostics.Process.Start("C:\\" + filename);
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
Ejemplo n.º 3
0
 public void LoadData(string id)
 {
     PSP_ImgInfo info = new PSP_ImgInfo();
     info.TreeID = id;
     gridControl.DataSource= Services.BaseService.GetList<PSP_ImgInfo>("SelectPSP_ImgInfoList", info);
     gridControl.RefreshDataSource();
 }
Ejemplo n.º 4
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Itop.Domain.Graphics.PSP_ImgInfo obj = FocusedObject;
     if (obj == null)
     {
         return;
     }
     if (MessageBox.Show("确定要删除么?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
     {
         Services.BaseService.Update("DeletePSP_ImgInfo", obj);
         RefreshData(tzgsid);
     }
 }
Ejemplo n.º 5
0
        public bool RefreshData(string id)
        {
            try
            {
                Itop.Domain.Graphics.PSP_ImgInfo img = new Itop.Domain.Graphics.PSP_ImgInfo();
                img.TreeID = id;
                IList <Itop.Domain.Graphics.PSP_ImgInfo> list = Services.BaseService.GetList <Itop.Domain.Graphics.PSP_ImgInfo>("SelectPSP_ImgInfoList", img);

                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                //HandleException.TryCatch(exc);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        public bool RefreshData(string id)
        {
            try
            {
                PSP_ImgInfo img = new PSP_ImgInfo();
                img.TreeID = id;

            }
            catch (Exception exc)
            {
                //HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }
Ejemplo n.º 7
0
        public bool RefreshData(string id)
        {
            try
            {
                PSP_ImgInfo img = new PSP_ImgInfo();
                img.TreeID = id;
                IList<PSP_ImgInfo> list = Services.BaseService.GetList<PSP_ImgInfo>("SelectPSP_ImgInfoList", img);

                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                //HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }
Ejemplo n.º 8
0
        private void delMenuItem_Click(object sender, EventArgs e)
        {
            if (uid == "")
            {
                MessageBox.Show("请选择目录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if(treeView1.SelectedNode.Nodes.Count>0){
                MessageBox.Show("选择的目录包含子目录,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            PSP_ImgInfo img = new PSP_ImgInfo();
            img.TreeID = uid;
            IList<PSP_ImgInfo> list = Services.BaseService.GetList<PSP_ImgInfo>("SelectPSP_ImgInfoList", img);
            if(list.Count>0){
                MessageBox.Show("选择的目录包含文件,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if(MessageBox.Show("确定要删除么?","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)==DialogResult.OK){
                Services.BaseService.DeleteByKey<PSP_ImgTree>(treeView1.SelectedNode.Tag.ToString());
                treeView1.Nodes.Remove(treeView1.SelectedNode);
                uid = "";
            }
        }
Ejemplo n.º 9
0
        private void btSave_Click(object sender, EventArgs e)
        {
            if(txtName.Text==""){

                MessageBox.Show("请输入名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtName.Focus();
                return;
            }
            StrName =txtName.Text;
            StrRemark =txtRemark.Text;

            if (uid == "")
            {
                MessageBox.Show("请选择目录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (pic == null)
            {
                MessageBox.Show("没有选择图片。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MemoryStream Ms = new MemoryStream();
            pic.Save(Ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] img = new byte[Ms.Length];
            Ms.Position = 0;
            Ms.Read(img, 0, Convert.ToInt32(Ms.Length));
            Ms.Close();

            PSP_ImgInfo imgInfo = new PSP_ImgInfo();
            imgInfo.UID = Guid.NewGuid().ToString();
            imgInfo.TreeID = uid;
            imgInfo.Image = img;
            imgInfo.Name = strName;
            imgInfo.Remark = strRemark;
            Services.BaseService.Create<PSP_ImgInfo>(imgInfo);
            pic = null;
            RefreshData(uid);
            txtName.Text = "";
            txtRemark.Text = "";
        }