public static FamilyExtra GetExtraValue(CMSDataContext db, int pid, string field) { var fid = (from v in db.People where v.PeopleId == pid select v.FamilyId).SingleOrDefault(); if (fid == 0) { return(null); } //field = field.Replace('/', '-'); var q = from v in db.FamilyExtras where v.Field == field where v.FamilyId == fid select v; var ev = q.SingleOrDefault(); if (ev == null) { ev = new FamilyExtra { FamilyId = fid, Field = field, TransactionTime = DateTime.Now }; db.FamilyExtras.InsertOnSubmit(ev); } return(ev); }
public static FamilyExtra GetExtraValueFamilyId(CMSDataContext db, int fid, string field) { if (fid == 0) { return(null); } field = field.Trim(); var q = from v in db.FamilyExtras where v.Field == field where v.FamilyId == fid select v; var ev = q.SingleOrDefault(); if (ev == null) { ev = new FamilyExtra { FamilyId = fid, Field = field, TransactionTime = DateTime.Now }; db.FamilyExtras.InsertOnSubmit(ev); } return(ev); }
public ExtraValue(FamilyExtra v, ExtraValueModel model) { Type = v.Type; Field = v.Field; StrValue = v.StrValue; DateValue = v.DateValue; Data = v.Data; IntValue = v.IntValue; BitValue = v.BitValue; Id = v.FamilyId; Model = model; }
public void SetExtra(string field, string value) { var e = FamilyExtras.FirstOrDefault(ee => ee.Field == field); if (e == null) { e = new FamilyExtra { Field = field, FamilyId = FamilyId, TransactionTime = DateTime.Now }; this.FamilyExtras.Add(e); } e.StrValue = value; }
public FamilyExtra GetExtraValue(string field) { if (!field.HasValue()) { field = "blank"; } //field = field.Replace(",", "_"); var ev = FamilyExtras.AsEnumerable().FirstOrDefault(ee => string.Compare(ee.Field, field, ignoreCase: true) == 0); if (ev == null) { ev = new FamilyExtra { FamilyId = FamilyId, Field = field, TransactionTime = DateTime.Now }; FamilyExtras.Add(ev); } return(ev); }
public FamilyExtra GetExtraValue(string field) { if (!field.HasValue()) { field = "blank"; } field = field.Trim(); var ev = FamilyExtras.AsEnumerable().FirstOrDefault(ee => ee.Field == field); if (ev == null) { ev = new FamilyExtra { FamilyId = FamilyId, Field = field, TransactionTime = DateTime.Now }; FamilyExtras.Add(ev); } return(ev); }
internal static Field AddField(Field f, FamilyExtra v) { if (f == null) { f = new Field { name = v.Field, nonstandard = true, familyid = v.FamilyId, extravalue = v, }; f.type = v.StrValue.HasValue() ? "Code" : v.Data.HasValue() ? "Data" : v.DateValue.HasValue ? "Date" : v.IntValue.HasValue ? "Int" : v.BitValue.HasValue ? "Bit" : "Code"; } f.extravalue = v; return f; }
public FamilyExtra GetExtraValue(string field) { if (!field.HasValue()) field = "blank"; field = field.Replace(",", "_"); var ev = FamilyExtras.AsEnumerable().FirstOrDefault(ee => string.Compare(ee.Field, field, ignoreCase:true) == 0); if (ev == null) { ev = new FamilyExtra { FamilyId = FamilyId, Field = field, TransactionTime = DateTime.Now }; FamilyExtras.Add(ev); } return ev; }
private void detach_FamilyExtras(FamilyExtra entity) { this.SendPropertyChanging(); entity.Family = null; }
private void attach_FamilyExtras(FamilyExtra entity) { this.SendPropertyChanging(); entity.Family = this; }
public static FamilyExtra GetExtraValue(CMSDataContext db, int pid, string field) { var fid = (from v in db.People where v.PeopleId == pid select v.FamilyId).SingleOrDefault(); if (fid == 0) return null; //field = field.Replace('/', '-'); var q = from v in db.FamilyExtras where v.Field == field where v.FamilyId == fid select v; var ev = q.SingleOrDefault(); if (ev == null) { ev = new FamilyExtra { FamilyId = fid, Field = field, TransactionTime = DateTime.Now }; db.FamilyExtras.InsertOnSubmit(ev); } return ev; }
public ActionResult NewExtraValue(int id, string field, string type, string value) { var v = new FamilyExtra { FamilyId = id, Field = field }; DbUtil.Db.FamilyExtras.InsertOnSubmit(v); switch (type) { case "string": v.StrValue = value; break; case "text": v.Data = value; break; case "date": var dt = DateTime.MinValue; DateTime.TryParse(value, out dt); v.DateValue = dt; break; case "int": v.IntValue = value.ToInt(); break; } try { DbUtil.Db.SubmitChanges(); } catch (Exception ex) { return Content("error: " + ex.Message); } return Content("ok"); }