/// <summary> /// 将TAKEIN01记录实体由普通的实体(DataAccess.Model.TAKEIN01)转换为SubSonic插件生成的实体 /// </summary> /// <param name="model">普通的实体(DataAccess.Model.TAKEIN01)</param> /// <returns>TAKEIN01</returns> public TAKEIN01 Transform(DataAccess.Model.TAKEIN01 model) { if (model == null) { return(null); } return(new TAKEIN01 { Id = model.Id, SHOP_ID = model.SHOP_ID, TAKEIN_ID = model.TAKEIN_ID, SNo = model.SNo, PROD_ID = model.PROD_ID, QUANTITY = model.QUANTITY, STD_UNIT = model.STD_UNIT, STD_CONVERT = model.STD_CONVERT, STD_QUAN = model.STD_QUAN, STD_PRICE = model.STD_PRICE, COST = model.COST, PLAN_QUAN = model.PLAN_QUAN, IsDispose = model.IsDispose, QUAN1 = model.QUAN1, QUAN2 = model.QUAN2, RELATE_ID = model.RELATE_ID, COM_ID = model.COM_ID, BAT_NO = model.BAT_NO, Exp_DateTime = model.Exp_DateTime, Memo = model.Memo, }); }
/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(DataAccess.Model.TAKEIN01 model) { //从缓存中读取记录列表 var list = GetList(); //从缓存中删除记录 DelCache(model.Id); //添加记录 list.Add(model); }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="dic">列名与值</param> public void SetModelValue(DataAccess.Model.TAKEIN01 model, Dictionary <string, object> dic) { if (model == null || dic == null) { return; } //遍历字典,逐个给字段赋值 foreach (var d in dic) { SetModelValue(model, d.Key, d.Value); } }
/// <summary> /// 给实体赋值 /// </summary> /// <param name="model">实体</param> /// <param name="colName">列名</param> /// <param name="value">值</param> public void SetModelValue(DataAccess.Model.TAKEIN01 model, string colName, object value) { if (model == null || string.IsNullOrEmpty(colName)) { return; } //返回指定条件的实体 switch (colName) { case "Id": model.Id = (int)value; break; case "SHOP_ID": model.SHOP_ID = (string)value; break; case "TAKEIN_ID": model.TAKEIN_ID = (string)value; break; case "SNo": model.SNo = (int)value; break; case "PROD_ID": model.PROD_ID = (string)value; break; case "QUANTITY": model.QUANTITY = (decimal)value; break; case "STD_UNIT": model.STD_UNIT = (string)value; break; case "STD_CONVERT": model.STD_CONVERT = (int)value; break; case "STD_QUAN": model.STD_QUAN = (decimal)value; break; case "STD_PRICE": model.STD_PRICE = (decimal)value; break; case "COST": model.COST = (decimal)value; break; case "PLAN_QUAN": model.PLAN_QUAN = (decimal)value; break; case "IsDispose": model.IsDispose = ConvertHelper.Ctinyint(value); break; case "QUAN1": model.QUAN1 = (decimal)value; break; case "QUAN2": model.QUAN2 = (decimal)value; break; case "RELATE_ID": model.RELATE_ID = (string)value; break; case "COM_ID": model.COM_ID = (string)value; break; case "BAT_NO": model.BAT_NO = (string)value; break; case "Exp_DateTime": model.Exp_DateTime = (DateTime)value; break; case "Memo": model.Memo = (string)value; break; } }
/// <summary> /// 从IIS缓存中获取指定Id记录 /// </summary> /// <param name="conditionColName">条件列名</param> /// <param name="value">条件值</param> /// <returns>DataAccess.Model.TAKEIN01</returns> public DataAccess.Model.TAKEIN01 GetModelForCache(string conditionColName, object value) { try { //从缓存中获取List var list = GetList(); DataAccess.Model.TAKEIN01 model = null; Expression <Func <TAKEIN01, bool> > expression = null; //返回指定条件的实体 switch (conditionColName) { case "Id": model = list.SingleOrDefault(x => x.Id == (int)value); expression = x => x.Id == (int)value; break; case "SHOP_ID": model = list.SingleOrDefault(x => x.SHOP_ID == (string)value); expression = x => x.SHOP_ID == (string)value; break; case "TAKEIN_ID": model = list.SingleOrDefault(x => x.TAKEIN_ID == (string)value); expression = x => x.TAKEIN_ID == (string)value; break; case "SNo": model = list.SingleOrDefault(x => x.SNo == (int)value); expression = x => x.SNo == (int)value; break; case "PROD_ID": model = list.SingleOrDefault(x => x.PROD_ID == (string)value); expression = x => x.PROD_ID == (string)value; break; case "QUANTITY": model = list.SingleOrDefault(x => x.QUANTITY == (decimal)value); expression = x => x.QUANTITY == (decimal)value; break; case "STD_UNIT": model = list.SingleOrDefault(x => x.STD_UNIT == (string)value); expression = x => x.STD_UNIT == (string)value; break; case "STD_CONVERT": model = list.SingleOrDefault(x => x.STD_CONVERT == (int)value); expression = x => x.STD_CONVERT == (int)value; break; case "STD_QUAN": model = list.SingleOrDefault(x => x.STD_QUAN == (decimal)value); expression = x => x.STD_QUAN == (decimal)value; break; case "STD_PRICE": model = list.SingleOrDefault(x => x.STD_PRICE == (decimal)value); expression = x => x.STD_PRICE == (decimal)value; break; case "COST": model = list.SingleOrDefault(x => x.COST == (decimal)value); expression = x => x.COST == (decimal)value; break; case "PLAN_QUAN": model = list.SingleOrDefault(x => x.PLAN_QUAN == (decimal)value); expression = x => x.PLAN_QUAN == (decimal)value; break; case "IsDispose": model = list.SingleOrDefault(x => x.IsDispose == (byte)value); expression = x => x.IsDispose == (byte)value; break; case "QUAN1": model = list.SingleOrDefault(x => x.QUAN1 == (decimal)value); expression = x => x.QUAN1 == (decimal)value; break; case "QUAN2": model = list.SingleOrDefault(x => x.QUAN2 == (decimal)value); expression = x => x.QUAN2 == (decimal)value; break; case "RELATE_ID": model = list.SingleOrDefault(x => x.RELATE_ID == (string)value); expression = x => x.RELATE_ID == (string)value; break; case "COM_ID": model = list.SingleOrDefault(x => x.COM_ID == (string)value); expression = x => x.COM_ID == (string)value; break; case "BAT_NO": model = list.SingleOrDefault(x => x.BAT_NO == (string)value); expression = x => x.BAT_NO == (string)value; break; case "Exp_DateTime": model = list.SingleOrDefault(x => x.Exp_DateTime == (DateTime)value); expression = x => x.Exp_DateTime == (DateTime)value; break; case "Memo": model = list.SingleOrDefault(x => x.Memo == (string)value); expression = x => x.Memo == (string)value; break; default: return(null); } if (model == null) { //从数据库中读取 var tem = TAKEIN01.SingleOrDefault(expression); if (tem == null) { return(null); } else { //对查询出来的实体进行转换 model = Transform(tem); return(model); } } else { return(model); } } catch (Exception e) { //记录日志 CommonBll.WriteLog("从IIS缓存中获取TAKEIN01表记录时出现异常", e); return(null); } }
/// <summary> /// 返回实体中指定字段名的值 /// </summary> /// <param name="model">实体</param> /// <param name="colName">获取的字段名</param> /// <returns></returns> private object GetFieldValue(DataAccess.Model.TAKEIN01 model, string colName) { if (model == null || string.IsNullOrEmpty(colName)) { return(null); } //返回指定的列值 switch (colName) { case "Id": return(model.Id); case "SHOP_ID": return(model.SHOP_ID); case "TAKEIN_ID": return(model.TAKEIN_ID); case "SNo": return(model.SNo); case "PROD_ID": return(model.PROD_ID); case "QUANTITY": return(model.QUANTITY); case "STD_UNIT": return(model.STD_UNIT); case "STD_CONVERT": return(model.STD_CONVERT); case "STD_QUAN": return(model.STD_QUAN); case "STD_PRICE": return(model.STD_PRICE); case "COST": return(model.COST); case "PLAN_QUAN": return(model.PLAN_QUAN); case "IsDispose": return(model.IsDispose); case "QUAN1": return(model.QUAN1); case "QUAN2": return(model.QUAN2); case "RELATE_ID": return(model.RELATE_ID); case "COM_ID": return(model.COM_ID); case "BAT_NO": return(model.BAT_NO); case "Exp_DateTime": return(model.Exp_DateTime); case "Memo": return(model.Memo); } return(null); }