Ejemplo n.º 1
0
 public int EditLog(Wxqunfa_log log)
 {
     using (var helper = new SqlHelper())
     {
         int id = new InternalWxqunfa_log(helper).EditLog(log);
         return(id);
     }
 }
Ejemplo n.º 2
0
        internal int EditLog(Wxqunfa_log log)
        {
            string sql = @"INSERT INTO [EtownDB].[dbo].[wxqunfa_log]
           ([msgtype],[media_id] ,[content],[sendtime],[errcode] ,[errmsg],[msg_id] ,[userid],[channelcompanyid] ,[comid] ,[yearmonth],[yearmonthday],[weixins])
     VALUES
           (@msgtype
           ,@media_id
           ,@content
           ,@sendtime
           ,@errcode
           ,@errmsg
           ,@msg_id
           ,@userid
           ,@channelcompanyid
           ,@comid
           ,@yearmonth
           ,@yearmonthday
           ,@weixins);select @@IDENTITY;";

            if (log.Id > 0)
            {
                sql = @" UPDATE [EtownDB].[dbo].[wxqunfa_log]
                       SET [msgtype] = @msgtype
                          ,[media_id] = @media_id
                          ,[content] = @content
                          ,[sendtime] = @sendtime
                          ,[errcode] = @errcode
                          ,[errmsg] = @errmsg
                          ,[msg_id] = @msg_id
                          ,[userid] = @userid
                          ,[channelcompanyid] = @channelcompanyid
                          ,[comid] = @comid
                          ,[yearmonth] = @yearmonth
                          ,[yearmonthday] = @yearmonthday
                          ,[weixins] = @weixins
                     WHERE id=@id";
            }
            var cmd = sqlHelper.PrepareTextSqlCommand(sql);

            cmd.AddParam("@msgtype", log.Msgtype);
            cmd.AddParam("@media_id", log.Media_id);
            cmd.AddParam("@content", log.Content);
            cmd.AddParam("@sendtime", log.Sendtime);
            cmd.AddParam("@errcode", log.Errcode);
            cmd.AddParam("@errmsg", log.Errmsg);
            cmd.AddParam("@msg_id", log.Msg_id);
            cmd.AddParam("@userid", log.Userid);
            cmd.AddParam("@channelcompanyid", log.Channelcompanyid);
            cmd.AddParam("@comid", log.Comid);
            cmd.AddParam("@yearmonth", log.Yearmonth);
            cmd.AddParam("@yearmonthday", log.Yearmonthday);
            cmd.AddParam("@weixins", log.Weixins);
            if (log.Id > 0)
            {
                cmd.AddParam("@id", log.Id);
            }

            if (log.Id > 0)
            {
                cmd.ExecuteNonQuery();
                return(log.Id);
            }
            else
            {
                object o = cmd.ExecuteScalar();
                return(o == null ? 0 : int.Parse(o.ToString()));
            }
        }