/// <summary> /// 新增子类目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridViewStockProp.RowCount > 0) { XtraMessageBox.Show("该类目下有属性信息,不能添加子类目!", Constants.SYSTEM_PROMPT); return; } TreeListNode node = treeListStockCat.FocusedNode; if (node != null) { TreeListNodeTag tag = node.Tag as TreeListNodeTag; string fatherCode = tag.Cid; if (tag.Cid == "10000") { XtraMessageBox.Show("该类目为系统内置默认类目,不能有子类目!", Constants.SYSTEM_PROMPT); return; } string fatherName = node.GetDisplayText(0); StockCatAdd stockCatAdd = new StockCatAdd(fatherName, fatherCode); stockCatAdd.ShowDialog(); if (stockCatAdd.DialogResult == DialogResult.OK) { flag = true; Init(null);//刷新 } } else { XtraMessageBox.Show("请先选中一个类目进行子节点的添加!", Constants.SYSTEM_PROMPT); return; } }
/// <summary> /// 尾页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bbtnLastIndex_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { currentIndex = allIndex; TreeListNodeTag tag = tlStockCats.FocusedNode.Tag as TreeListNodeTag; GetStockItem(tag.Cid, StockItemElement.StockCatCid); }
/// <summary> /// 获取选中节点的所有最底级的cid /// </summary> /// <param name="nodes"></param> /// <returns></returns> private List <string> GetCheckedCids(TreeListNodes nodes) { List <string> cidlist = new List <string>(); foreach (TreeListNode node in nodes) { if (node.Checked && node.Tag != null) { if (!node.HasChildren)//有子类目 { TreeListNodeTag tag = node.Tag as TreeListNodeTag; cidlist.Add(tag.Cid); } else if (node.Nodes.Count == 0)//没有子类目但子节点个数为0 { TreeListNodeTag tag = node.Tag as TreeListNodeTag; /*查询cid下的所有最底级子类目*/ cidlist.AddRange(GetChildCids(tag.Cid)); } else//没有子类目但子节点个数不为0 { cidlist.AddRange(GetCheckedCids(node.Nodes)); } } } return(cidlist); }
/// <summary> /// 新增同级类目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode node = treeListStockCat.FocusedNode; if (node != null) { TreeListNode fatherNode = node.ParentNode; string fatherName = string.Empty; string fatherCode = "0"; if (fatherNode != null) { fatherName = fatherNode.GetDisplayText(0); TreeListNodeTag tag = fatherNode.Tag as TreeListNodeTag; fatherCode = tag.Cid; } StockCatAdd stockCatAdd = new StockCatAdd(fatherName, "0"); stockCatAdd.ShowDialog(); if (stockCatAdd.DialogResult == DialogResult.OK) { flag = true; Init(null);//刷新 } } else { StockCatAdd stockCatAdd = new StockCatAdd(string.Empty, "0"); stockCatAdd.ShowDialog(); if (stockCatAdd.DialogResult == DialogResult.OK) { flag = true; Init(null);//刷新 } } }
private void treeListStockCat_MouseDown(object sender, MouseEventArgs e) { TreeListHitInfo hitInfo = treeListStockCat.CalcHitInfo(new Point(e.X, e.Y)); /*如果单击到单元格内*/ if (hitInfo.HitInfoType == HitInfoType.Cell) { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { TreeListNodeTag tag = hitInfo.Node.Tag as TreeListNodeTag; textCatName.Text = hitInfo.Node.GetDisplayText(0); textCatCode.Text = tag.Cid; if (!hitInfo.Node.HasChildren) { Init(hitInfo.Node); } waitForm.Close(); } catch (Exception ex) { waitForm.Close(); } } }
/// <summary> /// 加载当前节点的子类目 /// </summary> /// <param name="focusedNode"></param> private void LoadChildNodes(TreeListNode focusedNode) { TreeListNodeTag tag = focusedNode.Tag as TreeListNodeTag; if (tag == null) { return; } #region 获得当前节点的子节点 if (!tag.HasExpanded) { treeListItemCat.BeginUnboundLoad(); List <Alading.Entity.ItemCat> itemCatList = itemcatlist.Where(c => c.parent_cid == tag.Cid && c.status == "normal").ToList(); foreach (Alading.Entity.ItemCat itemCat in itemCatList) { TreeListNode node = treeListItemCat.AppendNode(new object[] { itemCat.name }, focusedNode, new TreeListNodeTag(itemCat.cid.ToString())); node.HasChildren = (bool)itemCat.is_parent; node.Checked = focusedNode.Checked; } treeListItemCat.EndUnboundLoad(); tag.HasExpanded = true; } #endregion }
private void treeListStockCat_BeforeExpand(object sender, DevExpress.XtraTreeList.BeforeExpandEventArgs e) { //防止重复加载 e.Node.Nodes.Clear(); TreeListNodeTag tag = (TreeListNodeTag)e.Node.Tag; List <Alading.Entity.StockCat> stockCatList = StockCatService.GetStockCat(i => i.ParentCid == tag.Cid); LoadCat(stockCatList, e.Node.Id); }
/// <summary> /// 转到 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void repositoryItemComboChangeTo_SelectedIndexChanged(object sender, EventArgs e) { ComboBoxEdit combo = (ComboBoxEdit)sender; if (combo.SelectedIndex >= 0) { currentIndex = combo.SelectedIndex + 1; //combo.Text = combo.Properties.Items[combo.SelectedIndex].ToString(); TreeListNodeTag tag = tlStockCats.FocusedNode.Tag as TreeListNodeTag; GetStockItem(tag.Cid, StockItemElement.StockCatCid); } }
/// <summary> /// 初始化/刷新 /// </summary> private void Init(TreeListNode fnode) { if (flag) { treeListStockCat.Nodes.Clear(); //只加载最顶级的类目 List <Alading.Entity.StockCat> stockCatList = StockCatService.GetStockCat(i => i.ParentCid == "0"); treeListStockCat.BeginUnboundLoad(); foreach (Alading.Entity.StockCat stockCat in stockCatList) { TreeListNode node = treeListStockCat.AppendNode(new object[] { stockCat.StockCatName }, null, new TreeListNodeTag(stockCat.StockCid)); //设置是否有子节点,有则会显示一个+号 node.HasChildren = stockCat.IsParent; } treeListStockCat.EndUnboundLoad(); //不可编辑 treeListStockCat.OptionsBehavior.Editable = false; treeListStockCat.FocusedNodeChanged += treeListStockCat_FocusedNodeChanged; flag = false; if (treeListStockCat.FocusedNode != null) { TreeListNodeTag tag = treeListStockCat.FocusedNode.Tag as TreeListNodeTag; textCatCode.Text = tag.Cid; textCatName.Text = treeListStockCat.FocusedNode.GetDisplayText(0); gridCtrlStockProp.DataSource = StockPropService.GetStockProp(c => c.StockCid == tag.Cid); Alading.Entity.StockProp stockProp = gridViewStockProp.GetFocusedRow() as Alading.Entity.StockProp; if (stockProp != null) { gridCtrlStockPropValue.DataSource = StockPropValueService.GetStockPropValue(c => c.StockPid == stockProp.StockPid); } else { gridCtrlStockPropValue.DataSource = null; } } } else if (fnode != null) { TreeListNodeTag tag = fnode.Tag as TreeListNodeTag; textCatCode.Text = tag.Cid; textCatName.Text = fnode.GetDisplayText(0); gridCtrlStockProp.DataSource = StockPropService.GetStockProp(c => c.StockCid == tag.Cid); Alading.Entity.StockProp stockProp = gridViewStockProp.GetFocusedRow() as Alading.Entity.StockProp; if (stockProp != null) { gridCtrlStockPropValue.DataSource = StockPropValueService.GetStockPropValue(c => c.StockPid == stockProp.StockPid); } else { gridCtrlStockPropValue.DataSource = null; } } }
private void tlOperator_MouseDown(object sender, MouseEventArgs e) { TreeListHitInfo hitInfo = tlOperator.CalcHitInfo(new Point(e.X, e.Y)); /*如果单击到单元格内*/ if (hitInfo.HitInfoType == HitInfoType.Cell) { TreeListNodeTag tag = hitInfo.Node.Tag as TreeListNodeTag; this.pceOperator.Text = hitInfo.Node.GetDisplayText(0); this.pceOperator.Tag = tag.Cid; this.pceOperator.ClosePopup(); } }
/// <summary> /// 类目删除,如果类目CID为10000的为默认类目,不让删除。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barDeleteCat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode node = treeListStockCat.FocusedNode; if (node != null) { TreeListNodeTag tag = node.Tag as TreeListNodeTag; string cid = tag.Cid; if (cid == "10000") { XtraMessageBox.Show("该类目为系统内置默认类目,不能删除!", Constants.SYSTEM_PROMPT); return; } DialogResult result = XtraMessageBox.Show("确定要删除该类目及该类目下的所有属性信息吗?", Constants.SYSTEM_PROMPT, MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.Cancel) { return; } WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); ReturnType returnType = StockCatService.DeleteStockCat(cid); if (returnType == ReturnType.Success) { waitForm.Close(); XtraMessageBox.Show("删除类目成功!", Constants.SYSTEM_PROMPT); flag = true; Init(null); return; } else if (returnType == ReturnType.Conflicted) { waitForm.Close(); XtraMessageBox.Show("该类目为父类目,不能直接删除!请将该类目下的子类目全部删除再删除该类目!", Constants.SYSTEM_PROMPT); return; } else { waitForm.Close(); XtraMessageBox.Show("删除类目失败!", Constants.SYSTEM_PROMPT); return; } } else { XtraMessageBox.Show("请先选中要删除的类目!", Constants.SYSTEM_PROMPT); return; } }
/// <summary> /// 单击显示类目下的商品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tlStockCats_MouseClick(object sender, MouseEventArgs e) { gridCtrlStockItem.DataSource = null; bbtnComboxChangeTo.EditValue = string.Empty; TreeListHitInfo hitInfo = tlStockCats.CalcHitInfo(new Point(e.X, e.Y)); /*如果单击到单元格内*/ if (hitInfo.HitInfoType == HitInfoType.Cell) { if (!hitInfo.Node.HasChildren) { currentIndex = 1; TreeListNodeTag tag = hitInfo.Node.Tag as TreeListNodeTag; GetStockItem(tag.Cid, StockItemElement.StockCatCid); repositoryItemComboChangeTo.Items.Clear(); for (int i = 1; i <= allIndex; i++) { string text = "第" + i.ToString() + "页"; repositoryItemComboChangeTo.Items.Add(text); } } } }
/// <summary> /// 类目修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barModifyCat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode node = treeListStockCat.FocusedNode; if (node != null) { TreeListNodeTag tag = node.Tag as TreeListNodeTag; if (tag.Cid == "10000") { XtraMessageBox.Show("该类目为系统内置默认类目,不能修改!", Constants.SYSTEM_PROMPT); return; } string cid = tag.Cid; string catName = node.GetDisplayText(0); string fatherName = string.Empty; string fatherCid = "0"; TreeListNode fatherNode = node.ParentNode; if (fatherNode != null) { fatherName = fatherNode.GetDisplayText(0); TreeListNodeTag fatherTag = fatherNode.Tag as TreeListNodeTag; fatherCid = fatherTag.Cid; } ModifyStockCat mstockCat = new ModifyStockCat(catName, cid, fatherName, fatherCid); mstockCat.ShowDialog(); if (mstockCat.DialogResult == DialogResult.OK) { flag = true; Init(null);//刷新 } } else { XtraMessageBox.Show("请先选中一个类目进行修改!", Constants.SYSTEM_PROMPT); return; } }
/// <summary> /// 在展开前加载子类目信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tlStockCats_BeforeExpand(object sender, DevExpress.XtraTreeList.BeforeExpandEventArgs e) { TreeListNode focusedNode = e.Node; tlStockCats.FocusedNode = focusedNode; //XtraMessageBox.Show(tlItemCat.IsUnboundMode.ToString(), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TreeListNodeTag tag = focusedNode.Tag as TreeListNodeTag; #region 获得当前节点的子节点 if (!tag.HasExpanded) { tlStockCats.BeginUnboundLoad(); List <StockCat> stockCatList = StockCatService.GetStockCat(i => i.ParentCid == tag.Cid.ToString()); foreach (StockCat stockCat in stockCatList) { TreeListNode node = tlStockCats.AppendNode(new object[] { stockCat.StockCatName }, focusedNode, new TreeListNodeTag(stockCat.StockCid)); node.HasChildren = stockCat.IsParent; } tlStockCats.EndUnboundLoad(); tag.HasExpanded = true; } #endregion }