/// <summary> /// 保存数据 /// </summary> /// <param name="product">供应商对象</param> /// <param name="workId">机构ID</param> /// <returns>返回结果对象</returns> public DGBillResult SaveSupply(DG_SupportDic product, int workId) { DGBillResult result = new DGBillResult(); List <Tuple <string, string, SqlOperator> > lst = new List <Tuple <string, string, SqlOperator> >(); lst.Add(Tuple.Create("SupportName", product.SupportName, SqlOperator.Equal)); lst.Add(Tuple.Create("delflag", "0", SqlOperator.Equal)); lst.Add(Tuple.Create("WorkId", workId.ToString(), SqlOperator.Equal)); IEnumerable <DG_SupportDic> objs = NewObject <IDGDao>().GetEntityType <DG_SupportDic>(lst, null); var vp = objs.FirstOrDefault(i => i.SupplierID == product.SupplierID); if (vp != null) { this.BindDb(product); SetWorkId(workId); product.save(); result.Result = 0; return(result); } if (objs != null && objs.Any()) { result.Result = 1; result.ErrMsg = "已经存在同名的生产厂厂家名称"; return(result); } else { this.BindDb(product); product.save(); result.Result = 0; return(result); } }
/// <summary> /// 改变当前选中行 /// </summary> /// <param name="sender">对象</param> /// <param name="e">参数</param> private void dgSupply_CurrentCellChanged(object sender, EventArgs e) { if (dgSupply.CurrentCell == null) { return; } int rowindex = dgSupply.CurrentCell.RowIndex; DataTable dt = (DataTable)dgSupply.DataSource; DG_SupportDic pruDic = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToObject <DG_SupportDic>(dt, rowindex); CurrentData = pruDic; fmCommon.Load <DG_SupportDic>(pruDic); }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender">对象</param> /// <param name="e">参数</param> private void btnSave_Click(object sender, System.EventArgs e) { if (fmCommon.Validate()) { if (this.txtPhone.Text.Trim() != string.Empty) { if (!RegexTelPhone(this.txtPhone.Text)) { DevComponents.DotNetBar.MessageBoxEx.Show("联系人号码不正确"); this.txtPhone.Focus(); return; } } DG_SupportDic productDic = null; if (CurrentData != null) { if (MessageBox.Show("确定更改记录?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } productDic = CurrentData; } else { productDic = new DG_SupportDic(); } try { fmCommon.GetValue <DG_SupportDic>(productDic); productDic.PYCode = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetSpellCode(productDic.SupportName); productDic.WBCode = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetWBCode(productDic.SupportName); CurrentData = productDic; InvokeController("SaveSupply", pagerMember.pageNo, pagerMember.pageSize); setGridSelectIndex(dgSupply); CurrentData = null; this.txtName.Focus(); } catch (Exception ex) { MessageBox.Show("保存失败" + ex.Message); throw; } } }
/// <summary> /// 更新生产商数据 /// </summary> /// <param name="productDic">生产商对象</param> public void UpdateSupply(DG_SupportDic productDic) { productDic.DelFlag = 1; productDic.save(); }