/// <summary> /// 修改库存自定义属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bbtnModifyProp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { StockProp sp = gridViewStockProp.GetFocusedRow() as StockProp; if (sp != null) { string cid = textCatCode.Text; string catName = textCatName.Text; string fParentPid = sp.ParentPid; string fParentName = string.Empty; if (fParentPid != "0") { fParentName = StockPropService.GetStockProp(sp.ParentPid).Name; } string fParentVid = sp.ParentVid; string fParentValueName = string.Empty; if (fParentVid != "0") { fParentValueName = StockPropValueService.GetStockPropValue(sp.ParentVid).Name; } StockPropAdd spa = new StockPropAdd(cid, catName, fParentName, fParentPid, fParentValueName, fParentVid, sp.StockPid, sp.Name); spa.ShowDialog(); WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); gridCtrlStockProp.DataSource = StockPropService.GetStockProp(c => c.StockCid == cid); waitForm.Close(); } }
/// <summary> /// 点击属性显示其属性值列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridViewStockProp_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { StockProp sp = gridViewStockProp.GetFocusedRow() as StockProp; if (sp != null) { gridCtrlStockPropValue.DataSource = StockPropValueService.GetStockPropValue(c => c.StockPid == sp.StockPid); } }
/// <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; } } }
/// <summary> /// 增加属性值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bbtnAddStockPropValue_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { StockProp sp = gridViewStockProp.GetFocusedRow() as StockProp; if (sp != null) { string cid = textCatCode.Text; string catName = textCatName.Text; StockPropValueAdd spva = new StockPropValueAdd(cid, catName, sp.Name, sp.StockPid); spva.ShowDialog(); WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); gridCtrlStockPropValue.DataSource = StockPropValueService.GetStockPropValue(c => c.StockPid == sp.StockPid); waitForm.Close(); } }
/// <summary> /// 增加子属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bbtnAddSonStockProp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { StockProp sp = gridViewStockProp.GetFocusedRow() as StockProp; StockPropValue spv = gridViewStockPropValue.GetFocusedRow() as StockPropValue; if (sp != null && spv != null) { string cid = sp.StockCid; string catName = textCatName.Text; string fParentPid = sp.StockPid; string fParentName = sp.Name; string fParentVid = spv.StockVid; string fParentValueName = spv.Name; StockPropAdd spa = new StockPropAdd(cid, catName, fParentName, fParentPid, fParentValueName, fParentVid, true); spa.ShowDialog(); WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); gridCtrlStockProp.DataSource = StockPropService.GetStockProp(c => c.StockCid == cid); gridCtrlStockPropValue.DataSource = StockPropValueService.GetStockPropValue(c => c.StockPid == sp.StockPid); waitForm.Close(); } }
/// <summary> /// 增加并关闭,或是修改保存关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddStockProp_Click(object sender, EventArgs e) { if (flag) { if (AddNewStockProp()) { this.Close(); } else { } } else { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { List <StockPropValue> list = StockPropValueService.GetStockPropValue(s => s.StockPid == PropPid && s.StockVid == Vid); if (list.Count > 0) { StockPropValue spv = list.First(); spv.Name = textEditValueName.Text; StockPropValueService.UpdateStockPropValue(spv); waitForm.Close(); XtraMessageBox.Show("修改属性值失败!", Constants.SYSTEM_PROMPT); this.Close(); } } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show("修改属性值失败!", Constants.SYSTEM_PROMPT); } } }
/// <summary> /// 添加StockProp /// </summary> /// <returns></returns> bool AddNewStockProp() { if (textEditPropName.Text == null || string.IsNullOrEmpty(textEditPropName.Text.Trim())) { XtraMessageBox.Show("请输入属性名称!", Constants.SYSTEM_PROMPT); textEditPropName.Focus(); return(false); } if (textEditCatCode.Text == null || string.IsNullOrEmpty(textEditCatCode.Text.Trim())) { XtraMessageBox.Show("请输入属性编码!", Constants.SYSTEM_PROMPT); textEditCatCode.Focus(); return(false); } WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { string stockPid = textEditPropPid.Text; if (StockPropService.GetStockProp(s => s.StockPid == stockPid).Count > 0) { waitForm.Close(); XtraMessageBox.Show("属性编码与数据库中已有编码重复,请重输!", Constants.SYSTEM_PROMPT); textEditCatCode.Focus(); return(false); } StockProp sp = new StockProp(); sp.Name = textEditPropName.Text; sp.StockPid = stockPid; sp.ParentPid = fPropPid; sp.ParentVid = fVid; sp.PropValues = string.Empty; sp.Status = string.Empty;// sp.StockCid = stockCid; if (StockPropService.AddStockProp(sp) == ReturnType.Success) { if (sonFlag) { List <StockPropValue> list = StockPropValueService.GetStockPropValue(s => s.StockPid == fPropPid && s.StockVid == fVid); if (list.Count > 0) { StockPropValue spv = list.First(); spv.IsParent = sonFlag; StockPropValueService.UpdateStockPropValue(spv); } } waitForm.Close(); XtraMessageBox.Show("添加属性成功!", Constants.SYSTEM_PROMPT); return(true); } else { waitForm.Close(); XtraMessageBox.Show("添加属性失败!", Constants.SYSTEM_PROMPT); return(false); } } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show("添加属性失败!", Constants.SYSTEM_PROMPT); return(false); } }