示例#1
0
文件: WxMsgDal.cs 项目: quwujin/SM297
        public Model.WxMsgModel GetOpenIdInfo(string FromUserName, string sqlstr)
        {
            StringBuilder sql = new StringBuilder("select Top 1 * from Wx_Msg where FromUserName='******' " + sqlstr);
            SqlDataReader dr  = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString());

            Model.WxMsgModel model = new Model.WxMsgModel();
            model.Id = 0;
            if (dr.Read())
            {
                model.Id           = Convert.ToInt32(dr["Id"].ToString());
                model.ToUserName   = dr["ToUserName"].ToString();
                model.FromUserName = dr["FromUserName"].ToString();
                model.CreateTime   = DateTime.Parse(dr["CreateTime"].ToString());
                if (dr["DTime"] != DBNull.Value)
                {
                    model.DTime = DateTime.Parse(dr["DTime"].ToString());
                }
                model.MsgType      = dr["MsgType"].ToString();
                model.PicUrl       = dr["PicUrl"].ToString();
                model.MediaId      = dr["MediaId"].ToString();
                model.MsgId        = dr["MsgId"].ToString();
                model.Contents     = dr["Contents"].ToString();
                model.Format       = dr["Format"].ToString();
                model.ThumbMediaId = dr["ThumbMediaId"].ToString();
                model.Location_X   = dr["Location_X"].ToString();
                model.Location_Y   = dr["Location_Y"].ToString();
                model.Scale        = dr["Scale"].ToString();
                model.Label        = dr["Label"].ToString();
                model.Title        = dr["Title"].ToString();
                model.States       = Convert.ToInt32(dr["States"].ToString());
            }
            return(model);
        }
示例#2
0
文件: WxMsgDal.cs 项目: quwujin/SM297
        public int AddImg(Model.WxMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Wx_Msg(ToUserName,FromUserName,CreateTime,MsgType,PicUrl,MediaId,MsgId,States) values(");
            strSql.Append("@ToUserName,@FromUserName,@CreateTime,@MsgType,@PicUrl,@MediaId,@MsgId,@States);select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ToUserName",   model.ToUserName),
                new SqlParameter("@FromUserName", model.FromUserName),
                new SqlParameter("@CreateTime",   model.CreateTime),
                new SqlParameter("@MsgType",      model.MsgType),
                new SqlParameter("@PicUrl",       model.PicUrl),
                new SqlParameter("@MediaId",      model.MediaId),
                new SqlParameter("@MsgId",        model.MsgId),
                new SqlParameter("@States",       model.States)
            };
            try
            {
                return(Convert.ToInt16(SqlHelper.ExecuteScalar(conn, CommandType.Text, strSql.ToString(), parameters)));
            }
            catch (Exception)
            {
                return(0);
            }
        }
示例#3
0
文件: WxMsgDal.cs 项目: quwujin/SM297
        public int Update(Model.WxMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" update Wx_Msg set States=@States,DTime=@DTime where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@States", model.States),
                new SqlParameter("@DTime",  model.DTime),
                new SqlParameter("@Id",     model.Id)
            };
            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters));
        }
示例#4
0
文件: WxMsgDal.cs 项目: quwujin/SM297
        public int UpdateStatus(Model.WxMsgModel model, Model.OrderLogModel mdlog)
        {
            int rtn = 0;

            using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString))
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(" update Wx_Msg set States=@States where Id=@Id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@States", model.States),
                            new SqlParameter("@Id",     model.Id)
                        };
                        rtn += SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql.ToString(), parameters);

                        StringBuilder strSql2 = new StringBuilder();
                        strSql2.Append(" insert into OrderLog(Oid,OrderCode,Mob,UpTime,LStatus,Status,Notes)");
                        strSql2.Append(" values(@Oid,@OrderCode,@Mob,@UpTime,@LStatus,@Status,@Notes)");
                        SqlParameter[] parameters2 =
                        {
                            new SqlParameter("@Oid",       mdlog.OId),
                            new SqlParameter("@OrderCode", mdlog.OrderCode),
                            new SqlParameter("@Mob",       mdlog.Mob),
                            new SqlParameter("@UpTime",    mdlog.UpTime),
                            new SqlParameter("@LStatus",   mdlog.LStatus),
                            new SqlParameter("@Status",    mdlog.Status),
                            new SqlParameter("@Notes",     mdlog.Notes)
                        };
                        rtn += SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql2.ToString(), parameters2);
                        trans.Commit();
                        return(rtn);
                    }
                    catch (Exception)
                    {
                        trans.Rollback();
                        rtn = 0;
                    }
                }
            }
            return(0);
        }
示例#5
0
文件: WxMsgDal.cs 项目: quwujin/SM297
        public int Add(Model.WxMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Wx_Msg(ToUserName,FromUserName,CreateTime,MsgType,PicUrl,MediaId,MsgId,Contents,Format,ThumbMediaId," +
                          "Location_X,Location_Y,Scale,Label,Title,States) values(");
            strSql.Append("@ToUserName,@FromUserName,@CreateTime,@MsgType,@PicUrl,@MediaId,@MsgId,@Contents,@Format,@ThumbMediaId,@" +
                          "Location_X,@Location_Y,@Scale,@Label,@Title,@States);select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ToUserName",   model.ToUserName),
                new SqlParameter("@FromUserName", model.FromUserName),
                new SqlParameter("@CreateTime",   model.CreateTime),
                new SqlParameter("@MsgType",      model.MsgType),
                new SqlParameter("@PicUrl",       model.PicUrl),
                new SqlParameter("@MediaId",      model.MediaId),
                new SqlParameter("@MsgId",        model.MsgId),
                new SqlParameter("@Contents",     model.Contents),
                new SqlParameter("@Format",       model.Format),
                new SqlParameter("@ThumbMediaId", model.ThumbMediaId),
                new SqlParameter("@Location_X",   model.Location_X),
                new SqlParameter("@Location_Y",   model.Location_Y),
                new SqlParameter("@Scale",        model.Scale),
                new SqlParameter("@Label",        model.Label),
                new SqlParameter("@Title",        model.Title),
                new SqlParameter("@States",       model.States)
            };
            try
            {
                return(Convert.ToInt16(SqlHelper.ExecuteScalar(conn, CommandType.Text, strSql.ToString(), parameters)));
            }
            catch (Exception)
            {
                return(0);
            }
        }