private void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtName.Text)) { if (_isEdit) { _wareType.Name = txtName.Text; DBHelper.GetInstance().WareTypeUpdate(_wareType); MessageBox.Show("商品类别修改成功!", "系统提示"); this.FindForm().Close(); } else { _wareType = new ProductType() { TID = Guid.NewGuid().ToString(), Name = txtName.Text, CreateTime = DateTime.Now, BEnable = true }; DBHelper.GetInstance().WareTypeInsert(_wareType); if (MessageBox.Show("商品类别保存成功!是否继续录入分类?", "系统提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.No) { this.FindForm().Close(); } } } else { MessageBox.Show("请输入类别名称","系统提示"); } }
/// <summary> /// 更新产品类型 /// </summary> /// <param name="wType"></param> public void WareTypeUpdate(ProductType wType) { OtDB db = GetDb(); try { db.Begin(); db.ExecUpdate(wType, "ProductType", new string[] { "Name", "Description", "BEnable" }, string.Format(" TID = '{0}'", wType.TID), null); db.Commit(); } catch (Exception ex) { OtCom.XLogErr(ex.Message); db.Rollback(); } }
/// <summary> /// 增加商品类型 /// </summary> /// <param name="wType"></param> public void WareTypeInsert(ProductType wType) { OtDB db = GetDb(); try { db.Begin(); db.ExecInsert(wType, "ProductType", new string[] { "TID", "Name", "Description", "BEnable", "CreateTime" }); db.Commit(); } catch (Exception ex) { OtCom.XLogErr(ex.Message); db.Rollback(); } }
public UiTypes(ProductType wType) { InitializeComponent(); _wareType = wType ?? new ProductType(); _isEdit = wType != null; }
private void menuChangeType_Click(object sender, EventArgs e) { TreeListNode fNode = _typeManagerTree.FocusedNode; if (fNode != null) { object nowKey = _typeManagerTree.GetNodeKey(fNode); if (nowKey.ToString() == "ALL" || nowKey.ToString() == "JINDONG" || nowKey.ToString() == "UnType" || nowKey.ToString() == "down" || nowKey.ToString() == "up" || nowKey.ToString() == "balance" || nowKey.ToString() == "focus" || nowKey.ToString() == "trash") { MessageBox.Show("系统基础分类不能修改!", "系统提示"); } else { object nowValue = _typeManagerTree.GetNodeCaption(fNode); if (nowValue != null) { ProductType cType = new ProductType() { TID = nowKey.ToString(), Name = nowValue.ToString(), BEnable = true }; AddWareType(true, cType); InitTypeTree(); } } } }
private void AddWareType(bool isEdit, ProductType wType) { UiTypes types = isEdit ? new UiTypes(wType) : new UiTypes(); ShowPopForm(types, "分类管理"); }