//修改
        protected void btnupdate_Click(object sender, EventArgs e)
        {
            string id = Request["ID"].ToString();

            string name = this.txName.Text; //链接地址
            string imagePath = this.Photo.Text;

            QPS.NEW.Model.Poster mpt = new QPS.NEW.Model.Poster();
            mpt.Id = Convert.ToInt32(id);
            mpt.URL = name;
            mpt.URL = imagePath;

            QPS.NEW.BLL.Poster pt =new QPS.NEW.BLL.Poster ();
            //rm.Add(Mro);
            if (pt.Update(mpt))
            {
                Response.Write("<script>alert('修改成功!!');</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!');</script>");
            }
        }
Beispiel #2
0
        //修改
        protected void btnupdate_Click(object sender, EventArgs e)
        {
            string id = Request["ID"].ToString();

            string name      = this.txName.Text; //链接地址
            string imagePath = this.Photo.Text;

            QPS.NEW.Model.Poster mpt = new QPS.NEW.Model.Poster();
            mpt.Id  = Convert.ToInt32(id);
            mpt.URL = name;
            mpt.URL = imagePath;

            QPS.NEW.BLL.Poster pt = new QPS.NEW.BLL.Poster();
            //rm.Add(Mro);
            if (pt.Update(mpt))
            {
                Response.Write("<script>alert('修改成功!!');</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!');</script>");
            }
        }
Beispiel #3
0
        public bool Update(QPS.NEW.Model.Poster model)
        {
            bool res = false;

            string[]       filedName = new string[50];
            string[]       paramName = new string[50];
            SqlParameter[] sqlParams = new SqlParameter[50];
            int            Count     = 0;

            if (model.Id == -999)
            {
                return(false);
            }

            if (model.Id != -999)
            {
                filedName[Count] = "ID";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Id);
                Count++;
            }
            if (model.PhotoUrl != null)
            {
                filedName[Count] = "PhotoUrl";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.PhotoUrl);
                Count++;
            }
            if (model.URL != null)
            {
                filedName[Count] = "URL";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.URL);
                Count++;
            }


            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Poster set ");
            for (int i = 1; i < Count; i++)      // i begin with 0 !!!
            {
                strSql.Append(filedName[i]);
                strSql.Append("=");
                strSql.Append(paramName[i]);
                if (i != Count - 1)
                {
                    strSql.Append(",");
                }
            }
            strSql.Append(" where ");
            strSql.Append(filedName[0] + "=" + paramName[0]);


            int num = Convert.ToInt32(sqlHelper_.ExecuteCommand(
                                          strSql.ToString(),
                                          CommandType.Text,
                                          sqlParams
                                          ));

            if (num != 1)
            {
                res = false;
            }
            else
            {
                res = true;
            }

            return(res);
        }