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 = ""; } }
public void OpenFile() { PSP_ImgInfo obj = FocusedObject; if (obj == null) { return; } obj = Services.BaseService.GetOneByKey <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); } }
private void simpleButton1_Click(object sender, EventArgs e) { if (buttonEdit1.Text == "") { MessageBox.Show("请选择附件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } 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(); }
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(); }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { 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); } }
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); }
public void View() { BinaryWriter bw; FileStream fs; PSP_ImgInfo info = FocusedObject; info = (PSP_ImgInfo)Services.BaseService.GetObject("SelectPSP_ImgInfoByKey", info); fs = new FileStream(Application.StartupPath + info.Name, FileMode.Create, FileAccess.Write); bw = new BinaryWriter(fs); bw.Write(info.Image); bw.Flush(); bw.Close(); fs.Close(); System.Diagnostics.Process.Start(Application.StartupPath + info.Name); }
private void gridView_DoubleClick(object sender, EventArgs e) { PSP_ImgInfo obj = FocusedObject; frmImgInfoInput f = new frmImgInfoInput(); f.StrName = obj.Name; f.StrRemark = obj.Remark; if (f.ShowDialog() == DialogResult.OK) { obj = Services.BaseService.GetOneByKey <PSP_ImgInfo>(obj.UID); obj.Name = f.StrName; obj.Remark = f.StrRemark; Services.BaseService.Update <PSP_ImgInfo>(obj); RefreshData(uid); } }
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); }
private void btDel_Click(object sender, EventArgs e) { //获取焦点对象 PSP_ImgInfo obj = FocusedObject; if (obj == null) { return; } //请求确认 if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //执行删除操作 try { Services.BaseService.Delete <PSP_ImgInfo>(obj); } catch (Exception exc) { HandleException.TryCatch(exc); return; } this.gridView.BeginUpdate(); //记住当前焦点行索引 int iOldHandle = this.gridView.FocusedRowHandle; //从链表中删除 //ObjectList.Remove(obj); gridView.DeleteRow(iOldHandle); //刷新表格 gridControl.RefreshDataSource(); //设置新的焦点行索引 GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); }
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 = ""; }