/// <summary> /// 提交添加 /// </summary> private bool SubmintAdd() { try { var member = new LHCustomerLink { FCode = txtFCode.Text.Trim(), FName = tbxFCustomer.Text.Trim(), FAddress = txtFAddress.Text.Trim(), FLinkman = txtFLinkman.Text.Trim(), FPhome = txtFPhome.Text.Trim(), FMoile = txtFMoile.Text.Trim(), FMemo = txtFMemo.Text.Trim(), FSpell = ChineseSpell.MakeSpellCode(tbxFCustomer.Text.Trim(), "", SpellOptions.FirstLetterOnly).ToUpper(), FCompanyId = CurrentUser.AccountComId, FCity = txtFCity.Text.Trim(), FZip = txtFZip.Text.Trim(), }; return(CustomerLinkService.Add(member)); } catch (Exception ex) { throw; } }
private void GridEdit() { #region update var dictModified = Grid1.GetModifiedDict(); foreach (var rowKey in dictModified.Keys) { int datakey = Convert.ToInt32(Grid1.DataKeys[rowKey][1].ToString()); var sKeys = new StringBuilder(); var sValues = new StringBuilder(); foreach (var key in dictModified[rowKey].Keys) { sKeys.AppendFormat("{0},", key); } foreach (var dictValue in dictModified[rowKey].Values) { sValues.AppendFormat("{0},", dictValue); } var details = CustomerLinkService.Where(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault(); var keys = sKeys.ToString().Split(','); var values = sValues.ToString().Split(','); for (int i = 0; i < keys.Count(); i++) { #region 修改内容 var key = keys[i]; var value = values[i]; if (!string.IsNullOrEmpty(key)) { if (details != null) { if (key.Equals("FLinkman")) { details.FLinkman = value; } if (key.Equals("FAddress")) { details.FAddress = value; } if (key.Equals("FPhome")) { details.FPhome = value; } if (key.Equals("FMoile")) { details.FMoile = value; } if (key.Equals("FMemo")) { details.FMemo = value; } if (key.Equals("FType")) { details.FType = value; } } } #endregion } CustomerLinkService.SaveChanges(); } #endregion var addList = Grid1.GetNewAddedList(); #region AddRow foreach (var add in addList) { var sKeys = new StringBuilder(); var sValues = new StringBuilder(); foreach (var key in add.Keys) { sKeys.AppendFormat("{0},", key); } foreach (var dictValue in add.Values) { sValues.AppendFormat("{0},", dictValue); } var keys = sKeys.ToString().Split(','); var values = sValues.ToString().Split(','); var details = new LHCustomerLink(); for (int i = 0; i < keys.Count(); i++) { #region 修改内容 details.FCompanyId = CurrentUser.AccountComId; details.FCode = FCode; var key = keys[i]; var value = values[i]; if (!string.IsNullOrEmpty(key)) { if (key.Equals("FLinkman")) { details.FLinkman = value; } if (key.Equals("FAddress")) { details.FAddress = value; } if (key.Equals("FPhome")) { details.FPhome = value; } if (key.Equals("FMoile")) { details.FMoile = value; } if (key.Equals("FMemo")) { details.FMemo = value; } if (key.Equals("FType")) { details.FType = value; } } #endregion } CustomerLinkService.Add(details); } #endregion }