Example #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.UserFeedBack DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.UserFeedBack model = new WebDemo.Model.WebDemo.UserFeedBack();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["UserCode"] != null)
         {
             model.UserCode = row["UserCode"].ToString();
         }
         if (row["ContactWay"] != null)
         {
             model.ContactWay = row["ContactWay"].ToString();
         }
         if (row["Phone"] != null)
         {
             model.Phone = row["Phone"].ToString();
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
         if (row["PublishDate"] != null && row["PublishDate"].ToString() != "")
         {
             model.PublishDate = DateTime.Parse(row["PublishDate"].ToString());
         }
         if (row["ReplyMan"] != null)
         {
             model.ReplyMan = row["ReplyMan"].ToString();
         }
         if (row["ReplyContent"] != null)
         {
             model.ReplyContent = row["ReplyContent"].ToString();
         }
         if (row["ReplyDate"] != null && row["ReplyDate"].ToString() != "")
         {
             model.ReplyDate = DateTime.Parse(row["ReplyDate"].ToString());
         }
         if (row["Flag"] != null && row["Flag"].ToString() != "")
         {
             model.Flag = int.Parse(row["Flag"].ToString());
         }
         if (row["TypeId"] != null && row["TypeId"].ToString() != "")
         {
             model.TypeId = int.Parse(row["TypeId"].ToString());
         }
         if (row["Contact"] != null)
         {
             model.Contact = row["Contact"].ToString();
         }
         if (row["ReplyFlag"] != null && row["ReplyFlag"].ToString() != "")
         {
             model.ReplyFlag = int.Parse(row["ReplyFlag"].ToString());
         }
     }
     return(model);
 }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.UserFeedBack model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserFeedBack set ");
            strSql.Append("UserCode=@UserCode,");
            strSql.Append("ContactWay=@ContactWay,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("Content=@Content,");
            strSql.Append("PublishDate=@PublishDate,");
            strSql.Append("ReplyMan=@ReplyMan,");
            strSql.Append("ReplyContent=@ReplyContent,");
            strSql.Append("ReplyDate=@ReplyDate,");
            strSql.Append("Flag=@Flag,");
            strSql.Append("TypeId=@TypeId,");
            strSql.Append("Contact=@Contact,");
            strSql.Append("ReplyFlag=@ReplyFlag");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",     SqlDbType.VarChar,    50),
                new SqlParameter("@ContactWay",   SqlDbType.VarChar,   100),
                new SqlParameter("@Phone",        SqlDbType.VarChar,    50),
                new SqlParameter("@Content",      SqlDbType.VarChar,   500),
                new SqlParameter("@PublishDate",  SqlDbType.DateTime),
                new SqlParameter("@ReplyMan",     SqlDbType.VarChar,   100),
                new SqlParameter("@ReplyContent", SqlDbType.VarChar,    50),
                new SqlParameter("@ReplyDate",    SqlDbType.DateTime),
                new SqlParameter("@Flag",         SqlDbType.Int,         4),
                new SqlParameter("@TypeId",       SqlDbType.Int,         4),
                new SqlParameter("@Contact",      SqlDbType.VarChar,    50),
                new SqlParameter("@ReplyFlag",    SqlDbType.Int,         4),
                new SqlParameter("@ID",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserCode;
            parameters[1].Value  = model.ContactWay;
            parameters[2].Value  = model.Phone;
            parameters[3].Value  = model.Content;
            parameters[4].Value  = model.PublishDate;
            parameters[5].Value  = model.ReplyMan;
            parameters[6].Value  = model.ReplyContent;
            parameters[7].Value  = model.ReplyDate;
            parameters[8].Value  = model.Flag;
            parameters[9].Value  = model.TypeId;
            parameters[10].Value = model.Contact;
            parameters[11].Value = model.ReplyFlag;
            parameters[12].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.UserFeedBack model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserFeedBack(");
            strSql.Append("UserCode,ContactWay,Phone,Content,PublishDate,ReplyMan,ReplyContent,ReplyDate,Flag,TypeId,Contact,ReplyFlag)");
            strSql.Append(" values (");
            strSql.Append("@UserCode,@ContactWay,@Phone,@Content,@PublishDate,@ReplyMan,@ReplyContent,@ReplyDate,@Flag,@TypeId,@Contact,@ReplyFlag)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",     SqlDbType.VarChar,    50),
                new SqlParameter("@ContactWay",   SqlDbType.VarChar,   100),
                new SqlParameter("@Phone",        SqlDbType.VarChar,    50),
                new SqlParameter("@Content",      SqlDbType.VarChar,   500),
                new SqlParameter("@PublishDate",  SqlDbType.DateTime),
                new SqlParameter("@ReplyMan",     SqlDbType.VarChar,   100),
                new SqlParameter("@ReplyContent", SqlDbType.VarChar,    50),
                new SqlParameter("@ReplyDate",    SqlDbType.DateTime),
                new SqlParameter("@Flag",         SqlDbType.Int,         4),
                new SqlParameter("@TypeId",       SqlDbType.Int,         4),
                new SqlParameter("@Contact",      SqlDbType.VarChar,    50),
                new SqlParameter("@ReplyFlag",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserCode;
            parameters[1].Value  = model.ContactWay;
            parameters[2].Value  = model.Phone;
            parameters[3].Value  = model.Content;
            parameters[4].Value  = model.PublishDate;
            parameters[5].Value  = model.ReplyMan;
            parameters[6].Value  = model.ReplyContent;
            parameters[7].Value  = model.ReplyDate;
            parameters[8].Value  = model.Flag;
            parameters[9].Value  = model.TypeId;
            parameters[10].Value = model.Contact;
            parameters[11].Value = model.ReplyFlag;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #4
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.UserFeedBack   bll   = new WebDemo.BLL.WebDemo.UserFeedBack();
     WebDemo.Model.WebDemo.UserFeedBack model = bll.GetModel(ID);
     this.lblID.Text           = model.ID.ToString();
     this.lblUserCode.Text     = model.UserCode;
     this.lblContactWay.Text   = model.ContactWay;
     this.lblPhone.Text        = model.Phone;
     this.lblContent.Text      = model.Content;
     this.lblPublishDate.Text  = model.PublishDate.ToString();
     this.lblReplyMan.Text     = model.ReplyMan;
     this.lblReplyContent.Text = model.ReplyContent;
     this.lblReplyDate.Text    = model.ReplyDate.ToString();
     this.lblFlag.Text         = model.Flag.ToString();
     this.lblTypeId.Text       = model.TypeId.ToString();
     this.lblContact.Text      = model.Contact;
     this.lblReplyFlag.Text    = model.ReplyFlag.ToString();
 }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.UserFeedBack GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,UserCode,ContactWay,Phone,Content,PublishDate,ReplyMan,ReplyContent,ReplyDate,Flag,TypeId,Contact,ReplyFlag from UserFeedBack ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtUserCode.Text.Trim().Length == 0)
            {
                strErr += "UserCode不能为空!\\n";
            }
            if (this.txtContactWay.Text.Trim().Length == 0)
            {
                strErr += "ContactWay不能为空!\\n";
            }
            if (this.txtPhone.Text.Trim().Length == 0)
            {
                strErr += "Phone不能为空!\\n";
            }
            if (this.txtContent.Text.Trim().Length == 0)
            {
                strErr += "Content不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtPublishDate.Text))
            {
                strErr += "PublishDate格式错误!\\n";
            }
            if (this.txtReplyMan.Text.Trim().Length == 0)
            {
                strErr += "ReplyMan不能为空!\\n";
            }
            if (this.txtReplyContent.Text.Trim().Length == 0)
            {
                strErr += "ReplyContent不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtReplyDate.Text))
            {
                strErr += "ReplyDate格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtFlag.Text))
            {
                strErr += "Flag格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtTypeId.Text))
            {
                strErr += "TypeId格式错误!\\n";
            }
            if (this.txtContact.Text.Trim().Length == 0)
            {
                strErr += "Contact不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtReplyFlag.Text))
            {
                strErr += "ReplyFlag格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID           = int.Parse(this.lblID.Text);
            string   UserCode     = this.txtUserCode.Text;
            string   ContactWay   = this.txtContactWay.Text;
            string   Phone        = this.txtPhone.Text;
            string   Content      = this.txtContent.Text;
            DateTime PublishDate  = DateTime.Parse(this.txtPublishDate.Text);
            string   ReplyMan     = this.txtReplyMan.Text;
            string   ReplyContent = this.txtReplyContent.Text;
            DateTime ReplyDate    = DateTime.Parse(this.txtReplyDate.Text);
            int      Flag         = int.Parse(this.txtFlag.Text);
            int      TypeId       = int.Parse(this.txtTypeId.Text);
            string   Contact      = this.txtContact.Text;
            int      ReplyFlag    = int.Parse(this.txtReplyFlag.Text);


            WebDemo.Model.WebDemo.UserFeedBack model = new WebDemo.Model.WebDemo.UserFeedBack();
            model.ID           = ID;
            model.UserCode     = UserCode;
            model.ContactWay   = ContactWay;
            model.Phone        = Phone;
            model.Content      = Content;
            model.PublishDate  = PublishDate;
            model.ReplyMan     = ReplyMan;
            model.ReplyContent = ReplyContent;
            model.ReplyDate    = ReplyDate;
            model.Flag         = Flag;
            model.TypeId       = TypeId;
            model.Contact      = Contact;
            model.ReplyFlag    = ReplyFlag;

            WebDemo.BLL.WebDemo.UserFeedBack bll = new WebDemo.BLL.WebDemo.UserFeedBack();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }