Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.UserRelate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserRelate set ");
            strSql.Append("UserId=@UserId,");
            strSql.Append("RelateUserId=@RelateUserId,");
            strSql.Append("IsDelete=@IsDelete,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",       SqlDbType.Int,       4),
                new SqlParameter("@RelateUserId", SqlDbType.Int,       4),
                new SqlParameter("@IsDelete",     SqlDbType.Bit,       1),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.RelateUserId;
            parameters[2].Value = model.IsDelete;
            parameters[3].Value = model.CreateTime;
            parameters[4].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.UserRelate DataRowToModel(DataRow row)
 {
     Maticsoft.Model.UserRelate model = new Maticsoft.Model.UserRelate();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["UserId"] != null && row["UserId"].ToString() != "")
         {
             model.UserId = int.Parse(row["UserId"].ToString());
         }
         if (row["RelateUserId"] != null && row["RelateUserId"].ToString() != "")
         {
             model.RelateUserId = int.Parse(row["RelateUserId"].ToString());
         }
         if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
         {
             if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true"))
             {
                 model.IsDelete = true;
             }
             else
             {
                 model.IsDelete = false;
             }
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.UserRelate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserRelate(");
            strSql.Append("UserId,RelateUserId,IsDelete,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@UserId,@RelateUserId,@IsDelete,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",       SqlDbType.Int, 4),
                new SqlParameter("@RelateUserId", SqlDbType.Int, 4),
                new SqlParameter("@IsDelete",     SqlDbType.Bit, 1),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.RelateUserId;
            parameters[2].Value = model.IsDelete;
            parameters[3].Value = model.CreateTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.UserRelate DataRowToModel(DataRow row)
 {
     Maticsoft.Model.UserRelate model=new Maticsoft.Model.UserRelate();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["UserId"]!=null && row["UserId"].ToString()!="")
         {
             model.UserId=int.Parse(row["UserId"].ToString());
         }
         if(row["RelateUserId"]!=null && row["RelateUserId"].ToString()!="")
         {
             model.RelateUserId=int.Parse(row["RelateUserId"].ToString());
         }
         if(row["IsDelete"]!=null && row["IsDelete"].ToString()!="")
         {
             if((row["IsDelete"].ToString()=="1")||(row["IsDelete"].ToString().ToLower()=="true"))
             {
                 model.IsDelete=true;
             }
             else
             {
                 model.IsDelete=false;
             }
         }
         if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
         {
             model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return model;
 }
Esempio n. 5
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.UserRelate   bll   = new Maticsoft.BLL.UserRelate();
     Maticsoft.Model.UserRelate model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.txtUserId.Text       = model.UserId.ToString();
     this.txtRelateUserId.Text = model.RelateUserId.ToString();
     this.chkIsDelete.Checked  = model.IsDelete;
     this.txtCreateTime.Text   = model.CreateTime.ToString();
 }
Esempio n. 6
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.UserRelate   bll   = new Maticsoft.BLL.UserRelate();
     Maticsoft.Model.UserRelate model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.lblUserId.Text       = model.UserId.ToString();
     this.lblRelateUserId.Text = model.RelateUserId.ToString();
     this.lblIsDelete.Text     = model.IsDelete?"是":"否";
     this.lblCreateTime.Text   = model.CreateTime.ToString();
 }
Esempio n. 7
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "UserId格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtRelateUserId.Text))
            {
                strErr += "RelateUserId格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "CreateTime格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id           = int.Parse(this.lblId.Text);
            int      UserId       = int.Parse(this.txtUserId.Text);
            int      RelateUserId = int.Parse(this.txtRelateUserId.Text);
            bool     IsDelete     = this.chkIsDelete.Checked;
            DateTime CreateTime   = DateTime.Parse(this.txtCreateTime.Text);


            Maticsoft.Model.UserRelate model = new Maticsoft.Model.UserRelate();
            model.Id           = Id;
            model.UserId       = UserId;
            model.RelateUserId = RelateUserId;
            model.IsDelete     = IsDelete;
            model.CreateTime   = CreateTime;

            Maticsoft.BLL.UserRelate bll = new Maticsoft.BLL.UserRelate();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 8
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr+="UserId格式错误!\\n";
            }
            if(!PageValidate.IsNumber(txtRelateUserId.Text))
            {
                strErr+="RelateUserId格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr+="CreateTime格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int Id=int.Parse(this.lblId.Text);
            int UserId=int.Parse(this.txtUserId.Text);
            int RelateUserId=int.Parse(this.txtRelateUserId.Text);
            bool IsDelete=this.chkIsDelete.Checked;
            DateTime CreateTime=DateTime.Parse(this.txtCreateTime.Text);

            Maticsoft.Model.UserRelate model=new Maticsoft.Model.UserRelate();
            model.Id=Id;
            model.UserId=UserId;
            model.RelateUserId=RelateUserId;
            model.IsDelete=IsDelete;
            model.CreateTime=CreateTime;

            Maticsoft.BLL.UserRelate bll=new Maticsoft.BLL.UserRelate();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx");
        }
Esempio n. 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.UserRelate GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserId,RelateUserId,IsDelete,CreateTime from UserRelate ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Maticsoft.Model.UserRelate model = new Maticsoft.Model.UserRelate();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.UserRelate model)
 {
     return(dal.Update(model));
 }
Esempio n. 11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.UserRelate model)
 {
     return(dal.Add(model));
 }
Esempio n. 12
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.UserRelate GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,UserId,RelateUserId,IsDelete,CreateTime from UserRelate ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

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