Ejemplo n.º 1
0
        public IList <EyouSoft.Model.SiteStructure.SiteChangePic> GetSiteChange(int CompanyId)
        {
            IList <EyouSoft.Model.SiteStructure.SiteChangePic> items = new List <EyouSoft.Model.SiteStructure.SiteChangePic>();

            EyouSoft.Model.SiteStructure.SiteChangePic item = null;
            DbCommand dc = this.DB.GetSqlStringCommand(String.Format("SELECT * FROM [tbl_SiteAttach] WHERE [CompanyId]={0}", CompanyId));

            using (IDataReader rdr = DbHelper.ExecuteReader(dc, this.DB))
            {
                {
                    while (rdr.Read())
                    {
                        item = new EyouSoft.Model.SiteStructure.SiteChangePic()
                        {
                            Id        = rdr.GetInt32(rdr.GetOrdinal("AttachId")),
                            CompanyId = rdr.IsDBNull(rdr.GetOrdinal("CompanyId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("CompanyId")),
                            FileName  = rdr["FileName"].ToString(),
                            FilePath  = rdr["FilePath"].ToString(),
                            ItemId    = rdr.IsDBNull(rdr.GetOrdinal("ItemId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("ItemId")),
                            ItemType  = (EyouSoft.Model.EnumType.SiteStructure.ItemType)(rdr.IsDBNull(rdr.GetOrdinal("ItemType")) ? 0 : rdr.GetByte(rdr.GetOrdinal("ItemType"))),
                            SortId    = rdr.IsDBNull(rdr.GetOrdinal("SortId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("SortId")),
                            URL       = rdr["URL"].ToString()
                        };
                        items.Add(item);
                    }
                }
                return(items);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 修改轮换图片
 /// </summary>
 /// <param name="SiteChangePic"></param>
 /// <returns></returns>
 public bool UpdateSiteChangePic(EyouSoft.Model.SiteStructure.SiteChangePic SiteChangePic)
 {
     if (SiteChangePic == null || SiteChangePic.CompanyId == 0 || SiteChangePic.Id == 0)
     {
         return(false);
     }
     return(idal.UpdateSiteChangePic(SiteChangePic));
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断权限
            if (!CheckGrant(global::Common.Enum.TravelPermission.系统设置_同行平台栏目))
            {
                Utils.ResponseNoPermit(global::Common.Enum.TravelPermission.系统设置_同行平台栏目, false);
                return;
            }
            if (!IsPostBack)
            {
                //初始化轮换图片实体
                ssModel = new EyouSoft.Model.SiteStructure.SiteChangePic();

                //获取轮换图片列表
                list = ssBLL.GetSiteChange(SiteUserInfo.CompanyID);
                //获取记录条数
                con = list.Count;
                //循环5次,对5个实体进行操作
                for (int i = 0; i < 5; i++)
                {
                    //判断用户是否存在第i个实体
                    if (list.Count > i)
                    {
                        //根据循环定义textbox
                        TextBox URL = (TextBox)Page.Form.FindControl("txt_URL" + (i + 1).ToString());
                        ///////对已有图片的URL进行赋值
                        //判断图片的连接是否为空
                        if (list[i].URL.Trim() == "")
                        {
                            URL.Text = "http://";//空的情况下,默认添加“http://”
                        }
                        else
                        {
                            URL.Text = list[i].URL;//不为空则获取列表中对应的连接地址
                        }
                    }
                }
            }
            //异步删除图片操作
            if (Request["id"] != null && Request["bid"] != null)//判断是否为删除操作
            {
                //获取删除图片ID
                int id = Utils.GetInt(Request["id"].ToString());
                //获取原有数据
                ssModel = ssBLL.GetSiteChange(id, SiteUserInfo.CompanyID);
                //清空图片路径
                ssModel.FilePath = "";
                //保存数据
                ssBLL.UpdateSiteChangePic(ssModel);

                bool res = false;
                res = ssBLL.UpdateSiteChangePic(ssModel);
                Response.Clear();
                Response.Write(string.Format("{{\"res\":{0}}}", res ? 1 : -1));
                Response.End();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加轮换图片
        /// </summary>
        /// <param name="SiteChangePic"></param>
        /// <returns></returns>
        public bool AddSiteChangePic(EyouSoft.Model.SiteStructure.SiteChangePic SiteChangePic)
        {
            string    SQL = "INSERT INTO [tbl_SiteAttach]([CompanyId],[FileName],[FilePath],[ItemId],[ItemType],[SortId],[URL]) VALUES(@CompanyId,@FileName,@FilePath,@ItemId,@ItemType,@SortId,@URL)";
            DbCommand dc  = this.DB.GetSqlStringCommand(SQL);

            this.DB.AddInParameter(dc, "CompanyId", DbType.Int32, SiteChangePic.CompanyId);
            this.DB.AddInParameter(dc, "FileName", DbType.String, SiteChangePic.FileName);
            this.DB.AddInParameter(dc, "FilePath", DbType.String, SiteChangePic.FilePath);
            this.DB.AddInParameter(dc, "ItemId", DbType.Int32, SiteChangePic.ItemId);
            this.DB.AddInParameter(dc, "ItemType", DbType.Byte, (int)SiteChangePic.ItemType);
            this.DB.AddInParameter(dc, "SortId", DbType.Int32, SiteChangePic.SortId);
            this.DB.AddInParameter(dc, "URL", DbType.String, SiteChangePic.URL);
            return(DbHelper.ExecuteSql(dc, this.DB) > 0 ? true : false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 修改轮换图片
        /// </summary>
        /// <param name="SiteChangePic"></param>
        /// <returns></returns>
        public bool UpdateSiteChangePic(EyouSoft.Model.SiteStructure.SiteChangePic SiteChangePic)
        {
            string    SQL = "UPDATE [tbl_SiteAttach] SET [FileName]=@FileName,[FilePath]=@FilePath,[ItemId]=@ItemId,[ItemType]=@ItemType,[SortId]=@SortId,[URL]=@URL WHERE [AttachId]=@AttachId AND [CompanyId]=@CompanyId";
            DbCommand dc  = this.DB.GetSqlStringCommand(SQL);

            this.DB.AddInParameter(dc, "AttachId", DbType.Int32, SiteChangePic.Id);
            this.DB.AddInParameter(dc, "CompanyId", DbType.Int32, SiteChangePic.CompanyId);
            this.DB.AddInParameter(dc, "FileName", DbType.String, SiteChangePic.FileName);
            this.DB.AddInParameter(dc, "FilePath", DbType.String, SiteChangePic.FilePath);
            this.DB.AddInParameter(dc, "ItemId", DbType.Int32, SiteChangePic.ItemId);
            this.DB.AddInParameter(dc, "ItemType", DbType.Byte, (int)SiteChangePic.ItemType);
            this.DB.AddInParameter(dc, "SortId", DbType.Int32, SiteChangePic.SortId);
            this.DB.AddInParameter(dc, "URL", DbType.String, SiteChangePic.URL);
            return(DbHelper.ExecuteSql(dc, this.DB) > 0 ? true : false);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到轮换图片列表
        /// </summary>
        /// <param name="companyId">专线公司编号</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public IList <EyouSoft.Model.SiteStructure.SiteChangePic> GetSiteChange(int CompanyId, int pageSize, int pageIndex, ref int recordCount)
        {
            IList <EyouSoft.Model.SiteStructure.SiteChangePic> items = new List <EyouSoft.Model.SiteStructure.SiteChangePic>();

            EyouSoft.Model.SiteStructure.SiteChangePic item = null;
            StringBuilder cmdQuery      = new StringBuilder();
            string        tableName     = "tbl_SiteAttach";
            string        primaryKey    = "AttachId";
            string        orderByString = "SortId ASC";
            StringBuilder fields        = new StringBuilder();

            #region 要查询的字段
            fields.Append("AttachId,CompanyId,ItemId,ItemType,FilePath,FileName,URL,SortId");
            #endregion
            #region 拼接查询条件
            cmdQuery.AppendFormat(" CompanyId={0}", CompanyId);
            #endregion
            using (IDataReader rdr = DbHelper.ExecuteReader(this.DB, pageSize, pageIndex, ref recordCount, tableName, primaryKey, fields.ToString(), cmdQuery.ToString(), orderByString))
            {
                while (rdr.Read())
                {
                    item = new EyouSoft.Model.SiteStructure.SiteChangePic()
                    {
                        Id        = rdr.GetInt32(rdr.GetOrdinal("AttachId")),
                        CompanyId = rdr.IsDBNull(rdr.GetOrdinal("CompanyId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("CompanyId")),
                        FileName  = rdr["FileName"].ToString(),
                        FilePath  = rdr["FilePath"].ToString(),
                        ItemId    = rdr.IsDBNull(rdr.GetOrdinal("ItemId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("ItemId")),
                        ItemType  = (EyouSoft.Model.EnumType.SiteStructure.ItemType)(rdr.IsDBNull(rdr.GetOrdinal("ItemType")) ? 0 : rdr.GetByte(rdr.GetOrdinal("ItemType"))),
                        SortId    = rdr.IsDBNull(rdr.GetOrdinal("SortId")) ? 0 : rdr.GetInt32(rdr.GetOrdinal("SortId")),
                        URL       = rdr["URL"].ToString()
                    };
                    items.Add(item);
                }
            }
            return(items);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //初始化BLL
            EyouSoft.BLL.SiteStructure.SiteChangePic ssBLL = new EyouSoft.BLL.SiteStructure.SiteChangePic();
            //初始化Model
            ssModel = new EyouSoft.Model.SiteStructure.SiteChangePic();
            //图片路径
            string filepath = string.Empty;
            //操作结果,默认失败
            bool ser = false;

            list = ssBLL.GetSiteChange(SiteUserInfo.CompanyID);

            ////////////////////////////////////////上传
            for (int i = 0; i < 5; i++)
            {
                ///////////////////验证loge格式
                //logo验证格式
                string[] allowExtensions = new string[] { ".jpeg", ".jpg", ".bmp", ".gif", ".pdf" };
                //提示语
                string msg = string.Empty;
                //验证上传文件格式
                bool nameForm = EyouSoft.Common.Function.UploadFile.CheckFileType(Request.Files, "workAgree" + i.ToString(), allowExtensions, null, out msg);
                if (!nameForm)
                {
                    //提示第i个错误提示
                    Literal lstMsg = (Literal)Page.Form.FindControl("lstMsg" + (i + 1).ToString());
                    lstMsg.Text = msg;
                }
                ///////////////////上传
                string oldfilename = string.Empty;
                bool   result      = EyouSoft.Common.Function.UploadFile.FileUpLoad(Request.Files["workAgree" + i.ToString()], "SupplierControlFile", out filepath, out oldfilename);
                if (result)
                {
                    //获取文件后缀
                    //string a = System.IO.Path.GetExtension(filepath);
                    //图片保存路劲
                    ssModel.FilePath = filepath;
                    //图片连接路径
                    TextBox URL = (TextBox)Page.Form.FindControl("txt_URL" + (i + 1).ToString());
                    ssModel.URL = URL.Text;
                    //专线公司ID
                    ssModel.CompanyId = SiteUserInfo.CompanyID;
                    //上传图片Name
                    ssModel.FileName = oldfilename;//进入页面,不进行任何操作直接保存 Name会清空
                    //上传类型
                    ssModel.ItemType = EyouSoft.Model.EnumType.SiteStructure.ItemType.轮换图片;
                    //主键ID
                    ssModel.Id = Utils.GetInt(Utils.GetFormValue("tid" + (i + 1).ToString()));
                }

                /////////////////////////

                if (ssModel.Id == 0)
                {
                    //添加
                    ser = ssBLL.AddSiteChangePic(ssModel);
                }
                else
                {
                    if (ssModel.FilePath == "")
                    {
                        //修改
                        ssModel.FilePath = list[i].FilePath;
                    }
                    ser = ssBLL.UpdateSiteChangePic(ssModel);
                }
            }
            if (ser)
            {
                Response.Write("<script language=javascript>alert('添加成功!');window.location.href='/systemset/ToGoTerrace/RotateImg.aspx';</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('添加失败!')</script>");
            }
        }