public override void SetModel(M_Base modelBase) { M_Department modelEntity = modelBase as M_Department; _model = modelEntity; Id = modelEntity.Id; DepartmentName = modelEntity.DepartmentName; Director = modelEntity.Director; Employers = modelEntity.Employee; }
public override void SetModel(M_Base modelBase) { M_CalendarDate modelEntity = modelBase as M_CalendarDate; _model = modelEntity; Id = modelEntity.Id; Start = modelEntity.Start; End = modelEntity.End; NameEmployer = GetName(modelEntity.Employee?.PersonInfo); TypeDate = modelEntity.TypeDate; _employer = modelEntity?.Employee; }
public static int Insert(M_Base data, SqlBase db) { SqlModel model = new SqlModel() { cmd = SqlCmd.Insert, tbName = data.TbName, pk = data.PK }; model.AddSpToList(data.GetParameters()); model.fields = DB.GetFields(data); model.values = DB.GetParams(data); PreSPList(model); return(db.InsertID(model)); }
/// <summary> /// 获取字段=参数(Update) /// </summary> public static string GetFieldAndPara(M_Base model) { string str = string.Empty, PK = model.PK.ToLower(); string[,] strArr = model.FieldList(); for (int i = 0; i < strArr.GetLength(0); i++) { if (strArr[i, 0].ToLower() != PK) { str += "[" + strArr[i, 0] + "]=@" + strArr[i, 0] + ","; } } return(str.Substring(0, str.Length - 1)); }
public override string GetParams(M_Base model) { string str = string.Empty, PK = model.PK.ToLower(); string[,] strArr = model.FieldList(); for (int i = 0; i < strArr.GetLength(0); i++) { if (strArr[i, 0].ToLower() != PK) { str += "@" + strArr[i, 0] + ",";//: } } return(str.Substring(0, str.Length - 1)); }
public static bool UpdateByID(M_Base data, int id) { SqlModel model = new SqlModel() { cmd = SqlCmd.Update, tbName = data.TbName, pk = data.PK }; model.AddSpToList(data.GetParameters()); model.sql = "UPDATE " + data.TbName + " SET " + DB.GetFieldAndParam(data) + " WHERE " + data.PK + "=" + id; PreSPList(model); DB.ExecuteNonQuery(model); return(true); }
public override void SetModel(M_Base model) { throw new NotImplementedException(); }
public static int Insert(M_Base data) { return(Insert(data, DBCenter.DB)); }
public abstract string GetFieldAndParam(M_Base model);
public abstract string GetParams(M_Base model);
public abstract string GetFields(M_Base model);
public abstract void SetModel(M_Base model);
public ViewModel(M_Base model) { SetModel(model); }