Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <TFXK.Model.Link> DataTableToList(DataTable dt)
        {
            List <TFXK.Model.Link> modelList = new List <TFXK.Model.Link>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                TFXK.Model.Link model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TFXK.Model.Link();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.title       = dt.Rows[n]["title"].ToString();
                    model.linkUrl     = dt.Rows[n]["linkUrl"].ToString();
                    model.logo        = dt.Rows[n]["logo"].ToString();
                    model.isPictureOn = dt.Rows[n]["isPictureOn"].ToString();
                    if (dt.Rows[n]["orderId"].ToString() != "")
                    {
                        model.orderId = int.Parse(dt.Rows[n]["orderId"].ToString());
                    }
                    model.description = dt.Rows[n]["description"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
 private void InitData(int id)
 {
     TFXK.Model.Link model = bll.GetModel(id);
     if (model != null)
     {
         hiddenPicPath.Value = model.logo;
         txtName.Text        = model.title;
         txtOrder.Text       = model.orderId + "";
         txtUrl.Text         = model.linkUrl;
         if (!string.IsNullOrEmpty(model.logo))
         {
             imgLink.ImageUrl = "../../uploads/" + model.logo;
         }
         ;
         ddlLinkType.SelectedValue = model.isPictureOn;
         txtDescription.Text       = model.description;
     }
 }
Exemplo n.º 3
0
    protected void ibtnAdd_Click(object sender, EventArgs e)
    {
        //验证代码
        try
        {
            TFXK.Model.Link model = new TFXK.Model.Link();

            model.title       = this.txtName.Text;
            model.linkUrl     = this.txtUrl.Text;
            model.isPictureOn = ddlLinkType.SelectedValue;
            model.orderId     = this.txtOrder.Text.Equals("") ? 0 : int.Parse(this.txtOrder.Text);
            model.parentId    = 0;
            model.logo        = hiddenPicPath.Value;
            model.description = txtDescription.Text;

            #region   图片
            if (this.uploadImg.PostedFile.FileName != "")
            {
                string uppath = Server.MapPath("~/" + pathpage);
                string ext    = uploadImg.PostedFile.FileName.Substring(uploadImg.PostedFile.FileName.Length - 4);
                if (ext.ToUpper() == ".JPG" || ext.ToUpper() == ".PNG" || ext.ToUpper() == ".GIF" || ext.ToUpper() == ".BMP")
                {
                    string upName = DateTime.Now.ToString("yyyyMMddhhmmss") + ext;
                    try
                    {
                        uploadImg.SaveAs(uppath + upName);
                        if (hiddenPicPath.Value != "")
                        {
                            if (File.Exists(hiddenPicPath.Value))
                            {
                                File.Delete(hiddenPicPath.Value);
                            }
                        }
                        model.logo = upName;
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex);
                    }
                }
            }

            #endregion

            // 防止网页重复提交

            string type = this.hdfAction.Value.Trim();
            // 判断动作
            switch (type)
            {
            case "add":
                Add(model);
                break;

            case "modify":
                model.id = int.Parse(Request.QueryString["id"]);
                Modify(model);
                break;
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Msg.Show("网络错误!原因:" + ex.Message);
        }
    }
Exemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(TFXK.Model.Link model)
 {
     dal.Update(model);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TFXK.Model.Link model)
 {
     return(dal.Add(model));
 }