示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public la.Model.friend DataRowToModel(DataRow row)
 {
     la.Model.friend model=new la.Model.friend();
     if (row != null)
     {
         if(row["friend_id"]!=null && row["friend_id"].ToString()!="")
         {
             model.friend_id=int.Parse(row["friend_id"].ToString());
         }
         if(row["friend_from"]!=null)
         {
             model.friend_from=row["friend_from"].ToString();
         }
         if(row["friend_to"]!=null)
         {
             model.friend_to=row["friend_to"].ToString();
         }
         if(row["friend_time"]!=null && row["friend_time"].ToString()!="")
         {
             model.friend_time=DateTime.Parse(row["friend_time"].ToString());
         }
         if(row["friend_state"]!=null)
         {
             model.friend_state=row["friend_state"].ToString();
         }
         if(row["friend_comment"]!=null)
         {
             model.friend_comment=row["friend_comment"].ToString();
         }
     }
     return model;
 }
示例#2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtfriend_id.Text))
            {
                strErr+="好友关系ID格式错误!\\n";
            }
            if(this.txtfriend_from.Text.Trim().Length==0)
            {
                strErr+="好友FROM不能为空!\\n";
            }
            if(this.txtfriend_to.Text.Trim().Length==0)
            {
                strErr+="好友TO不能为空!\\n";
            }
            if(!PageValidate.IsDateTime(txtfriend_time.Text))
            {
                strErr+="添加时间格式错误!\\n";
            }
            if(this.txtfriend_state.Text.Trim().Length==0)
            {
                strErr+="关系状态不能为空!\\n";
            }
            if(this.txtfriend_comment.Text.Trim().Length==0)
            {
                strErr+="关系备注不能为空!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int friend_id=int.Parse(this.txtfriend_id.Text);
            string friend_from=this.txtfriend_from.Text;
            string friend_to=this.txtfriend_to.Text;
            DateTime friend_time=DateTime.Parse(this.txtfriend_time.Text);
            string friend_state=this.txtfriend_state.Text;
            string friend_comment=this.txtfriend_comment.Text;

            la.Model.friend model=new la.Model.friend();
            model.friend_id=friend_id;
            model.friend_from=friend_from;
            model.friend_to=friend_to;
            model.friend_time=friend_time;
            model.friend_state=friend_state;
            model.friend_comment=friend_comment;

            la.BLL.friend bll=new la.BLL.friend();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public la.Model.friend GetModel(int friend_id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 friend_id,friend_from,friend_to,friend_time,friend_state,friend_comment from friend ");
            strSql.Append(" where friend_id=@friend_id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@friend_id", SqlDbType.Int,4)			};
            parameters[0].Value = friend_id;

            la.Model.friend model=new la.Model.friend();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }