Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Reply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Reply(");
            strSql.Append("Fk_Leaveword_Id,Contents,Fk_Users_Id,AddTimes)");
            strSql.Append(" values (");
            strSql.Append("@Fk_Leaveword_Id,@Contents,@Fk_Users_Id,@AddTimes)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fk_Leaveword_Id", SqlDbType.Int,       4),
                new SqlParameter("@Contents",        SqlDbType.VarChar, 500),
                new SqlParameter("@Fk_Users_Id",     SqlDbType.Int,       4),
                new SqlParameter("@AddTimes",        SqlDbType.DateTime)
            };
            parameters[0].Value = model.Fk_Leaveword_Id;
            parameters[1].Value = model.Contents;
            parameters[2].Value = model.Fk_Users_Id;
            parameters[3].Value = model.AddTimes;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Reply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Reply set ");
            strSql.Append("Fk_Leaveword_Id=@Fk_Leaveword_Id,");
            strSql.Append("Contents=@Contents,");
            strSql.Append("Fk_Users_Id=@Fk_Users_Id,");
            strSql.Append("AddTimes=@AddTimes");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fk_Leaveword_Id", SqlDbType.Int,         4),
                new SqlParameter("@Contents",        SqlDbType.VarChar,   500),
                new SqlParameter("@Fk_Users_Id",     SqlDbType.Int,         4),
                new SqlParameter("@AddTimes",        SqlDbType.DateTime),
                new SqlParameter("@Id",              SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Fk_Leaveword_Id;
            parameters[1].Value = model.Contents;
            parameters[2].Value = model.Fk_Users_Id;
            parameters[3].Value = model.AddTimes;
            parameters[4].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Reply DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Reply model = new Maticsoft.Model.Reply();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Fk_Leaveword_Id"] != null && row["Fk_Leaveword_Id"].ToString() != "")
         {
             model.Fk_Leaveword_Id = int.Parse(row["Fk_Leaveword_Id"].ToString());
         }
         if (row["Contents"] != null)
         {
             model.Contents = row["Contents"].ToString();
         }
         if (row["Fk_Users_Id"] != null && row["Fk_Users_Id"].ToString() != "")
         {
             model.Fk_Users_Id = int.Parse(row["Fk_Users_Id"].ToString());
         }
         if (row["AddTimes"] != null && row["AddTimes"].ToString() != "")
         {
             model.AddTimes = DateTime.Parse(row["AddTimes"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsDateTime(txtAddTimes.Text))
            {
                strErr += "回复时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id = int.Parse(this.lblId.Text);
            int      Fk_Leaveword_Id = int.Parse(this.ddlFk_Leaveword_Id.SelectedValue);
            String   Contents        = this.txtContents.Text;
            int      Fk_Users_Id     = int.Parse(this.ddlFk_Users_Id.SelectedValue);
            DateTime AddTimes        = DateTime.Parse(this.txtAddTimes.Text);


            Maticsoft.Model.Reply model = new Maticsoft.Model.Reply();
            model.Id = Id;
            model.Fk_Leaveword_Id = Fk_Leaveword_Id;
            model.Contents        = Contents;
            model.Fk_Users_Id     = Fk_Users_Id;
            model.AddTimes        = AddTimes;

            Maticsoft.BLL.Reply bll = new Maticsoft.BLL.Reply();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Пример #5
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.Reply   bll   = new Maticsoft.BLL.Reply();
     Maticsoft.Model.Reply model = bll.GetModel(Id);
     this.lblId.Text = model.Id.ToString();
     this.ddlFk_Leaveword_Id.SelectedValue = model.Fk_Leaveword_Id.ToString();
     this.txtContents.Text             = model.Contents;
     this.ddlFk_Users_Id.SelectedValue = model.Fk_Users_Id.ToString();
     this.txtAddTimes.Text             = model.AddTimes.ToString();
 }
Пример #6
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.Reply   bll   = new Maticsoft.BLL.Reply();
     Maticsoft.Model.Reply model = bll.GetModel(Id);
     this.lblId.Text = model.Id.ToString();
     BLL.Leaveword   BLLLeaveword   = new BLL.Leaveword();
     Model.Leaveword ModelLeaveword = BLLLeaveword.GetModel((int)model.Fk_Leaveword_Id);
     this.lblFk_Leaveword_Id.Text = ModelLeaveword.Id.ToString();
     this.lblContents.Text        = model.Contents;
     BLL.Users   BLLUsers   = new BLL.Users();
     Model.Users ModelUsers = BLLUsers.GetModel((int)model.Fk_Users_Id);
     this.lblFk_Users_Id.Text = ModelUsers.Name;
     this.lblAddTimes.Text    = model.AddTimes.ToString();
 }
Пример #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Reply GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Fk_Leaveword_Id,Contents,Fk_Users_Id,AddTimes from Reply ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }