/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Tools_Defination model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Tools_Defination]("); strSql.Append("[WorkceIIID], [WorkceII], [FamilyID], [Family], [Code], [Name], [Model], [PartNo], [UsedFor], [UPL], [Owner], [OwnerNamer], [Remark], [PMperiord], [RecOn], [RecBy], [RecByName], [EditOn], [EditBy], [EditByName] )"); strSql.Append(" values ("); strSql.Append("@WorkceIIID, @WorkceII, @FamilyID, @Family, @Code, @Name, @Model, @PartNo, @UsedFor, @UPL, @Owner, @OwnerNamer, @Remark, @PMperiord, @RecOn, @RecBy, @RecByName, @EditOn, @EditBy, @EditByName )"); strSql.Append(";select @@IDENTITY"); MSSQLHelper h = new MSSQLHelper(); h.CreateCommand(strSql.ToString()); if (model.WorkceIIID == null) { h.AddParameter("@WorkceIIID", DBNull.Value); } else { h.AddParameter("@WorkceIIID", model.WorkceIIID); } if (model.WorkceII == null) { h.AddParameter("@WorkceII", DBNull.Value); } else { h.AddParameter("@WorkceII", model.WorkceII); } if (model.FamilyID == null) { h.AddParameter("@FamilyID", DBNull.Value); } else { h.AddParameter("@FamilyID", model.FamilyID); } if (model.Family == null) { h.AddParameter("@Family", DBNull.Value); } else { h.AddParameter("@Family", model.Family); } if (model.Code == null) { h.AddParameter("@Code", DBNull.Value); } else { h.AddParameter("@Code", model.Code); } if (model.Name == null) { h.AddParameter("@Name", DBNull.Value); } else { h.AddParameter("@Name", model.Name); } if (model.Model == null) { h.AddParameter("@Model", DBNull.Value); } else { h.AddParameter("@Model", model.Model); } if (model.PartNo == null) { h.AddParameter("@PartNo", DBNull.Value); } else { h.AddParameter("@PartNo", model.PartNo); } if (model.UsedFor == null) { h.AddParameter("@UsedFor", DBNull.Value); } else { h.AddParameter("@UsedFor", model.UsedFor); } if (model.UPL == null) { h.AddParameter("@UPL", DBNull.Value); } else { h.AddParameter("@UPL", model.UPL); } if (model.Owner == null) { h.AddParameter("@Owner", DBNull.Value); } else { h.AddParameter("@Owner", model.Owner); } if (model.OwnerNamer == null) { h.AddParameter("@OwnerNamer", DBNull.Value); } else { h.AddParameter("@OwnerNamer", model.OwnerNamer); } if (model.Remark == null) { h.AddParameter("@Remark", DBNull.Value); } else { h.AddParameter("@Remark", model.Remark); } if (model.PMperiord == null) { h.AddParameter("@PMperiord", DBNull.Value); } else { h.AddParameter("@PMperiord", model.PMperiord); } if (model.RecOn == null) { h.AddParameter("@RecOn", DateTime.Now); } else { h.AddParameter("@RecOn", model.RecOn); } if (model.RecBy == null) { h.AddParameter("@RecBy", DBNull.Value); } else { h.AddParameter("@RecBy", model.RecBy); } if (model.RecByName == null) { h.AddParameter("@RecByName", DBNull.Value); } else { h.AddParameter("@RecByName", model.RecByName); } if (model.EditOn == null) { h.AddParameter("@EditOn", DateTime.Now); } else { h.AddParameter("@EditOn", model.EditOn); } if (model.EditBy == null) { h.AddParameter("@EditBy", DBNull.Value); } else { h.AddParameter("@EditBy", model.EditBy); } if (model.EditByName == null) { h.AddParameter("@EditByName", DBNull.Value); } else { h.AddParameter("@EditByName", model.EditByName); } int result; string obj = h.ExecuteScalar(); if (!int.TryParse(obj, out result)) { return(0); } return(result); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Tools_entitys model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Tools_entitys]("); strSql.Append("[Code], [SeqID], [BillNo], [RegDate], [UserCount], [Location] )"); strSql.Append(" values ("); strSql.Append("@Code, @SeqID, @BillNo, @RegDate, @UserCount, @Location )"); strSql.Append(";select @@IDENTITY"); MSSQLHelper h = new MSSQLHelper(); h.CreateCommand(strSql.ToString()); if (model.Code == null) { h.AddParameter("@Code", DBNull.Value); } else { h.AddParameter("@Code", model.Code); } if (model.SeqID == null) { h.AddParameter("@SeqID", DBNull.Value); } else { h.AddParameter("@SeqID", model.SeqID); } if (model.BillNo == null) { h.AddParameter("@BillNo", DBNull.Value); } else { h.AddParameter("@BillNo", model.BillNo); } if (model.RegDate == null) { h.AddParameter("@RegDate", DateTime.Now); } else { h.AddParameter("@RegDate", model.RegDate); } if (model.UserCount == null) { h.AddParameter("@UserCount", DBNull.Value); } else { h.AddParameter("@UserCount", model.UserCount); } if (model.Location == null) { h.AddParameter("@Location", DBNull.Value); } else { h.AddParameter("@Location", model.Location); } int result; string obj = h.ExecuteScalar(); if (!int.TryParse(obj, out result)) { return(0); } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Tools_Defination model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Tools_Defination] set "); strSql.Append("[WorkceIIID]=@WorkceIIID, [WorkceII]=@WorkceII, [FamilyID]=@FamilyID, [Family]=@Family, [Code]=@Code, [Name]=@Name, [Model]=@Model, [PartNo]=@PartNo, [UsedFor]=@UsedFor, [UPL]=@UPL, [Owner]=@Owner, [OwnerNamer]=@OwnerNamer, [Remark]=@Remark, [PMperiord]=@PMperiord, [RecOn]=@RecOn, [RecBy]=@RecBy, [RecByName]=@RecByName, [EditOn]=@EditOn, [EditBy]=@EditBy, [EditByName]=@EditByName "); strSql.Append(" where ID=@ID "); MSSQLHelper h = new MSSQLHelper(); h.CreateCommand(strSql.ToString()); if (model.ID.ToString() == null) { h.AddParameter("@ID", DBNull.Value); } else { h.AddParameter("@ID", model.ID); } if (model.WorkceIIID == null) { h.AddParameter("@WorkceIIID", DBNull.Value); } else { h.AddParameter("@WorkceIIID", model.WorkceIIID); } if (model.WorkceII == null) { h.AddParameter("@WorkceII", DBNull.Value); } else { h.AddParameter("@WorkceII", model.WorkceII); } if (model.FamilyID == null) { h.AddParameter("@FamilyID", DBNull.Value); } else { h.AddParameter("@FamilyID", model.FamilyID); } if (model.Family == null) { h.AddParameter("@Family", DBNull.Value); } else { h.AddParameter("@Family", model.Family); } if (model.Code == null) { h.AddParameter("@Code", DBNull.Value); } else { h.AddParameter("@Code", model.Code); } if (model.Name == null) { h.AddParameter("@Name", DBNull.Value); } else { h.AddParameter("@Name", model.Name); } if (model.Model == null) { h.AddParameter("@Model", DBNull.Value); } else { h.AddParameter("@Model", model.Model); } if (model.PartNo == null) { h.AddParameter("@PartNo", DBNull.Value); } else { h.AddParameter("@PartNo", model.PartNo); } if (model.UsedFor == null) { h.AddParameter("@UsedFor", DBNull.Value); } else { h.AddParameter("@UsedFor", model.UsedFor); } if (model.UPL == null) { h.AddParameter("@UPL", DBNull.Value); } else { h.AddParameter("@UPL", model.UPL); } if (model.Owner == null) { h.AddParameter("@Owner", DBNull.Value); } else { h.AddParameter("@Owner", model.Owner); } if (model.OwnerNamer == null) { h.AddParameter("@OwnerNamer", DBNull.Value); } else { h.AddParameter("@OwnerNamer", model.OwnerNamer); } if (model.Remark == null) { h.AddParameter("@Remark", DBNull.Value); } else { h.AddParameter("@Remark", model.Remark); } if (model.PMperiord == null) { h.AddParameter("@PMperiord", DBNull.Value); } else { h.AddParameter("@PMperiord", model.PMperiord); } if (model.RecOn == null) { h.AddParameter("@RecOn", DBNull.Value); } else { h.AddParameter("@RecOn", model.RecOn); } if (model.RecBy == null) { h.AddParameter("@RecBy", DBNull.Value); } else { h.AddParameter("@RecBy", model.RecBy); } if (model.RecByName == null) { h.AddParameter("@RecByName", DBNull.Value); } else { h.AddParameter("@RecByName", model.RecByName); } if (model.EditOn == null) { h.AddParameter("@EditOn", DBNull.Value); } else { h.AddParameter("@EditOn", model.EditOn); } if (model.EditBy == null) { h.AddParameter("@EditBy", DBNull.Value); } else { h.AddParameter("@EditBy", model.EditBy); } if (model.EditByName == null) { h.AddParameter("@EditByName", DBNull.Value); } else { h.AddParameter("@EditByName", model.EditByName); } return(h.ExecuteNonQuery()); }