public ActionResult Edit(ItempropertyInfo itempropertyInfo) { if (itempropertyInfo.ItemPropertyID == 0) { return Insert(itempropertyInfo); } else { return Update(itempropertyInfo); } }
/// <summary> /// 更新一条Itemproperty记录 /// </summary> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行更新对数据库影响的行数</returns> public int UpdateItemproperty(ItempropertyInfo itempropertyInfo) { return itempropertyDA.UpdateItemproperty(itempropertyInfo); }
/// <summary> /// 新增一条Itemproperty记录 /// </summary> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行新增对数据库影响的行数</returns> public int InsertItemproperty(ItempropertyInfo itempropertyInfo) { return itempropertyDA.InsertItemproperty(itempropertyInfo); }
public ActionResult Insert(ItempropertyInfo itempropertyInfo) { try { itempropertyInfo.CreatedDate = DateTime.Now; itempropertyInfo.UpdatedDate = DateTime.Now; itempropertyInfo.CreatedBy = CurrentUserInfo.UserCode; itempropertyInfo.UpdatedBy = CurrentUserInfo.UserCode; IItempropertyService itempropertyService = UnityHelper.UnityResolve<IItempropertyService>(); var data = itempropertyService.InsertItemproperty(itempropertyInfo); LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Insert ItempropertyInfo {0},{1}", LogHelper.ChangeEntityToLog(itempropertyInfo), data)); if (data > 0) { return Content("OK"); } else { return Content("Failed"); } } catch (BusinessException bex) { return Content(bex.Message); } catch (Exception ex) { LogHelper.LogError(ex, ""); return Content(ex.Message); } }
/// <summary> /// 设置SQL参数表 /// </summary> /// <param name="Itemproperty">Itemproperty对象</param> /// <returns>Itemproperty参数数组</returns> private SqlParameter[] Set_Itemproperty_Parameters(ItempropertyInfo itempropertyInfo) { SqlParameter[] paramArray = new SqlParameter[] {new SqlParameter("@ItemPropertyID",itempropertyInfo.ItemPropertyID), new SqlParameter("@PropertyName",string.IsNullOrEmpty(itempropertyInfo.PropertyName)?"":itempropertyInfo.PropertyName), new SqlParameter("@Descr",string.IsNullOrEmpty(itempropertyInfo.Descr)?"":itempropertyInfo.Descr), new SqlParameter("@Remark",string.IsNullOrEmpty(itempropertyInfo.Remark)?"":itempropertyInfo.Remark), new SqlParameter("@IsActive",string.IsNullOrEmpty(itempropertyInfo.IsActive)?"":itempropertyInfo.IsActive), new SqlParameter("@CreatedBy",string.IsNullOrEmpty(itempropertyInfo.CreatedBy)?"":itempropertyInfo.CreatedBy), new SqlParameter("@UpdatedBy",string.IsNullOrEmpty(itempropertyInfo.UpdatedBy)?"":itempropertyInfo.UpdatedBy) }; return paramArray; }
/// <summary> /// 初始化ItempropertyInfo /// </summary> private ItempropertyInfo InitItempropertyInfoByDataReader(ItempropertyInfo itempropertyInfo, IDataReader reader) { itempropertyInfo = new ItempropertyInfo(reader["ItemPropertyID"].ToString() != "" ? Int32.Parse(reader["ItemPropertyID"].ToString()) : 0, reader["PropertyName"].ToString(), reader["Descr"].ToString(), reader["Remark"].ToString(), reader["IsActive"].ToString(), reader["CreatedBy"].ToString(), reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(), reader["UpdatedBy"].ToString(), reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime()); return itempropertyInfo; }
/// <summary> /// 更新一条Itemproperty记录 /// </summary> /// <param name="db">DataBase对象</param> /// <param name="tran">一个有效的DbTransaction</param> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行更新对数据库影响的行数</returns> public int UpdateItemproperty(Database db, DbTransaction tran, ItempropertyInfo itempropertyInfo) { int result = 0; SqlParameter[] paras = Set_Itemproperty_Parameters(itempropertyInfo); if (paras != null) { result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_ITEMPROPERTY, paras); } return result; }
/// <summary> /// 新增一条Itemproperty记录 /// </summary> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行新增对数据库影响的行数</returns> public int InsertItemproperty(ItempropertyInfo itempropertyInfo) { int result = 0; SqlParameter[] paras = Set_Itemproperty_Parameters(itempropertyInfo); if (paras != null) { result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_ITEMPROPERTY, paras); } return result; }