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

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

            QPS.NEW.Model.ad a = new QPS.NEW.Model.ad();
            a.Id = Convert.ToInt32(id);
            a.AdUrl = name;
            a.AdImg = imagePath;

            QPS.NEW.BLL.Ad Ba = new QPS.NEW.BLL.Ad();
            //rm.Add(Mro);
            if (Ba.Update(a))
            {
                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.txtUrl.Text; //链接地址
            string imagePath = this.Photo.Text;

            QPS.NEW.Model.ad a = new QPS.NEW.Model.ad();
            a.Id    = Convert.ToInt32(id);
            a.AdUrl = name;
            a.AdImg = imagePath;

            QPS.NEW.BLL.Ad Ba = new QPS.NEW.BLL.Ad();
            //rm.Add(Mro);
            if (Ba.Update(a))
            {
                Response.Write("<script>alert('修改成功!!');</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!');</script>");
            }
        }
Beispiel #3
0
        public bool Update(QPS.NEW.Model.ad 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.Catid != null)
            {
                filedName[Count] = "catid";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Catid);
                Count++;
            }
            if (model.AdImg != null)
            {
                filedName[Count] = "adImg";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.AdImg);
                Count++;
            }
            if (model.AdUrl != null)
            {
                filedName[Count] = "adUrl";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.AdUrl);
                Count++;
            }
            if (model.AdType != null)
            {
                filedName[Count] = "adType";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.AdType);
                Count++;
            }
            if (model.AdName != null)
            {
                filedName[Count] = "adName";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.AdName);
                Count++;
            }
            if (model.AdDate != null)
            {
                filedName[Count] = "adDate";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.AdDate);
                Count++;
            }


            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ad 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);
        }