public int Update(CompanyPurchaseGoupInfo info, out string errorMessage) { errorMessage = string.Empty; if (info == null || info.CompanyId == Guid.Empty) { errorMessage = "参数不能为空"; return(0); } string sql = string.Format("UPDATE [CompanyPurchaseGoup] SET [PurchaseGroupName]=@PurchaseGroupName WHERE [CompanyId]='{0}' AND [PurchaseGroupId]='{1}'", info.CompanyId, info.PurchaseGroupId); var parms = new[] { new SqlParameter("@PurchaseGroupName", SqlDbType.VarChar) }; parms[0].Value = info.PurchaseGroupName; try { return(SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, sql, parms)); } catch (Exception ex) { errorMessage = ex.Message; throw new ApplicationException(ex.Message); } }
public int Insert(CompanyPurchaseGoupInfo info, out string errorMessage) { errorMessage = string.Empty; if (info == null || info.CompanyId == Guid.Empty) { errorMessage = "参数不能为空"; return(0); } string sql = string.Format("INSERT INTO [CompanyPurchaseGoup]([CompanyId],[PurchaseGroupId],[PurchaseGroupName],[OrderIndex]) VALUES('{0}','{1}',@PurchaseGroupName,{2})", info.CompanyId, info.PurchaseGroupId, info.OrderIndex); var parms = new[] { new SqlParameter("@PurchaseGroupName", SqlDbType.VarChar) }; parms[0].Value = info.PurchaseGroupName; try { return(SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, sql, parms)); } catch (Exception ex) { errorMessage = ex.Message; throw new ApplicationException(ex.Message); } }