private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { var m = ctx.LineOfOperation.Find(this.LineOfOperationId); if (m == null) { m = new EF6.LineOfOperation(); m.LineOfOperationId = new Guid(); ctx.LineOfOperation.Add(m); m.LineOfOperationCode = txtLineOfOperationCode.Text; } m.LineOfOperationName = txtLineOfOperationName.Text; m.LineOfOperationName_Chs = txtLineOfOperationNameAlt1.Text; m.LineOfOperationName_Cht = txtLineOfOperationNameAlt2.Text; m.CurrencyCode = cboCurrency.Text; m.PrimaryLine = chkPrimaryLine.Checked; m.ParentLine = (cboParentLine.SelectedValue == null) ? Guid.Empty : new Guid(cboParentLine.SelectedValue.ToString()); ctx.SaveChanges(); result = true; } return(result); }
private static string GetFormatedText(EF6.LineOfOperation target, string[] textField, string textFormatString) { for (int i = 0; i < textField.Length; i++) { PropertyInfo pi = target.GetType().GetProperty(textField[i]); textFormatString = textFormatString.Replace("{" + i.ToString() + "}", pi != null ? pi.GetValue(target, null).ToString() : string.Empty); } return(textFormatString); }