コード例 #1
0
ファイル: StockCat.cs プロジェクト: treesan/taobao-alading
 /// <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;
         }
     }
 }
コード例 #2
0
ファイル: StockCat.cs プロジェクト: treesan/taobao-alading
 /// <summary>
 /// 删除类目属性
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bbtnDelProp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     Alading.Entity.StockProp stockProp = gridViewStockProp.GetFocusedRow() as Alading.Entity.StockProp;
     if (stockProp != null)
     {
         DialogResult result = XtraMessageBox.Show("确定要删除该属性及该属性下的所有属性值及子属性吗?", Constants.SYSTEM_PROMPT, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         if (result == DialogResult.OK)
         {
             WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);
             waitForm.Show();
             try
             {
                 if (StockPropService.DeleteStockPropAndValue(stockProp) == ReturnType.Success)
                 {
                     waitForm.Close();
                     XtraMessageBox.Show("删除类目属性成功!", Constants.SYSTEM_PROMPT);
                     waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);
                     waitForm.Show();
                     //flag = true;
                     Init(treeListStockCat.FocusedNode);
                     waitForm.Close();
                 }
                 else
                 {
                     waitForm.Close();
                     XtraMessageBox.Show("删除类目属性失败!", Constants.SYSTEM_PROMPT);
                     return;
                 }
             }
             catch (Exception ex)
             {
                 waitForm.Close();
                 XtraMessageBox.Show("删除类目属性失败!", Constants.SYSTEM_PROMPT);
                 return;
             }
         }
     }
 }