public ActionResult Update(ItempropertyInfo itempropertyInfo) { try { itempropertyInfo.UpdatedBy = CurrentUserInfo.UserName; itempropertyInfo.UpdatedDate = DateTime.Now; IItempropertyService itempropertyService = UnityHelper.UnityResolve <IItempropertyService>(); var data = itempropertyService.UpdateItemproperty(itempropertyInfo); LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Update 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> /// 更新一条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); }
public ActionResult Edit(ItempropertyInfo itempropertyInfo) { if (itempropertyInfo.ItemPropertyID == 0) { return(Insert(itempropertyInfo)); } else { return(Update(itempropertyInfo)); } }
/// <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> /// 根据itempropertyID得到一条Itemproperty记录 /// </summary> /// <param name="itempropertyID">itempropertyID</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据itempropertyID得到一条Itemproperty记录</returns> public ItempropertyInfo GetItempropertyByID(string itempropertyID) { string sql = SQL_SELECT_ALL_ITEMPROPERTY + " AND ITEMPROPERTYID = @ITEMPROPERTYID "; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ITEMPROPERTYID", itempropertyID) }; ItempropertyInfo itempropertyInfo = null; using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras)) { if (reader.Read()) { itempropertyInfo = InitItempropertyInfoByDataReader(itempropertyInfo, reader); } } return(itempropertyInfo); }
/// <summary> /// 根据itempropertyID得到一条Itemproperty记录 /// </summary> /// <param name="db">DataBase对象</param> /// <param name="tran">一个有效的DbTransaction</param> /// <param name="itempropertyID">itempropertyID</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据itempropertyID得到一条Itemproperty记录</returns> public ItempropertyInfo GetItempropertyByID(Database db, DbTransaction tran, string itempropertyID) { string sql = SQL_SELECT_ALL_ITEMPROPERTY + " AND ITEMPROPERTYID = @ITEMPROPERTYID "; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ITEMPROPERTYID", itempropertyID) }; ItempropertyInfo itempropertyInfo = null; IDataReader reader = DBHelper.ExecuteReader(db, tran, CommandType.Text, sql, paras); if (reader.Read()) { itempropertyInfo = InitItempropertyInfoByDataReader(itempropertyInfo, reader); } if (!reader.IsClosed) { reader.Close(); } return(itempropertyInfo); }
/// <summary> /// 新增一条Itemproperty记录 /// </summary> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行新增对数据库影响的行数</returns> public int InsertItemproperty(ItempropertyInfo itempropertyInfo) { return(itempropertyDA.InsertItemproperty(itempropertyInfo)); }
/// <summary> /// 更新一条Itemproperty记录 /// </summary> /// <param name="itemproperty">Itemproperty对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行更新对数据库影响的行数</returns> public int UpdateItemproperty(ItempropertyInfo itempropertyInfo) { return(itempropertyDA.UpdateItemproperty(itempropertyInfo)); }