Example #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtMessTitle.Text.Trim().Length == 0)
            {
                strErr += "MessTitle不能为空!\\n";
            }
            if (this.txtUsername.Text.Trim().Length == 0)
            {
                strErr += "Username不能为空!\\n";
            }
            if (this.txtAddress.Text.Trim().Length == 0)
            {
                strErr += "Address不能为空!\\n";
            }
            if (this.txtLinkphoto.Text.Trim().Length == 0)
            {
                strErr += "Linkphoto不能为空!\\n";
            }
            if (this.txtEmail.Text.Trim().Length == 0)
            {
                strErr += "Email不能为空!\\n";
            }
            if (this.txtMesscontent.Text.Trim().Length == 0)
            {
                strErr += "Messcontent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    MessID      = int.Parse(this.lblMessID.Text);
            string MessTitle   = this.txtMessTitle.Text;
            string Username    = this.txtUsername.Text;
            bool   Sex         = this.chkSex.Checked;
            string Address     = this.txtAddress.Text;
            string Linkphoto   = this.txtLinkphoto.Text;
            string Email       = this.txtEmail.Text;
            string Messcontent = this.txtMesscontent.Text;


            Maticsoft.Model.MessageInfo model = new Maticsoft.Model.MessageInfo();
            model.MessID      = MessID;
            model.MessTitle   = MessTitle;
            model.Username    = Username;
            model.Sex         = Sex;
            model.Address     = Address;
            model.Linkphoto   = Linkphoto;
            model.Email       = Email;
            model.Messcontent = Messcontent;

            Maticsoft.BLL.MessageInfo bll = new Maticsoft.BLL.MessageInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #2
0
 private void ShowInfo(int MessID)
 {
     Maticsoft.BLL.MessageInfo   bll   = new Maticsoft.BLL.MessageInfo();
     Maticsoft.Model.MessageInfo model = bll.GetModel(MessID);
     this.lblMessID.Text      = model.MessID.ToString();
     this.txtMessTitle.Text   = model.MessTitle;
     this.txtUsername.Text    = model.Username;
     this.chkSex.Checked      = model.Sex;
     this.txtAddress.Text     = model.Address;
     this.txtLinkphoto.Text   = model.Linkphoto;
     this.txtEmail.Text       = model.Email;
     this.txtMesscontent.Text = model.Messcontent;
 }
Example #3
0
 private void ShowInfo(int MessID)
 {
     Maticsoft.BLL.MessageInfo   bll   = new Maticsoft.BLL.MessageInfo();
     Maticsoft.Model.MessageInfo model = bll.GetModel(MessID);
     this.lblMessID.Text      = model.MessID.ToString();
     this.lblMessTitle.Text   = model.MessTitle;
     this.lblUsername.Text    = model.Username;
     this.lblSex.Text         = model.Sex?"ÊÇ":"·ñ";
     this.lblAddress.Text     = model.Address;
     this.lblLinkphoto.Text   = model.Linkphoto;
     this.lblEmail.Text       = model.Email;
     this.lblMesscontent.Text = model.Messcontent;
 }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.MessageInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update MessageInfo set ");
            strSql.Append("MessTitle=@MessTitle,");
            strSql.Append("Username=@Username,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("DateTime=@DateTime,");
            strSql.Append("Address=@Address,");
            strSql.Append("Linkphoto=@Linkphoto,");
            strSql.Append("Email=@Email,");
            strSql.Append("Messcontent=@Messcontent");
            strSql.Append(" where MessID=@MessID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MessID",      SqlDbType.Int,         4),
                new SqlParameter("@MessTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@Username",    SqlDbType.VarChar,   200),
                new SqlParameter("@Sex",         SqlDbType.Int,         4),
                new SqlParameter("@DateTime",    SqlDbType.DateTime),
                new SqlParameter("@Address",     SqlDbType.Text),
                new SqlParameter("@Linkphoto",   SqlDbType.VarChar,   200),
                new SqlParameter("@Email",       SqlDbType.VarChar,   200),
                new SqlParameter("@Messcontent", SqlDbType.Text)
            };
            parameters[0].Value = model.MessID;
            parameters[1].Value = model.MessTitle;
            parameters[2].Value = model.Username;
            parameters[3].Value = model.Sex;
            parameters[4].Value = model.DateTime;
            parameters[5].Value = model.Address;
            parameters[6].Value = model.Linkphoto;
            parameters[7].Value = model.Email;
            parameters[8].Value = model.Messcontent;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        protected void btnok_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.MessageInfo   messbll   = new Maticsoft.BLL.MessageInfo();
            Maticsoft.Model.MessageInfo messmodel = new Maticsoft.Model.MessageInfo();
            messmodel.Address  = txtAddress.Text.Trim();
            messmodel.DateTime = Convert.ToDateTime(DateTime.Now.ToString());
            messmodel.Email    = txtEmail.Text.Trim();
            if (txtMesscontent.Text.Trim() == "")
            {
                lblcotent.Text = "请填写留言内容";
                return;
            }
            lblcotent.Text        = "";
            messmodel.Messcontent = txtMesscontent.Text.Trim();
            if (txtMessTitle.Text.Trim() == "")
            {
                lnltitle.Text = "请填写留言名称";
                return;
            }
            lnltitle.Text       = "";
            messmodel.MessTitle = txtMessTitle.Text.Trim();
            if (txtUsername.Text.Trim() == "")
            {
                lblusename.Text = "请填写用户名称";
                return;
            }
            messmodel.Username = txtUsername.Text.Trim();
            lblusename.Text    = "";
            if (drpSex.SelectedValue != "1" && drpSex.SelectedValue != "0")
            {
                lblsex.Text = "请选择您的性别";
                return;
            }
            messmodel.Sex       = int.Parse(drpSex.SelectedValue);
            lblsex.Text         = "";
            messmodel.Linkphoto = txtLinkphoto.Text.Trim();
            messbll.Add(messmodel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息提交成功!!!')</script>");

            txtAddress.Text     = string.Empty;
            txtEmail.Text       = string.Empty;
            txtLinkphoto.Text   = string.Empty;
            txtMesscontent.Text = string.Empty;
            txtMessTitle.Text   = string.Empty;
            txtUsername.Text    = string.Empty;
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.MessageInfo GetModel(int MessID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 MessID,MessTitle,Username,Sex,DateTime,Address,Linkphoto,Email,Messcontent from MessageInfo ");
            strSql.Append(" where MessID=@MessID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MessID", SqlDbType.Int, 4)
            };
            parameters[0].Value = MessID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MessID"].ToString() != "")
                {
                    model.MessID = int.Parse(ds.Tables[0].Rows[0]["MessID"].ToString());
                }
                model.MessTitle = ds.Tables[0].Rows[0]["MessTitle"].ToString();
                model.Username  = ds.Tables[0].Rows[0]["Username"].ToString();
                if (ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = int.Parse(ds.Tables[0].Rows[0]["Sex"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DateTime"].ToString() != "")
                {
                    model.DateTime = DateTime.Parse(ds.Tables[0].Rows[0]["DateTime"].ToString());
                }
                model.Address     = ds.Tables[0].Rows[0]["Address"].ToString();
                model.Linkphoto   = ds.Tables[0].Rows[0]["Linkphoto"].ToString();
                model.Email       = ds.Tables[0].Rows[0]["Email"].ToString();
                model.Messcontent = ds.Tables[0].Rows[0]["Messcontent"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        private void bind()
        {
            Maticsoft.BLL.MessageInfo messbll = new Maticsoft.BLL.MessageInfo();
            int index = int.Parse(Request.QueryString["MessID"].ToString());

            Maticsoft.Model.MessageInfo messmodel = messbll.GetModel(index);
            lblemail.Text = messmodel.Email;
            lblname.Text  = messmodel.Username;
            lblphoto.Text = messmodel.Linkphoto;
            if (messmodel.Sex == 1)
            {
                lblsex.Text = "先生";
            }
            else
            {
                lblsex.Text = "女士";
            }
            lbltime.Text    = Convert.ToDateTime(messmodel.DateTime.ToString()).ToString("yyyy-MM-dd");
            lbltitle.Text   = messmodel.MessTitle;
            txtcontent.Text = messmodel.Messcontent;
        }
Example #8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.MessageInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MessageInfo(");
            strSql.Append("MessTitle,Username,Sex,DateTime,Address,Linkphoto,Email,Messcontent)");
            strSql.Append(" values (");
            strSql.Append("@MessTitle,@Username,@Sex,@DateTime,@Address,@Linkphoto,@Email,@Messcontent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MessTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@Username",    SqlDbType.VarChar,   200),
                new SqlParameter("@Sex",         SqlDbType.Int,         4),
                new SqlParameter("@DateTime",    SqlDbType.DateTime),
                new SqlParameter("@Address",     SqlDbType.Text),
                new SqlParameter("@Linkphoto",   SqlDbType.VarChar,   200),
                new SqlParameter("@Email",       SqlDbType.VarChar,   200),
                new SqlParameter("@Messcontent", SqlDbType.Text)
            };
            parameters[0].Value = model.MessTitle;
            parameters[1].Value = model.Username;
            parameters[2].Value = model.Sex;
            parameters[3].Value = model.DateTime;
            parameters[4].Value = model.Address;
            parameters[5].Value = model.Linkphoto;
            parameters[6].Value = model.Email;
            parameters[7].Value = model.Messcontent;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }