protected override void Del() { if (!DeleteRight) { MessageBox.Show("您没有此权限。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSP_interface ins = new PSP_interface(); ins.col1 = " BdzId like '%" + treeView1.SelectedNode.Tag.ToString() + "%' "; IList <PSP_interface> l2 = Services.BaseService.GetList <PSP_interface>("SelectPSP_interfaceByWhere", ins); if (l2.Count > 0) { MessageBox.Show("分类下包含数据,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (treeView1.SelectedNode.Nodes.Count > 0) { MessageBox.Show("分类下包含子分类,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("确定删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { PSP_bdz_type p = new PSP_bdz_type(); p.id = treeView1.SelectedNode.Tag.ToString(); Services.BaseService.Update("DeletePSP_bdz_type", p); treeView1.Nodes.Remove(treeView1.SelectedNode); ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
/// <summary> /// 修改焦点对象 /// </summary> public void UpdateObject() { //获取焦点对象 PSP_bdz_type obj = FocusedObject; if (obj == null) { return; } int i = gridView.FocusedRowHandle; //创建对象的一个副本 //LineType objCopy = new LineType(); //DataConverter.CopyTo<LineType>(obj, objCopy); //执行修改操作 using (FrmbdzTypeDialog dlg = new FrmbdzTypeDialog()) { dlg.Object = obj; //绑定副本 if (dlg.ShowDialog() != DialogResult.OK) { return; } } //RefreshData(); gridControl.RefreshDataSource(); gridView.FocusedRowHandle = i; }
/// <summary> /// 添加对象 /// </summary> public void AddObject() { //检查对象链表是否已经加载 if (ObjectList == null) { return; } //新建对象 PSP_bdz_type obj = new PSP_bdz_type(); //执行添加操作 using (FrmbdzTypeDialog dlg = new FrmbdzTypeDialog()) { dlg.IsCreate = true; //设置新建标志 dlg.Typeid = typeid; dlg.Object = obj; if (dlg.ShowDialog() != DialogResult.OK) { return; } } ObjectList.Add(obj); //刷新表格,并将焦点行定位到新对象上。 gridControl.RefreshDataSource(); GridHelper.FocuseRow(this.gridView, obj); //RefreshData(); //GridHelper.FocuseRow(this.gridView, obj); //gridView.FocusedRowHandle = gridView.RowCount; }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确定删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { PSP_bdz_type p = new PSP_bdz_type(); p.id = treeView1.SelectedNode.Tag.ToString(); Services.BaseService.Update("DeletePSP_bdz_type", p); treeView1.Nodes.Remove(treeView1.SelectedNode); ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
public void LoadTree(TreeNode _root, string id) { PSP_bdz_type p = new PSP_bdz_type(); p.col1 = " col3='" + id + "' order by Name"; IList <PSP_bdz_type> list = Services.BaseService.GetList <PSP_bdz_type>("SelectPSP_bdz_typeByWhere", p); for (int i = 0; i < list.Count; i++) { PSP_bdz_type _type = list[i]; TreeNode node = new TreeNode(_type.Name); node.Tag = _type.id; LoadTree(node, _type.id); _root.Nodes.Add(node); } }
private void 增加ToolStripMenuItem_Click(object sender, EventArgs e) { FomInput f = new FomInput(); if (f.ShowDialog() == DialogResult.OK) { PSP_bdz_type p = new PSP_bdz_type(); p.id = Guid.NewGuid().ToString(); p.Name = f.strName; p.col3 = typeid; Services.BaseService.Create <PSP_bdz_type>(p); TreeNode node = new TreeNode(p.Name); node.Tag = p.id; treeView1.SelectedNode.Nodes.Add(node); ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
/// <summary> /// 刷新表格中的数据 /// </summary> /// <returns>ture:成功 false:失败</returns> public bool RefreshData() { try { PSP_bdz_type p = new PSP_bdz_type(); p.col1 = " col3='" + typeid + "' order by Name"; IList <PSP_bdz_type> list = Services.BaseService.GetList <PSP_bdz_type>("SelectPSP_bdz_typeByWhere", p); this.gridControl.DataSource = list; } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } return(true); }
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e) { PSP_bdz_type p = new PSP_bdz_type(); p.id = treeView1.SelectedNode.Tag.ToString(); p = (PSP_bdz_type)Services.BaseService.GetObject("SelectPSP_bdz_typeByKey", p); FomInput f = new FomInput(); f.strName = p.Name; if (f.ShowDialog() == DialogResult.OK) { p.Name = f.strName; Services.BaseService.Update <PSP_bdz_type>(p); treeView1.SelectedNode.Text = p.Name; ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
/// <summary> /// 删除焦点对象 /// </summary> public void DeleteObject() { //获取焦点对象 PSP_bdz_type obj = FocusedObject; if (obj == null) { return; } //请求确认 if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //执行删除操作 try { Services.BaseService.Delete <PSP_bdz_type>(obj); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } this.gridView.BeginUpdate(); //记住当前焦点行索引 int iOldHandle = this.gridView.FocusedRowHandle; //从链表中删除 ObjectList.Remove(obj); //刷新表格 gridControl.RefreshDataSource(); //设置新的焦点行索引 GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); }
protected override void Edit() { if (!EditRight) { MessageBox.Show("您没有此权限。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSP_bdz_type p = new PSP_bdz_type(); p.id = treeView1.SelectedNode.Tag.ToString(); p = (PSP_bdz_type)Services.BaseService.GetObject("SelectPSP_bdz_typeByKey", p); FomInput f = new FomInput(); f.strName = p.Name; if (f.ShowDialog() == DialogResult.OK) { p.Name = f.strName; Services.BaseService.Update("UpdatePSP_bdz_typeNM", p); treeView1.SelectedNode.Text = p.Name; ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
protected override void Add() { if (!AddRight) { MessageBox.Show("您没有此权限。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FomInput f = new FomInput(); if (f.ShowDialog() == DialogResult.OK) { PSP_bdz_type p = new PSP_bdz_type(); p.id = Guid.NewGuid().ToString(); p.Name = f.strName; p.col3 = typeid; Services.BaseService.Create <PSP_bdz_type>(p); TreeNode node = new TreeNode(p.Name); node.Tag = p.id; treeView1.SelectedNode.Nodes.Add(node); ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
private void FrmglebeTypeDialog_Load(object sender, EventArgs e) { LoadData(); year.Text = _obj.UYear.ToString(); month.Text = _obj.UMonth; textkgbh.Text = _obj.Switch_Id; textkgmc.Text = _obj.Switch_Name; textfh.Text = _obj.LoadValue.ToString(); textdl.Text = _obj.Number.ToString(); PSP_bdz_type p = new PSP_bdz_type(); p.col1 = " col1=1 order by Name"; IList list1 = Services.BaseService.GetList("SelectPSP_bdz_typeByWhere", p); foreach (PSP_bdz_type str in list1) { bool b1 = false; for (int i = 0; i < bdzlist.Length; i++) { if (bdzlist[i] == str.id.ToString()) { b1 = true; } } treeList1.AppendNode(new object[] { str.id, str.Name, b1 }, -1); } PSP_bdz_type p2 = new PSP_bdz_type(); p2.col1 = " col1=2 order by Name"; IList list2 = Services.BaseService.GetList("SelectPSP_bdz_typeByWhere", p2); foreach (PSP_bdz_type str in list2) { bool b2 = false; for (int i = 0; i < fqlist.Length; i++) { if (fqlist[i] == str.id.ToString()) { b2 = true; } } treeList2.AppendNode(new object[] { str.id, str.Name, b2 }, -1); } PSP_bdz_type p3 = new PSP_bdz_type(); p3.col1 = " col1=3 order by Name"; IList list3 = Services.BaseService.GetList("SelectPSP_bdz_typeByWhere", p3); foreach (PSP_bdz_type str in list3) { bool b3 = false; for (int i = 0; i < fxtlist.Length; i++) { if (fxtlist[i] == str.id.ToString()) { b3 = true; } } treeList3.AppendNode(new object[] { str.id, str.Name, b3 }, -1); } }