private void NodeClick(object sender, EventArgs e) { Node node = sender as Node; this.selectedNode = node.Tag as MouldClass; this.txt_CCode.Text = selectedNode.Code; this.txt_CName.Text = selectedNode.Name; }
private void btn_Save_Click(object sender, EventArgs e) { #region 保存模具档案 string cCode = txt_CCode.Text.Trim(); int len = cCode.LastIndexOf("."); if (len > 0) { string pCode = cCode.Substring(0, len); if (!dal.Exists(pCode)) { throw new Exception("不存在上级分类: " + pCode); } } if (opState == OpState.Add) { if (dal.Exists(cCode)) { throw new Exception("分类编码: " + cCode + "已存在!"); } this.selectedNode = new MouldClass(); selectedNode.Code = cCode; selectedNode.Name = txt_CName.Text.Trim(); selectedNode.cMaker = Information.UserInfo.cUser_Name; if (dal.Add(selectedNode)) { this.btn_Refresh_Click(null, null); } } else if (opState == OpState.Update) { if (selectedNode.Code != cCode) { if (dal.Exists(cCode)) { throw new Exception("分类编码: " + cCode + "已存在!"); } else if (dal.ExistsChild(selectedNode.Code)) { throw new Exception("当前分类存在下级分类, 分类编码不能修改!"); } } selectedNode.Code = cCode; selectedNode.Name = txt_CName.Text.Trim(); if (dal.Update(selectedNode)) { this.btn_Refresh_Click(null, null); } } TreeM.SelectedNode = TreeM.FindNodeByName(cCode); #endregion }
private void btn_Del_Click(object sender, EventArgs e) { #region 除 MouldClass model = TreeM.SelectedNode.Tag as MouldClass; if (dal.ExistsChild(model.Code)) { throw new Exception("存在下级分类不能删除!"); } else if (dal.ExistsRef(model.MCId)) { throw new Exception("分类已经被引用不能删除!"); } if (dal.Delete(model.MCId)) { this.btn_Refresh_Click(null, null); } #endregion }
public FmMould(MouldClass modelC, OpState op = OpState.Add) : this() { this.opState = op; this.modelC = modelC; }