Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hch.iDisk.Model.FriendTemp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update FriendTemp set ");
            strSql.Append("Confirmed=@Confirmed,");
            strSql.Append("Message=@Message");
            strSql.Append(" where SenderId=@SenderId and Receiver=@Receiver ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Confirmed", SqlDbType.Bit,      1),
                new SqlParameter("@Message",   SqlDbType.VarChar, 50),
                new SqlParameter("@SenderId",  SqlDbType.Int,      4),
                new SqlParameter("@Receiver",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Confirmed;
            parameters[1].Value = model.Message;
            parameters[2].Value = model.SenderId;
            parameters[3].Value = model.Receiver;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hch.iDisk.Model.FriendTemp GetModel(int SenderId, int Receiver)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SenderId,Receiver,Confirmed,Message from FriendTemp ");
            strSql.Append(" where SenderId=@SenderId and Receiver=@Receiver ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SenderId", SqlDbType.Int, 4),
                new SqlParameter("@Receiver", SqlDbType.Int, 4)
            };
            parameters[0].Value = SenderId;
            parameters[1].Value = Receiver;

            Hch.iDisk.Model.FriendTemp model = new Hch.iDisk.Model.FriendTemp();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SenderId"].ToString() != "")
                {
                    model.SenderId = int.Parse(ds.Tables[0].Rows[0]["SenderId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Receiver"].ToString() != "")
                {
                    model.Receiver = int.Parse(ds.Tables[0].Rows[0]["Receiver"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Confirmed"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Confirmed"].ToString() == "1") || (ds.Tables[0].Rows[0]["Confirmed"].ToString().ToLower() == "true"))
                    {
                        model.Confirmed = true;
                    }
                    else
                    {
                        model.Confirmed = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Message"] != null)
                {
                    model.Message = ds.Tables[0].Rows[0]["Message"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Hch.iDisk.Model.FriendTemp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FriendTemp(");
            strSql.Append("SenderId,Receiver,Confirmed,Message)");
            strSql.Append(" values (");
            strSql.Append("@SenderId,@Receiver,@Confirmed,@Message)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SenderId",  SqlDbType.Int,     4),
                new SqlParameter("@Receiver",  SqlDbType.Int,     4),
                new SqlParameter("@Confirmed", SqlDbType.Bit,     1),
                new SqlParameter("@Message",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.SenderId;
            parameters[1].Value = model.Receiver;
            parameters[2].Value = model.Confirmed;
            parameters[3].Value = model.Message;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Beispiel #4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Hch.iDisk.Model.FriendTemp GetModel(int SenderId,int Receiver)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 SenderId,Receiver,Confirmed,Message from FriendTemp ");
            strSql.Append(" where SenderId=@SenderId and Receiver=@Receiver ");
            SqlParameter[] parameters = {
                    new SqlParameter("@SenderId", SqlDbType.Int,4),
                    new SqlParameter("@Receiver", SqlDbType.Int,4)};
            parameters[0].Value = SenderId;
            parameters[1].Value = Receiver;

            Hch.iDisk.Model.FriendTemp model=new Hch.iDisk.Model.FriendTemp();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["SenderId"].ToString()!="")
                {
                    model.SenderId=int.Parse(ds.Tables[0].Rows[0]["SenderId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Receiver"].ToString()!="")
                {
                    model.Receiver=int.Parse(ds.Tables[0].Rows[0]["Receiver"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Confirmed"].ToString()!="")
                {
                    if((ds.Tables[0].Rows[0]["Confirmed"].ToString()=="1")||(ds.Tables[0].Rows[0]["Confirmed"].ToString().ToLower()=="true"))
                    {
                        model.Confirmed=true;
                    }
                    else
                    {
                        model.Confirmed=false;
                    }
                }
                if(ds.Tables[0].Rows[0]["Message"]!=null)
                {
                model.Message=ds.Tables[0].Rows[0]["Message"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }