public override void AddNew() { Action func = () => { Models.ConsumableEntity.hc_Goods md = null; int a = 0; for (int i = 0; i < 1000000; i++) { md = new Models.ConsumableEntity.hc_Goods(); md.Id = Guid.NewGuid(); md.GoodsName = $"name{i}"; md.GoodsBrand = $"Brand{i}"; md.GoodsBuyerId = Guid.Empty; md.GoodsCategoryId = Guid.Empty; md.GoodsMaxCount = 5; md.GoodsMinCount = 1; md.GoodsSN = $"SN{i}"; md.GoodsUnit = "个"; md.GoodsPrice = 10; md.GoodsSupplierId = Guid.Empty; md.GoodsModel = $"Model{i}"; if (!Manager.AddNew(md)) { a++; } else { continue; } } }; func.Invoke(); }
/// <summary> /// 商品信息保存方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, System.EventArgs e) { if (_model == null) { _model = new Models.ConsumableEntity.hc_Goods(); _model.Id = Guid.Empty; } if (txtGoodsName.Text.Trim() == "" || cbGoodsCategory.EditValue == null || cbUnit.SelectedIndex <= 0 || txtGoodsModel.Text.Trim() == "" || cbSupplier.EditValue == null || txtGoodsPrice.Text.Trim() == "" || cbGoodsBuyer.EditValue == null) { clsPublic.ShowMessage("信息输入不全!", Text); return; } _model.GoodsName = txtGoodsName.Text.Trim(); _model.GoodsBrand = txtGoodsBrand.Text.Trim(); _model.GoodsBuyerId = clsPublic.GetObjGUID(cbGoodsBuyer.EditValue); _model.GoodsCategoryId = clsPublic.GetObjGUID(cbGoodsCategory.EditValue); _model.GoodsMaxCount = int.Parse(txtMaxNum.Text); _model.GoodsMinCount = int.Parse(txtMinNum.Text); _model.GoodsSN = txtGoodsSN.Text; _model.GoodsUnit = cbUnit.SelectedItem.ToString(); _model.GoodsPrice = decimal.Parse(txtGoodsPrice.Text.Trim()); _model.GoodsSupplierId = clsPublic.GetObjGUID(cbSupplier.EditValue); _model.GoodsModel = txtGoodsModel.Text.Trim(); if (_model.Id == Guid.Empty) { _model.Id = Guid.NewGuid(); if (manager.AddNew(_model)) { base.DialogResult = DialogResult.OK; return; } } else { if (manager.Modify(_model)) { base.DialogResult = DialogResult.OK; return; } } base.DialogResult = DialogResult.Cancel; }
/// <summary> /// 构造函数(修改带参数) /// </summary> /// <param name="model"> 实体货品</param> public GoodsEditForm(Models.ConsumableEntity.hc_Goods model) : this() { this.Text = this.Text.Replace("[新增]", "[修改]"); _model = model; #region 控件赋值 txtGoodsName.Text = _model.GoodsName; txtGoodsBrand.Text = _model.GoodsBrand; cbGoodsBuyer.EditValue = _model.GoodsBuyerId; cbGoodsCategory.EditValue = _model.GoodsCategoryId; txtMaxNum.Text = _model.GoodsMaxCount.ToString(); txtMinNum.Text = _model.GoodsMinCount.ToString(); txtGoodsSN.Text = _model.GoodsSN; cbUnit.Text = _model.GoodsUnit; txtGoodsPrice.Text = _model.GoodsPrice.ToString(); cbSupplier.EditValue = _model.GoodsSupplierId; txtGoodsModel.Text = _model.GoodsModel; #endregion }
public bool Modify(Models.ConsumableEntity.hc_Goods model) { return(DAL.Sql.SqlHelper.Modify <Models.ConsumableEntity.hc_Goods>(model)); }
public bool AddNew(Models.ConsumableEntity.hc_Goods model) { return(DAL.Sql.SqlHelper.Insert <Models.ConsumableEntity.hc_Goods>(model)); }