/// <summary> /// 新增产品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNewPro_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtProName.Text.Trim())) { if (txtMoneyIsSucced()) { KPS.Model.ProductInfo pinfo = new Model.ProductInfo(); pinfo.productname = txtProName.Text.Trim(); pinfo.promoney = Convert.ToDouble(txtMoney.Text.Trim()); if (isSelUnit) { //调用BLL获取所有的用户列表 KPS.BLL.ProductInfoManager manager = new BLL.ProductInfoManager(); RecordList = manager.GetModelList(string.Format("productname like '%{0}%'", pinfo.productname)); ReaLoadSpList();//重新加载列表 } else { //调用BLL获取所有的用户列表 KPS.BLL.ProductInfoManager manager = new BLL.ProductInfoManager(); if (!manager.Exists(pinfo.productname)) { if (manager.Add(pinfo)) { pinfo.productid = manager.GetMaxId(); } if (pinfo.productid != null && pinfo.productid != 0) { if (RecordList == null) { RecordList = new List <Model.ProductInfo>(); } RecordList.Add(pinfo); ReaLoadSpList(); MessageBox.Show("添加成功!"); } else { MessageBox.Show("添加失败!"); } } else { MessageBox.Show("输入名称和已有名称重复,无法成功添加!"); } } } } else { MessageBox.Show("名称不可为空!"); } }
/// <summary> /// 新增产品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNewPro_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtProName.Text.Trim())) { if (txtMoneyIsSucced()) { KPS.Model.ProductInfo pinfo = new Model.ProductInfo(); pinfo.productname = txtProName.Text.Trim(); pinfo.promoney = Convert.ToDouble(txtMoney.Text.Trim()); if (isSelUnit) { //调用BLL获取所有的用户列表 KPS.BLL.ProductInfoManager manager = new BLL.ProductInfoManager(); RecordList = manager.GetModelList(string.Format("productname like '%{0}%'", pinfo.productname)); ReaLoadSpList();//重新加载列表 } else { //调用BLL获取所有的用户列表 KPS.BLL.ProductInfoManager manager = new BLL.ProductInfoManager(); if (!manager.Exists(pinfo.productname)) { if (manager.Add(pinfo)) { pinfo.productid = manager.GetMaxId(); } if (pinfo.productid != null && pinfo.productid != 0) { if (RecordList == null) { RecordList = new List<Model.ProductInfo>(); } RecordList.Add(pinfo); ReaLoadSpList(); MessageBox.Show("添加成功!"); } else { MessageBox.Show("添加失败!"); } } else { MessageBox.Show("输入名称和已有名称重复,无法成功添加!"); } } } } else { MessageBox.Show("名称不可为空!"); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(KPS.Model.ProductInfo model) { return(dal.Update(model)); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (!isSelUnit) { this.DialogResult = DialogResult.OK; } else { if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0) { selproductInfo = (ProductInfo)this._RecordListView.SelectedObjects[0]; this.DialogResult = DialogResult.OK; } else { MessageBox.Show("您未选择任何项,请选择对应项后再试!"); } } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(KPS.Model.ProductInfo model) { return(dal.Add(model)); }