Beispiel #1
0
        public int Update(int?SID, string ID, string MasterID, TestDetailInfo entity)
        {
            if (!SID.HasValue & string.IsNullOrEmpty(ID) & string.IsNullOrEmpty(MasterID))
            {
                return(0);
            }
            Database      db    = base.GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.Append(@"
             UPDATE [TestDetail]
             SET 
             [A] = @A
             ,[B] = @B
             ,[C] = @C
             ,[D] = @D    
             ,[E] = @E
             ,[F] = @F
             ,[G] = @G
             WHERE (1=1)
");
            if (SID.HasValue)
            {
                sbCmd.Append("AND SID=@SID");
            }
            if (!string.IsNullOrEmpty(ID))
            {
                sbCmd.Append("AND ID=@ID");
            }
            if (!string.IsNullOrEmpty(MasterID))
            {
                sbCmd.Append("AND MasterID=@MasterID");
            }

            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());


            if (SID.HasValue)
            {
                db.AddInParameter(dbCommand, "@SID", DbType.Int32, SID.Value);
            }
            if (!string.IsNullOrEmpty(ID))
            {
                db.AddInParameter(dbCommand, "@ID", DbType.String, entity.ID);
            }
            if (!string.IsNullOrEmpty(MasterID))
            {
                db.AddInParameter(dbCommand, "@MasterID", DbType.String, entity.MasterID);
            }

            db.AddInParameter(dbCommand, "@A", DbType.String, entity.A);
            db.AddInParameter(dbCommand, "@B", DbType.String, entity.B);
            db.AddInParameter(dbCommand, "@C", DbType.String, entity.C);
            db.AddInParameter(dbCommand, "@D", DbType.String, entity.D);
            db.AddInParameter(dbCommand, "@E", DbType.String, entity.E);
            db.AddInParameter(dbCommand, "@F", DbType.String, entity.F);
            db.AddInParameter(dbCommand, "@G", DbType.String, entity.G);
            return(db.ExecuteNonQuery(dbCommand));
        }
Beispiel #2
0
        public int Insert(TestDetailInfo entity)
        {
            Database      db    = base.GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.Append(@"
INSERT INTO [TestDetail]
           ([ID]
           ,[MasterID]
           ,[A]
           ,[B]
           ,[C]
           ,[D]
           ,[E]
           ,[F]
           ,[G])
     VALUES
           
           (@ID
           ,@MasterID
           ,@A
           ,@B
           ,@C
           ,@D
           ,@E
           ,@F
           ,@G)
");
            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());

            #region Add In Parameter
            db.AddInParameter(dbCommand, "@ID", DbType.String, entity.ID);
            db.AddInParameter(dbCommand, "@MasterID", DbType.String, entity.MasterID);
            db.AddInParameter(dbCommand, "@A", DbType.String, entity.A);
            db.AddInParameter(dbCommand, "@B", DbType.String, entity.B);
            db.AddInParameter(dbCommand, "@C", DbType.String, entity.C);
            db.AddInParameter(dbCommand, "@D", DbType.String, entity.D);
            db.AddInParameter(dbCommand, "@E", DbType.String, entity.E);
            db.AddInParameter(dbCommand, "@F", DbType.String, entity.F);
            db.AddInParameter(dbCommand, "@G", DbType.String, entity.G);


            #endregion

            return(db.ExecuteNonQuery(dbCommand));
        }
Beispiel #3
0
            /// <summary>
            /// 修改
            /// </summary>

            /// <returns></returns>
            public int Update(int?SID, string ID, string MasterID, TestDetailInfo entity)
            {
                var result = 0;

                try
                {
                    var db = new TestDetailDB();
                    result = db.Update(SID, ID, MasterID, entity);
                }
                catch (Exception ex)
                {
                    var dbExpLog = new ExpLogDB();
                    dbExpLog.Insert(new ExpLogInfo {
                        ClassName = "TestBiz.Detail", MethodName = "Update", ErrMsg = ex.Message
                    });
                }
                return(result);
            }
Beispiel #4
0
            /// <summary>
            /// 取一筆資料

            /// <returns></returns>
            public TestDetailInfo Load(int?SID, string MasterID, string ID)
            {
                TestDetailInfo result = null;

                try
                {
                    var db = new TestDetailDB();
                    result = db.Load(SID, ID, MasterID);
                }
                catch (Exception ex)
                {
                    var dbExpLog = new ExpLogDB();
                    dbExpLog.Insert(new ExpLogInfo {
                        ClassName = "TestBiz.Detail", MethodName = "Load", ErrMsg = ex.Message
                    });
                }
                return(result);
            }
Beispiel #5
0
            /// <summary>
            /// 新增
            /// </summary>
            /// <param name="entity"></param>
            /// <returns></returns>
            public int Insert(TestDetailInfo entity)
            {
                var result = 0;

                try
                {
                    var db = new TestDetailDB();
                    result = db.Insert(entity);
                }
                catch (Exception ex)
                {
                    var dbExpLog = new ExpLogDB();
                    dbExpLog.Insert(new ExpLogInfo {
                        ClassName = "TestBiz.Detail", MethodName = "Insert", ErrMsg = ex.Message
                    });
                }
                return(result);
            }