/// <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; MW_SupportDic pruDic = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToObject <MW_SupportDic>(dt, rowindex); CurrentData = pruDic; fmCommon.Load <MW_SupportDic>(pruDic); }
/// <summary> /// 保存 /// </summary> /// <param name="sender">控件</param> /// <param name="e">参数</param> private void btnSave_Click(object sender, 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; } } MW_SupportDic productDic = null; if (CurrentData != null) { if (MessageBox.Show("确定更改记录?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } productDic = CurrentData; } else { productDic = new MW_SupportDic(); } try { fmCommon.GetValue <MW_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="product">供应商实体</param> /// <param name="workId">机构id</param> /// <returns>true保存成功</returns> public bool SaveSupply(MW_SupportDic product, int workId) { try { Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("SupportName", product.SupportName); dictionary.Add("WorkId", workId.ToString()); DataTable dt = GetSupplys(dictionary); //新增有重名数据 if (product.SupplierID == 0 && dt.Rows.Count > 0) { return(false); } else if (product.SupplierID != 0 && dt.Rows.Count > 0) { if (dt.Select("SupplierID=" + product.SupplierID).Length == 1 && dt.Rows.Count > 1) { return(false); } if (dt.Select("SupplierID=" + product.SupplierID).Length == 0 && dt.Rows.Count > 0) { return(false); } } this.BindDb(product); SetWorkId(workId); product.save(); return(true); } catch (Exception) { throw; } }
/// <summary> /// 更新供应商数据 /// </summary> /// <param name="productDic">供应商实体</param> public void UpdateSupply(MW_SupportDic productDic) { productDic.DelFlag = 1; productDic.save(); }