Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.ed_product GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,nodeId,title,picSmall,picBig,remark,isRecommend,addTime,status from ed_product ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            hm.Model.ed_product model = new hm.Model.ed_product();
            DataSet             ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["nodeId"] != null && ds.Tables[0].Rows[0]["nodeId"].ToString() != "")
                {
                    model.nodeId = int.Parse(ds.Tables[0].Rows[0]["nodeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["picSmall"] != null && ds.Tables[0].Rows[0]["picSmall"].ToString() != "")
                {
                    model.picSmall = ds.Tables[0].Rows[0]["picSmall"].ToString();
                }
                if (ds.Tables[0].Rows[0]["picBig"] != null && ds.Tables[0].Rows[0]["picBig"].ToString() != "")
                {
                    model.picBig = ds.Tables[0].Rows[0]["picBig"].ToString();
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["isRecommend"] != null && ds.Tables[0].Rows[0]["isRecommend"].ToString() != "")
                {
                    model.isRecommend = int.Parse(ds.Tables[0].Rows[0]["isRecommend"].ToString());
                }
                if (ds.Tables[0].Rows[0]["addTime"] != null && ds.Tables[0].Rows[0]["addTime"].ToString() != "")
                {
                    model.addTime = DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            hm.BLL.ed_product bll    = new hm.BLL.ed_product();
            string            strErr = "";

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "标题不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            int    Id = int.Parse(lblId.Text);
            int    nodeId = int.Parse(litId.Text);
            string title = txtTitle.Text;
            string remark = this.txtRemark.Text;
            string spic = litPicSmall.Text, bpic = litPicBig.Text;
            int    recommend = 0;

            if (flPic.HasFile)
            {
                string msg = Common.CommonHelper.Imageupload(flPic, "product");
                if (msg.Split('|')[0].Equals("1"))
                {
                    bpic = msg.Split('|')[1];
                    spic = msg.Split('|')[2];
                }
            }
            if (cbRecommend.Checked)
            {
                recommend = 1;
            }

            hm.Model.ed_product model = bll.GetModel(Id);
            model.nodeId      = nodeId;
            model.title       = title;
            model.remark      = remark;
            model.picBig      = bpic;
            model.picSmall    = spic;
            model.isRecommend = recommend;
            model.addTime     = model.addTime;
            model.status      = model.status;

            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "../media/list.aspx?id=" + model.nodeId);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(hm.Model.ed_product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ed_product set ");
            strSql.Append("nodeId=@nodeId,");
            strSql.Append("title=@title,");
            strSql.Append("picSmall=@picSmall,");
            strSql.Append("picBig=@picBig,");
            strSql.Append("remark=@remark,");
            strSql.Append("isRecommend=@isRecommend,");
            strSql.Append("addTime=@addTime,");
            strSql.Append("status=@status");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@nodeId",      OleDbType.Integer,   4),
                new OleDbParameter("@title",       OleDbType.VarChar, 255),
                new OleDbParameter("@picSmall",    OleDbType.VarChar, 255),
                new OleDbParameter("@picBig",      OleDbType.VarChar, 255),
                new OleDbParameter("@remark",      OleDbType.VarChar,   0),
                new OleDbParameter("@isRecommend", OleDbType.Integer,   4),
                new OleDbParameter("@addTime",     OleDbType.Date),
                new OleDbParameter("@status",      OleDbType.Integer,   4),
                new OleDbParameter("@ID",          OleDbType.Integer, 4)
            };
            parameters[0].Value = model.nodeId;
            parameters[1].Value = model.title;
            parameters[2].Value = model.picSmall;
            parameters[3].Value = model.picBig;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.isRecommend;
            parameters[6].Value = model.addTime;
            parameters[7].Value = model.status;
            parameters[8].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private void ShowInfo(int siId)
        {
            hm.BLL.ed_product   bll   = new hm.BLL.ed_product();
            hm.Model.ed_product model = bll.GetModel(siId);
            this.lblId.Text     = model.ID.ToString();
            txtTitle.Text       = model.title;
            this.txtRemark.Text = model.remark;
            imagePic.ImageUrl   = model.picSmall;
            litPicSmall.Text    = model.picSmall;
            litPicBig.Text      = model.picBig;
            if (model.isRecommend.Value == 1)
            {
                cbRecommend.Checked = true;
            }

            Model.ed_node modelNode = nBll.GetModel(model.nodeId.Value);
            litId.Text   = modelNode.ID.ToString();
            litName.Text = modelNode.title;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(hm.Model.ed_product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ed_product(");
            strSql.Append("nodeId,title,picSmall,picBig,remark,isRecommend,addTime,status)");
            strSql.Append(" values (");
            strSql.Append("@nodeId,@title,@picSmall,@picBig,@remark,@isRecommend,@addTime,@status)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@nodeId",      OleDbType.Integer,   4),
                new OleDbParameter("@title",       OleDbType.VarChar, 255),
                new OleDbParameter("@picSmall",    OleDbType.VarChar, 255),
                new OleDbParameter("@picBig",      OleDbType.VarChar, 255),
                new OleDbParameter("@remark",      OleDbType.VarChar,   0),
                new OleDbParameter("@isRecommend", OleDbType.Integer,   4),
                new OleDbParameter("@addTime",     OleDbType.Date),
                new OleDbParameter("@status",      OleDbType.Integer, 4)
            };
            parameters[0].Value = model.nodeId;
            parameters[1].Value = model.title;
            parameters[2].Value = model.picSmall;
            parameters[3].Value = model.picBig;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.isRecommend;
            parameters[6].Value = model.addTime;
            parameters[7].Value = model.status;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }