public int DataUpdate(FunctionModifyReq req) { int count = 0; using (DbCommand cmd = Db.CreateConnection().CreateCommand()) { string sql = @" UPDATE FUNCTIONS SET NAME=@NAME,CATEGORY=@CATEGORY,PARENT_SN=@PARENT_SN,URL=@URL,SORT=@SORT ,MODE=@MODE,MDATE=GETDATE(),MUSER=@MUSER WHERE SN=@SN; "; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; Db.AddInParameter(cmd, "SN", DbType.String, req.FUNCTIONS.SN); Db.AddInParameter(cmd, "NAME", DbType.String, req.FUNCTIONS.NAME); Db.AddInParameter(cmd, "CATEGORY", DbType.String, req.FUNCTIONS.CATEGORY); Db.AddInParameter(cmd, "PARENT_SN", DbType.Int16, req.FUNCTIONS.PARENT_SN); Db.AddInParameter(cmd, "URL", DbType.String, req.FUNCTIONS.URL); Db.AddInParameter(cmd, "SORT", DbType.Int16, req.FUNCTIONS.SORT); Db.AddInParameter(cmd, "MODE", DbType.String, req.FUNCTIONS.MODE); //Db.AddInParameter(cmd, "MDATE", DbType.DateTime, req.FUNCTIONS.MDATE); Db.AddInParameter(cmd, "MUSER", DbType.Int16, req.FUNCTIONS.MUSER); count = Db.ExecuteNonQuery(cmd); } return(count); }
public int DataCreate(FunctionModifyReq req) { int count = 0; using (DbCommand cmd = Db.CreateConnection().CreateCommand()) { string sql = @" INSERT INTO FUNCTIONS (NAME,CATEGORY,PARENT_SN,URL,SORT,MODE,CDATE,CUSER,MDATE,MUSER) VALUES (@NAME,@CATEGORY,@PARENT_SN,@URL,@SORT,@MODE,GETDATE(),@CUSER,GETDATE(),@MUSER) SET @SN = SCOPE_IDENTITY();"; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; Db.AddInParameter(cmd, "NAME", DbType.String, req.FUNCTIONS.NAME); Db.AddInParameter(cmd, "CATEGORY", DbType.String, req.FUNCTIONS.CATEGORY); Db.AddInParameter(cmd, "PARENT_SN", DbType.Int16, req.FUNCTIONS.PARENT_SN); Db.AddInParameter(cmd, "URL", DbType.String, req.FUNCTIONS.URL); Db.AddInParameter(cmd, "SORT", DbType.Int16, req.FUNCTIONS.SORT); Db.AddInParameter(cmd, "MODE", DbType.String, req.FUNCTIONS.MODE); //Db.AddInParameter(cmd, "CDATE", DbType.DateTime, req.FUNCTIONS.CDATE); Db.AddInParameter(cmd, "CUSER", DbType.Int16, req.FUNCTIONS.CUSER); //Db.AddInParameter(cmd, "MDATE", DbType.DateTime, req.FUNCTIONS.MDATE); Db.AddInParameter(cmd, "MUSER", DbType.Int16, req.FUNCTIONS.MUSER); Db.AddOutParameter(cmd, "SN", DbType.Int16, 1); count = Db.ExecuteNonQuery(cmd); req.FUNCTIONS.SN = Db.GetParameterValue(cmd, "SN") as Int16? ?? null; } return(count); }