示例#1
0
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string     newsID = GV.DataKeys[e.RowIndex].Value.ToString();
            SQLHelper_ db     = new SQLHelper_();

            db.sql = "SELECT pic FROM " + com.tablePrefix + "News WHERE NewsID=" + newsID;
            DataTable dt = db.Get_DataTable();

            if (dt.Rows.Count > 0)
            {
                FileSys.delFile(dt.Rows[0]["pic"].ToString());
            }
            //删除相册中的照片
            db.sql = @"SELECT *
FROM " + com.tablePrefix + "News  WHERE ParentNewsID=" + newsID;
            dt     = new DataTable();
            dt     = db.Get_DataTable();
            foreach (DataRow dr in dt.Rows)
            {
                FileSys.delFile(dr["pic"].ToString());
            }
            db.sql = "DELETE News WHERE ParentNewsID=" + newsID;
            db.ExecSql();
            db.sql = "DELETE News WHERE NewsID=" + newsID;
            db.ExecSql();
            bindGv();
            alert.Show(Page, "删除成功");
        }
示例#2
0
        public DataTable getNewsDt()
        {
            SQLHelper_ db        = new SQLHelper_();
            string     pagesize  = PagerMember.PageSize.ToString();
            string     curpage   = pg.request(PagerMember.PagePara);
            string     pageCount = "";//总页数
            int        rowCount  = 0;

            if (pagesize == "")
            {
                pagesize = "10";
            }
            if (curpage == "")
            {
                curpage = "1";
            }
            string sql = @"SELECT * FROM " + com.tablePrefix + "Members ORDER BY RegTime DESC";

            sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
            db.sql = sql;
            DataSet   ds = db.Get_DataSet();
            DataTable dt = ds.Tables[2];

            pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
            rowCount  = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
            PagerMember.RecordCount = rowCount;
            if (rowCount == 0)
            {
                PagerMember.Visible = false;
            }
            return(dt);
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            com.adminLogin();

            if (!IsPostBack)
            {
                string productid = pg.request("productid"); //.NewsID
                string realLbid  = "";                      //lb.lbid
                if (productid == "")
                {
                    alert.ShowAndBack(Page, "productid未传递");
                    return;
                }
                else
                {
                    SQLHelper_ db = new SQLHelper_();
                    db.sql = "SELECT TOP 1 lbid,NewsID,Title FROM " + com.tablePrefix + "News WHERE NewsID=" + productid;
                    DataTable dt = db.Get_DataTable();
                    if (dt.Rows.Count > 0)
                    {
                        productName = dt.Rows[0]["Title"].ToString();
                        realLbid    = dt.Rows[0]["lbid"].ToString();
                    }
                }
                lblLbname.Text = productName;
                string pid = clsLB.getPid(realLbid);
                hlParentLbname.Text        = clsLB.getLbname(pid);
                hlParentLbname.NavigateUrl = "Prod.aspx?pid=" + pid;
                hlbid.Value = productid;
                bindGv();
            }
        }
示例#4
0
        protected void GV_RowCreated(object sender, GridViewRowEventArgs e)
        {
            productid = hlbid.Value;

            GridView g = (GridView)sender;

            if (g.Rows.Count == 0)
            {
                return;
            }
            int         index  = g.Rows.Count - 1;
            DataKey     key    = this.GV.DataKeys[index];
            string      NewsID = key.Value.ToString();
            GridViewRow gvr    = GV.Rows[index];

            #region ddlColor
            DropDownList ddl = (DropDownList)g.Rows[index].FindControl("ddlColor");
            if (ddl != null)
            {
                SQLHelper_ db = new SQLHelper_();
                db.sql = "SELECT id,ColorName,ColorValue,OrderId,SUBSTRING(('000'+CONVERT(varchar,OrderId)),LEN('000'+CONVERT(varchar,OrderId))-3,4)+' '+ColorName AS ColorText FROM " + com.tablePrefix + "Color ORDER BY OrderId";
                DataTable dt = db.Get_DataTable();
                ddl.DataSource     = dt;
                ddl.DataValueField = "id";
                ddl.DataTextField  = "ColorText";
                ddl.DataBind();
                if (NewsID.Length > 0)
                {
                    db.sql = "SELECT ColorId FROM " + com.tablePrefix + "News WHERE NewsId=" + NewsID;
                    DataTable dtc = db.Get_DataTable();
                    if (dtc.Rows.Count > 0)
                    {
                        ddl.SelectedValue = dtc.Rows[0][0].ToString();
                    }
                }
            }
            #endregion

            DropDownList ddl_imgtid = (DropDownList)g.Rows[index].FindControl("ddlpro_imgTypeid");
            if (ddl_imgtid != null)
            {
                SQLHelper_ db = new SQLHelper_();
                db.sql = "SELECT id,ImgTypeName FROM " + com.tablePrefix + "ProductImgType ORDER BY OrderId";
                DataTable dt = db.Get_DataTable();
                ddl_imgtid.DataSource     = dt;
                ddl_imgtid.DataValueField = "id";
                ddl_imgtid.DataTextField  = "ImgTypeName";
                ddl_imgtid.DataBind();
                if (NewsID.Length > 0)
                {
                    db.sql = "SELECT pro_imgTypeid FROM " + com.tablePrefix + "News WHERE NewsId=" + NewsID;
                    DataTable dti = db.Get_DataTable();
                    if (dti.Rows.Count > 0)
                    {
                        ddl_imgtid.SelectedValue = dti.Rows[0][0].ToString();
                    }
                }
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Session["AdminName"] = "admin"; //
            com.adminLogin();

            if (!IsPostBack)
            {
                bindProvince();
                string NewsID = pg.request("id");
                if (NewsID != "")
                {
                    string sql = @"SELECT c.id as provinceId,b.id as cityid, c.Name as provinceName,b.Name as cityName, a.* FROM " + com.tablePrefix + @"News a
LEFT JOIN City b ON a.cityid=b.id
LEFT JOIN Province c ON c.id=b.Pid
 WHERE lbid=24 and NewsID=" + NewsID;
                    try
                    {
                        SQLHelper_ db = new SQLHelper_();
                        db.sql = sql;
                        DataTable dt = db.Get_DataTable();
                        if (dt.Rows.Count > 0)
                        {
                            string title      = dt.Rows[0]["title"].ToString();
                            string body       = dt.Rows[0]["NewsBody"].ToString();
                            string desc       = dt.Rows[0]["Description"].ToString();
                            string provinceId = dt.Rows[0]["provinceId"].ToString();
                            string cityid     = dt.Rows[0]["cityid"].ToString();
                            hID.Value                 = NewsID;
                            txtTitle.Text             = title;
                            tbxBody.Text              = body;
                            tbxDesc.Text              = desc;//联系方式
                            ddlProvince.SelectedValue = provinceId;
                            if (provinceId != "")
                            {
                                bindCity(provinceId);
                            }
                            ddlCity.SelectedValue = cityid;
                            btnAdd.Text           = "修改并保存";
                            lblOper.Text          = "修改";
                            //tbxDesc.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message + "<br>" + sql);
                        Response.End();
                    }
                }
                else
                {
                    btnAdd.Text  = "添加";
                    lblOper.Text = "添加";
                }
                //txtStar.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
                //txtStudentCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
                //txtStudentTotalCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
            }
        }
示例#6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string lbid     = hLbid.Value;
            string id       = hID.Value;
            string title    = pg.GetSafeString(txtTitle.Text);
            string cityid   = ddlCity.SelectedValue;
            string newsBody = tbxBody.Text;
            string tel      = tbxDesc.Text;
            //if (tel.Length < 8)
            //{
            //    alert.ShowAndBack(Page, "联系方式不能小于8位数字");
            //    return;
            //}
            string sql = "";

            if (cityid == "0" || cityid.Length == 0)
            {
                alert.ShowAndBack(Page, "请选择省市");
                return;
            }
            if (id.Length > 0)
            {
                //修改
                sql = "UPDATE News SET Title='" + title + "',cityid='" + cityid + "',Description='" + tel + "',NewsBody='" + newsBody + "',EditTime=getdate() WHERE NewsID=" + id;
                SQLHelper_ db = new SQLHelper_();
                db.sql = sql;
                if (db.ExecSql() == "1")
                {
                    alert.showAndGo("修改成功", "NetworkManage.aspx");
                }
                else
                {
                    //alert.ShowAndBack(Page, "修改失败");
                    Response.Write(sql);
                    Response.End();
                }
            }
            else
            {
                //添加
                string newsid = clsNews.MaxNewsid();
                lbid = "24";
                sql  = "INSERT INTO News(NewsID,lbid,Title,cityid,Description,NewsBody,Creator) VALUES(" + newsid + "," + lbid + ",'" + title + "','" + cityid + "','" + tel + "','" + newsBody + "','" + Session["AdminName"].ToString() + "')";
                SQLHelper_ db = new SQLHelper_();
                db.sql = sql;
                string result = db.ExecSql();
                if (result == "1")
                {
                    alert.showAndGo("添加成功", "NetworkManage.aspx");
                }
                else
                {
                    Response.Write(result + ",sql=" + sql);
                    Response.End();
                    //alert.ShowAndBack(Page, "添加失败" + result);
                }
            }
        }
示例#7
0
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string     newsID = GV.DataKeys[e.RowIndex].Value.ToString();
            SQLHelper_ db     = new SQLHelper_();

            db.sql = "DELETE News WHERE NewsID=" + newsID;
            db.ExecSql();
            bindGv();
        }
示例#8
0
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string     id = GV.DataKeys[e.RowIndex].Value.ToString();
            SQLHelper_ db = new SQLHelper_();

            db.sql = "UPDATE DxMembers SET isDeleted=1 WHERE ID=" + id;
            db.ExecSql();
            bindGv();
            alert.Show(Page, "删除成功");
        }
示例#9
0
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string     lbid = GV.DataKeys[e.RowIndex].Value.ToString();
            SQLHelper_ db   = new SQLHelper_();

            db.sql = "DELETE Province WHERE id=" + lbid;
            db.ExecSql();
            bindGv();
            alert.Show(Page, "删除成功");
            return;
        }
示例#10
0
        public DataTable getNewsDt()
        {
            lbid = hlbid.Value;
            SQLHelper_ db = new SQLHelper_();

            try
            {
                if (Pager1 == null)
                {
                    Response.Write("2.1  Pager1 == null。");
                }
                if (Pager1.PageSize == null)
                {
                    Response.Write("2.2  Pager1.PageSize == null。");
                }



                string pagesize  = Pager1.PageSize.ToString();
                string curpage   = pg.request(Pager1.PagePara);
                string pageCount = "";//总页数
                int    rowCount  = 0;
                if (pagesize == "")
                {
                    pagesize = "20";
                }
                if (curpage == "")
                {
                    curpage = "1";
                }
                string sql = @"SELECT NewsID,Title,Pic,Description,OrderId
FROM " + com.tablePrefix + @"News 
WHERE lbid=" + lbid;
                sql   += " ORDER BY title";
                sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
                db.sql = sql;
                DataSet   ds = db.Get_DataSet();
                DataTable dt = ds.Tables[2];
                pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
                rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
                Pager1.RecordCount = rowCount;
                if (rowCount == 0)
                {
                    Pager1.Visible = false;
                }
                return(dt);
            }
            catch (NullReferenceException ex)
            {
                Response.Write("2. " + ex.Message + "。");
                //Response.End();
                return(new DataTable());
            }
        }
示例#11
0
        protected void bindProvince()
        {
            SQLHelper_ db = new SQLHelper_();

            db.sql = "SELECT id,name FROM " + com.tablePrefix + "Province ORDER BY OrderID";
            DataTable dt = db.Get_DataTable();

            ddlProvince.DataSource     = dt;
            ddlProvince.DataValueField = "id";
            ddlProvince.DataTextField  = "name";
            ddlProvince.DataBind();
        }
示例#12
0
        protected void bindDDlLbid()
        {
            string     sql = "SELECT lbid,lbname FROM " + com.tablePrefix + "lb WHERE parentid=1";
            SQLHelper_ db  = new SQLHelper_();

            db.sql = sql;
            DataTable dt = db.Get_DataTable();

            ddlLbid.DataSource     = dt;
            ddlLbid.DataTextField  = "lbname";
            ddlLbid.DataValueField = "lbid";
            ddlLbid.DataBind();
        }
示例#13
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string pwd     = txtPwd.Text;
            string newPwd  = txtNewPwd.Text;
            string newPwd2 = txtNewPwd2.Text;

            if (pwd.Length == 0)
            {
                alert.Show(Page, "请填写原密码");
                return;
            }
            if (newPwd.Length == 0)
            {
                alert.Show(Page, "请填写新密码");
                return;
            }
            if (newPwd != newPwd2)
            {
                alert.Show(Page, "新密码与确认新密码不一致");
                return;
            }


            string     memberName = Session["AdminName"].ToString();
            SQLHelper_ db         = new SQLHelper_();

            db.sql = "SELECT pwd FROM " + com.tablePrefix + "admin WHERE username='******'";
            DataTable dt = db.Get_DataTable();

            pwd    = com.MD5(pwd, 1);
            newPwd = com.MD5(newPwd, 1);

            if (dt.Rows.Count > 0)
            {
                if (pwd != dt.Rows[0]["pwd"].ToString())
                {
                    alert.Show(Page, "原密码错误");
                    return;
                }
                else
                {
                    db.sql = "UPDATE admin SET Pwd='" + newPwd + "' WHERE username='******'";
                    db.ExecSql();
                    alert.Show(Page, "修改成功");
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
示例#14
0
        public void bindGv()
        {
            lbid = hlbid.Value;
            string sql = @"SELECT *
FROM " + com.tablePrefix + @"News 
WHERE lbid=" + lbid;

            sql += " ORDER BY isTop DESC,IsIndex DESC,AddTime DESC";
            SQLHelper_ db = new SQLHelper_();

            db.sql = sql;
            DataTable dt = db.Get_DataTable();

            GV.DataSource = dt.DefaultView;
            GV.DataBind();
        }
示例#15
0
        protected void bindCity(string pid)
        {
            if (pid != "0")
            {
                SQLHelper_ db = new SQLHelper_();
                db.sql = "SELECT id,name FROM " + com.tablePrefix + "City WHERE pid=" + pid + " ORDER BY OrderID";
                DataTable dt = db.Get_DataTable();

                ddlCity.DataSource     = dt;
                ddlCity.DataValueField = "id";
                ddlCity.DataTextField  = "name";
                ddlCity.DataBind();
            }
            else
            {
                ddlCity.Items.Clear();
            }
        }
示例#16
0
        public DataTable getNewsDt()
        {
            SQLHelper_ db = new SQLHelper_();

            try
            {
                string pagesize  = Pager1.PageSize.ToString();
                string curpage   = pg.request(Pager1.PagePara);
                string pageCount = "";//总页数
                int    rowCount  = 0;
                if (pagesize == "")
                {
                    pagesize = "10";
                }
                if (curpage == "")
                {
                    curpage = "1";
                }
                string sql = "SELECT Id,LbName FROM DXLb WHERE  IsDeleted=0 ";
                if (ddlLbid.SelectedValue.Length > 0)
                {
                    sql += " AND ParentId=" + ddlLbid.SelectedValue;
                }

                sql   += " ORDER BY OrderId";
                sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
                db.sql = sql;
                DataSet   ds = db.Get_DataSet();
                DataTable dt = ds.Tables[2];
                pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
                rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
                Pager1.RecordCount = rowCount;
                //if (rowCount == 0) Pager1.Visible = false;
                return(dt);
            }
            catch (NullReferenceException ex)
            {
                Response.Write("2. " + ex.Message + "。");
                //Response.End();
                return(new DataTable());
            }
        }
示例#17
0
        public void bindGv(bool addNewRow)
        {
            lbid = hlbid.Value;
            SQLHelper_ db        = new SQLHelper_();
            string     pagesize  = Pager2.PageSize.ToString();
            string     curpage   = pg.request(Pager2.PagePara);
            string     pageCount = "";//总页数
            int        rowCount  = 0;

            if (pagesize == "")
            {
                pagesize = "5";
            }
            if (curpage == "")
            {
                curpage = "1";
            }
            string sql = @"SELECT *
FROM " + com.tablePrefix + @"News 
WHERE lbid=" + lbid;

            sql   += " ORDER BY isTop DESC,IsIndex DESC,EditTime DESC";
            sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
            db.sql = sql;
            DataSet   ds = db.Get_DataSet();
            DataTable dt = ds.Tables[2];

            pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
            rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
            Pager2.RecordCount = rowCount;
            if (rowCount == 0)
            {
                Pager2.Visible = false;
            }
            if (addNewRow)
            {
                DataRow newRow = dt.NewRow();
                dt.Rows.Add(newRow);
            }
            GV.DataSource = dt.DefaultView;
            GV.DataBind();
        }
示例#18
0
        protected void GV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string     newsID = GV.DataKeys[e.RowIndex].Value.ToString();
            SQLHelper_ db     = new SQLHelper_();

            //删除图片
            db.sql = "SELECT pic FROM " + com.tablePrefix + "News WHERE NewsID=" + newsID;
            DataTable dt = db.Get_DataTable();

            if (dt.Rows.Count > 0)
            {
                string pic = dt.Rows[0]["pic"].ToString();
                FileSys.delFile(pic);
            }
            db.sql = "DELETE News WHERE NewsID=" + newsID;
            db.ExecSql();
            bindGv();
            alert.Show(Page, "删除成功");
            return;
        }
示例#19
0
        public DataTable getNewsDt()
        {
            productid = hlbid.Value;
            SQLHelper_ db        = new SQLHelper_();
            string     pagesize  = Pager0.PageSize.ToString();
            string     curpage   = pg.request(Pager0.PagePara);
            string     pageCount = "";//总页数
            int        rowCount  = 0;

            if (pagesize == "")
            {
                pagesize = "20";
            }
            if (curpage == "")
            {
                curpage = "1";
            }
            string sql = @"SELECT c.imgTypeName,b.ColorValue,b.ColorName
,SUBSTRING((''000''+CONVERT(varchar,b.OrderId)),LEN(''000''+CONVERT(varchar,b.OrderId))-2,3)+''-''+b.ColorName AS ColorText
,a.*
FROM " + com.tablePrefix + @"News a LEFT JOIN " + com.tablePrefix + @"Color b ON a.colorId=b.id
LEFT JOIN " + com.tablePrefix + @"ProductImgType c ON c.id =a.pro_imgTypeid
WHERE a.ParentNewsID=" + productid;

            sql   += " ORDER BY a.OrderId";
            sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
            db.sql = sql;
            DataSet   ds = db.Get_DataSet();
            DataTable dt = ds.Tables[2];

            pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
            rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
            Pager0.RecordCount = rowCount;
            if (rowCount == 0)
            {
                Pager0.Visible = false;
            }
            return(dt);
        }
示例#20
0
        public void bindGv()
        {
            string provid = ddlProvince.SelectedValue;

            string sql = @"SELECT c.id AS ProvinceId, c.Name as provinceName,b.Name as cityName, a.* FROM " + com.tablePrefix + @"News a
LEFT JOIN City b ON a.cityid=b.id
LEFT JOIN Province c ON c.id=b.Pid
 WHERE 1=1 AND lbid=24 ";

            if (provid.Length > 0)
            {
                sql += " AND c.id=" + provid;
            }
            sql += " ORDER BY OrderId DESC";
            SQLHelper_ db = new SQLHelper_();

            db.sql = sql;
            DataTable dt = db.Get_DataTable();

            GV.DataSource = dt.DefaultView;
            GV.DataBind();
        }
示例#21
0
        public DataTable getNewsDt()
        {
            SQLHelper_ db = new SQLHelper_();

            try
            {
                string pagesize  = Pager1.PageSize.ToString();
                string curpage   = pg.request(Pager1.PagePara);
                string pageCount = "";//总页数
                int    rowCount  = 0;
                if (pagesize == "")
                {
                    pagesize = "10";
                }
                if (curpage == "")
                {
                    curpage = "1";
                }
                string sql = "SELECT id,name,OrderId,JianCheng FROM " + com.tablePrefix + "province WHERE 1=1 ";

                sql   += " ORDER BY OrderId";
                sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
                db.sql = sql;
                DataSet   ds = db.Get_DataSet();
                DataTable dt = ds.Tables[2];
                pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
                rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
                Pager1.RecordCount = rowCount;
                //if (rowCount == 0) Pager1.Visible = false;
                return(dt);
            }
            catch (NullReferenceException ex)
            {
                Response.Write("2. " + ex.Message + "。");
                //Response.End();
                return(new DataTable());
            }
        }
示例#22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            com.adminLogin();

            if (!IsPostBack)
            {
                string lbid     = pg.request("lbid"); //新闻.NewsID
                string realLbid = "";                 //lb.lbid
                if (lbid == "")
                {
                    SQLHelper_ db = new SQLHelper_();
                    db.sql = "SELECT TOP 1 lbid,NewsID,Title FROM " + com.tablePrefix + "News WHERE lbid=2";
                    DataTable dt = db.Get_DataTable();
                    if (dt.Rows.Count > 0)
                    {
                        lbid     = dt.Rows[0]["NewsID"].ToString();//图片集管理
                        lbname   = dt.Rows[0]["Title"].ToString();
                        realLbid = dt.Rows[0]["lbid"].ToString();
                    }
                }
                else
                {
                    SQLHelper_ db = new SQLHelper_();
                    db.sql = "SELECT TOP 1 lbid,NewsID,Title FROM " + com.tablePrefix + "News WHERE NewsID=" + lbid;
                    DataTable dt = db.Get_DataTable();
                    if (dt.Rows.Count > 0)
                    {
                        lbname   = dt.Rows[0]["Title"].ToString();
                        realLbid = dt.Rows[0]["lbid"].ToString();
                    }
                }
                lblLbname.Text             = lbname;
                hlParentLbname.Text        = clsLB.getLbname(realLbid);
                hlParentLbname.NavigateUrl = "News.aspx?lbid=" + realLbid;
                hlbid.Value = lbid;
                bindGv();
            }
        }
示例#23
0
        public string setTopBtn(string newsid)
        {
            string     re  = "";
            string     sql = "SELECT isNull(isTop,0) as isTop,lbid FROM " + com.tablePrefix + "News WHERE newsid=" + newsid;
            SQLHelper_ db  = new SQLHelper_();

            db.sql = sql;
            DataTable dt = db.Get_DataTable();

            if (dt.Rows.Count > 0)
            {
                string lbid = dt.Rows[0]["lbid"].ToString();
                if (dt.Rows[0][0].ToString() == "0")
                {
                    re = "<a href='News.aspx?act=top&lbid=" + lbid + "&id=" + newsid + "'>置顶</a>";
                }
                else
                {
                    re = "已置顶";
                }
            }
            return(re);
        }
示例#24
0
        public string setIsIndex(string newsid)
        {
            string     re  = "";
            string     sql = "SELECT isNull(IsIndex,0) as IsIndex,lbid FROM " + com.tablePrefix + "News WHERE newsid=" + newsid;
            SQLHelper_ db  = new SQLHelper_();

            db.sql = sql;
            DataTable dt = db.Get_DataTable();

            if (dt.Rows.Count > 0)
            {
                string lbid = dt.Rows[0]["lbid"].ToString();
                if (dt.Rows[0][0].ToString() == "0")
                {
                    re = "<a href='News.aspx?act=IsIndex&value=1&lbid=" + lbid + "&id=" + newsid + "' style='color:green;'>放到首页</a>";
                }
                else
                {
                    re = "<a href='News.aspx?act=IsIndex&value=0&lbid=" + lbid + "&id=" + newsid + "' style='color:red;'>取消首页</a>";
                }
            }
            return(re);
        }
示例#25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            com.adminLogin();

            if (!IsPostBack)
            {
                bindProvince();
                string id         = pg.request("id");
                string ProvinceId = pg.request("ProvinceId");
                ddlProvince.SelectedValue = ProvinceId;
                string lbid = "24";
                string act  = pg.request("act");
                if (act == "del")
                {
                    SQLHelper_ db = new SQLHelper_();
                    db.sql = "DELETE FROM " + com.tablePrefix + "News WHERE NewsID=" + id;
                    db.ExecSql();
                    alert.showAndGo("删除成功", "NetworkManage.aspx?ProvinceId=" + ProvinceId);

                    return;
                }
                bindGv();
            }
        }
示例#26
0
        public DataTable getNewsDt()
        {
            lbid = hlbid.Value;
            SQLHelper_ db        = new SQLHelper_();
            string     pagesize  = Pager0.PageSize.ToString();
            string     curpage   = pg.request(Pager0.PagePara);
            string     pageCount = "";//总页数
            int        rowCount  = 0;

            if (pagesize == "")
            {
                pagesize = "10";
            }
            if (curpage == "")
            {
                curpage = "1";
            }
            string sql = @"SELECT *
FROM " + com.tablePrefix + @"News 
WHERE ParentNewsID=" + lbid;

            sql   += " ORDER BY isTop DESC,IsIndex DESC,AddTime DESC";
            sql    = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
            db.sql = sql;
            DataSet   ds = db.Get_DataSet();
            DataTable dt = ds.Tables[2];

            pageCount          = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
            rowCount           = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
            Pager0.RecordCount = rowCount;
            if (rowCount == 0)
            {
                Pager0.Visible = false;
            }
            return(dt);
        }
示例#27
0
        protected void GV_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lbid = hlbid.Value;
            System.Web.UI.WebControls.Button btn = e.CommandSource as System.Web.UI.WebControls.Button;
            if (btn == null)
            {
                return;
            }
            int index = ((System.Web.UI.WebControls.GridViewRow)btn.Parent.Parent).RowIndex;

            DataKey key    = this.GV.DataKeys[index];
            string  NewsID = key.Value.ToString();

            if (e.CommandName == "PicMng")
            {
                Server.Transfer("PhotoManage.aspx?lbid=" + NewsID);
                return;
            }

            GridViewRow gvr = GV.Rows[index];

            if (e.CommandName == "upFile")
            {
                //寻找上传控件
                FileUpload fu = (FileUpload)gvr.FindControl("FileUpload1");
                if (fu != null)
                {
                    if (fu.HasFile)
                    {
                        SQLHelper_ db = new SQLHelper_();
                        //上传图片
                        string pic = UpFile(fu);
                        //删除原图
                        db.sql = "SELECT pic FROM " + com.tablePrefix + "News WHERE NewsID=" + NewsID;
                        string pic0 = db.Get_DataTable().Rows[0][0].ToString();
                        if (pic0.Length > 0)
                        {
                            FileSys.delFile(pic0);
                        }

                        //更新数据库
                        db.sql = "UPDATE News SET pic='" + pic + "' WHERE NewsID=" + NewsID;
                        db.ExecSql();

                        bindGv();
                        alert.Show(Page, "图片更新成功");
                    }
                }
            }
            if (e.CommandName == "Save")
            {
                //查找 title控件
                TextBox txtTitle = null;
                try
                {
                    txtTitle = this.GV.Rows[index].Cells[1].Controls[0] as TextBox;
                }
                catch
                {
                    alert.Show(Page, "未找到图片集名称控件");
                    return;
                }
                TextBox txtEditTime = null;
                try
                {
                    txtEditTime = this.GV.Rows[index].Cells[2].Controls[0] as TextBox;
                }
                catch
                {
                    alert.Show(Page, "未找到编辑日期控件");
                    return;
                }



                FileUpload fu = gvr.Cells[4].FindControl("FileUpload1") as FileUpload;

                string title    = pg.GetSafeString(txtTitle.Text.Trim());
                string EditTime = pg.GetSafeString(txtEditTime.Text.Trim());
                if (title == "")
                {
                    alert.Show(Page, "请填写图片集名称");
                    return;
                }
                if (EditTime == "")
                {
                    EditTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                }
                string     pic = UpFile(fu);
                SQLHelper_ db  = new SQLHelper_();
                if (NewsID.Length > 0)
                {
                    if (pic != "")
                    {
                        //更新
                        db.sql = "UPDATE News SET title='" + title + "',pic='" + pic + "',editTime='" + EditTime + "' WHERE NewsID=" + NewsID;
                    }
                    else
                    {
                        //更新
                        db.sql = "UPDATE News SET title='" + title + "',editTime='" + EditTime + "' WHERE NewsID=" + NewsID;
                    }
                    if (db.ExecSql() != "1")
                    {
                        alert.Show(Page, "保存失败");
                    }
                    else
                    {
                        GV.EditIndex = -1;
                        bindGv();
                    }
                }
                else
                {
                    //添加
                    NewsID = clsNews.MaxNewsid();
                    db.sql = "INSERT INTO News(lbid,NewsID,title,pic,EditTime,AddTime) VALUES(" + lbid + "," + NewsID + ",'" + title + "','" + pic + "','" + EditTime + "',getdate())";
                    if (db.ExecSql() != "1")
                    {
                        alert.Show(Page, "添加失败");
                    }
                    else
                    {
                        GV.EditIndex = -1;
                        bindGv();
                    }
                }
            }
        }
示例#28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Session["AdminName"] = "admin"; //
            com.adminLogin();

            if (!IsPostBack)
            {
                bindDDlLbid();

                string NewsID = pg.request("id");
                lbid = pg.request("lbid");
                if (lbid == "")
                {
                    lbid = "2";            //企业新闻
                }
                ddlLbid.SelectedValue = lbid;
                if (NewsID != "")
                {
                    string act = pg.request("act");
                    if (act == "delpic")
                    {
                        //由前台的jquery异步调用
                        string     imgsrc = pg.request("imgsrc");
                        SQLHelper_ db     = new SQLHelper_();
                        db.sql = "UPDATE News SET pic = replace(pic,'" + imgsrc + "','') WHERE NewsID=" + NewsID;
                        db.ExecSql();
                        db.sql = "UPDATE News SET pic = replace(pic,'||','|') WHERE NewsID=" + NewsID;
                        db.ExecSql();
                        FileSys.delFile(imgsrc);
                        Response.Write("ok");
                        Response.End();
                    }
                    else
                    {
                        string sql = "SELECT * FROM " + com.tablePrefix + "News WHERE NewsID=" + NewsID;
                        try
                        {
                            SQLHelper_ db = new SQLHelper_();
                            db.sql = sql;
                            DataTable dt = db.Get_DataTable();
                            if (dt.Rows.Count > 0)
                            {
                                string title    = dt.Rows[0]["title"].ToString();
                                string newsBody = dt.Rows[0]["NewsBody"].ToString();
                                string pic      = dt.Rows[0]["pic"].ToString();
                                string addTime  = dt.Rows[0]["addTime"].ToString();
                                string picSmall = dt.Rows[0]["picSmall"].ToString();
                                string desc     = dt.Rows[0]["Description"].ToString();
                                string video    = dt.Rows[0]["pic"].ToString();


                                if (addTime.Length > 0)
                                {
                                    addTime = Convert.ToDateTime(addTime).ToString("yyyy-MM-dd hh:mm:ss");
                                }
                                lbid = dt.Rows[0]["lbid"].ToString();
                                ddlLbid.SelectedValue = lbid;
                                lbname    = clsLB.getLbname(lbid);
                                hID.Value = NewsID;
                                //hPic.Value = pic;
                                hSmallPic.Value  = picSmall;
                                txtTitle.Text    = title;
                                txtAddTime.Text  = addTime;
                                FCKeditor1.Value = newsBody;
                                FCKeditor2.Value = desc;
                                FCKeditor3.Value = video;
                                btnAdd.Text      = "修改并保存";
                                lblOper.Text     = "修改" + lbname;
                            }
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message + "<br>" + sql);
                            Response.End();
                        }
                    }
                }
                else
                {
                    lbname          = clsLB.getLbname(lbid);
                    txtAddTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    btnAdd.Text     = "添加";
                    lblOper.Text    = "添加" + lbname;
                }
                //txtStar.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
                //txtStudentCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
                //txtStudentTotalCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}");
            }
        }
示例#29
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string lbid  = ddlLbid.SelectedValue;
            string id    = hID.Value;
            string title = pg.GetSafeString(txtTitle.Text);
            string video = FCKeditor3.Value;
            //string oldPic = hPic.Value;
            //string newPic = hPic_new.Value;
            string oldSmallPic = hSmallPic.Value;
            string newsBody = pg.GetSafeString(FCKeditor1.Value).Replace("\"", "''");
            string desc = pg.GetSafeString(FCKeditor2.Value).Replace("\"", "''");
            string pic = "", picSmall = hSmallPic_new.Value;
            string addtime = pg.GetSafeString(txtAddTime.Text);

            //pic = oldPic + newPic;
            pic = pic.Replace("||", "|");
            string sql = "";

            if (id.Length > 0)
            {
                if (picSmall == "")
                {
                    //未上传小图
                    picSmall = oldSmallPic;
                }
                else
                {
                    //已上传小图并且原来有图
                    if (picSmall != "" && oldSmallPic != "")
                    {
                        //删除旧图
                        FileSys.delFile(oldSmallPic);
                    }
                }
                //修改
                sql = "UPDATE News SET lbid=" + lbid + ",Title='" + title + "',pic = '" + video + "',Description='" + desc + "',AddTime='" + addtime + "',picSmall='" + picSmall + "',NewsBody='" + newsBody + "',Editor='" + Session["AdminName"].ToString() + "',EditTime=getdate() WHERE NewsID=" + id;
                SQLHelper_ db = new SQLHelper_();
                db.sql = sql;
                string result = db.ExecSql();
                if (result == "1")
                {
                    //删除旧文件
                    //if (picSmall != oldPic)
                    //{
                    //    FileSys.delFile(oldPic);
                    //}

                    alert.showAndGo("修改成功", "News.aspx?lbid=" + lbid);
                }
                else
                {
                    //alert.ShowAndBack(Page, "修改失败");
                    Response.Write(result + ",sql=" + sql);
                    Response.End();
                }
            }
            else
            {
                //添加
                string newsid = clsNews.MaxNewsid();
                sql = "INSERT INTO News(NewsID,lbid,Title,pic,Description,AddTime,picSmall,NewsBody,Creator) VALUES(" + newsid + "," + lbid + ",'" + title + "','" + video + "','" + desc + "','" + addtime + "','" + picSmall + "','" + newsBody + "','" + Session["AdminName"].ToString() + "')";
                SQLHelper_ db = new SQLHelper_();
                db.sql = sql;
                string result = db.ExecSql();
                if (result == "1")
                {
                    alert.showAndGo("添加成功", "News.aspx?lbid=" + lbid);
                }
                else
                {
                    //Response.Write(sql);
                    alert.ShowAndBack(Page, "添加失败" + result);
                }
            }
        }
示例#30
0
        protected void GV_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            productid = hlbid.Value;
            System.Web.UI.WebControls.Button btn = e.CommandSource as System.Web.UI.WebControls.Button;
            if (btn == null)
            {
                return;
            }
            int index = ((System.Web.UI.WebControls.GridViewRow)btn.Parent.Parent).RowIndex;

            DataKey key    = this.GV.DataKeys[index];
            string  NewsID = key.Value.ToString();

            GridViewRow gvr = GV.Rows[index];


            #region 单击上传图片按钮
            if (e.CommandName == "upFile")
            {
                //寻找上传控件
                FileUpload fu  = (FileUpload)gvr.FindControl("FileUpload1");//原图
                string     pic = "";
                //上传图片
                pic = UpFile(fu);
                string picSmall = "";
                if (pic != "")
                {
                    picSmall = pic.ToLower().Replace(".jpg", "_s.jpg");
                    //ThumNail.MakeThumNail(pic, picSmall, 127, 127, "HW");
                    SQLHelper_ db = new SQLHelper_();

                    //删除原图
                    db.sql = "SELECT pic,picSmall FROM " + com.tablePrefix + "News WHERE NewsID=" + NewsID;
                    DataTable dtp = db.Get_DataTable();
                    if (dtp.Rows.Count > 0)
                    {
                        string pic0 = dtp.Rows[0][0].ToString();
                        string pic1 = dtp.Rows[0][1].ToString();
                        if (pic0.Length > 0)
                        {
                            FileSys.delFile(pic0);
                        }
                        if (pic1.Length > 0)
                        {
                            FileSys.delFile(pic1);
                        }
                    }
                    //更新数据库
                    db.sql = "UPDATE News SET pic='" + pic + "',picSmall='" + picSmall + "' WHERE NewsID=" + NewsID;
                    db.ExecSql();

                    bindGv();
                    alert.Show(Page, "图片更新成功");
                }
            }
            #endregion

            #region 保存
            if (e.CommandName == "Save")
            {
                //查找 title控件
                TextBox txtTitle = null;
                try
                {
                    txtTitle = this.GV.Rows[index].Cells[1].Controls[0] as TextBox;
                }
                catch
                {
                    alert.ShowAndBack(Page, "未找到标题控件");
                    return;
                }
                string colorid = "-1";

                try
                {
                    DropDownList ddlColor = (DropDownList)GV.Rows[index].FindControl("ddlColor");
                    colorid = ddlColor.SelectedValue;
                }
                catch (Exception)
                {
                    alert.ShowAndBack(Page, "未找到颜色控件");
                    return;
                }

                string imgTypeid = "";
                try
                {
                    DropDownList ddImglType = (DropDownList)GV.Rows[index].FindControl("ddlpro_imgTypeid");
                    imgTypeid = ddImglType.SelectedValue;
                }
                catch (Exception)
                {
                    alert.ShowAndBack(Page, "未找到图片类型控件");
                    return;
                }
                FileUpload fu = gvr.Cells[5].FindControl("FileUpload1") as FileUpload;

                string title = pg.GetSafeString(txtTitle.Text.Trim());
                if (title == "")
                {
                    alert.ShowAndBack(Page, "请填写标题");
                    return;
                }

                TextBox tbxOrder = null;
                try
                {
                    tbxOrder = this.GV.Rows[index].Cells[6].Controls[0] as TextBox;
                }
                catch
                {
                    alert.ShowAndBack(Page, "未找到排序文本框控件");
                    return;
                }
                string orderid = pg.GetSafeString(tbxOrder.Text.Trim());
                if (orderid == "")
                {
                    orderid = "0";
                }

                string pic      = UpFile(fu);
                string picSmall = "";
                if (pic != "")
                {
                    picSmall = pic.ToLower().Replace(".jpg", "_s.jpg");
                }
                SQLHelper_ db = new SQLHelper_();

                if (NewsID.Length > 0)
                {
                    //取出旧图
                    string oldPic = "", oldPicSmall = "";
                    db.sql = "SELECT pic,picSmall FROM " + com.tablePrefix + "News WHERE NewsID=" + NewsID;
                    DataTable dt = db.Get_DataTable();
                    if (dt.Rows.Count > 0)
                    {
                        oldPic      = dt.Rows[0]["pic"].ToString();
                        oldPicSmall = dt.Rows[0]["picSmall"].ToString();
                    }
                    //更新
                    string sql = "UPDATE News SET title='" + title + "',ColorId=" + colorid + ",pro_imgTypeid=" + imgTypeid + ",editTime=getdate(),OrderId=" + orderid;
                    if (pic.Length > 0)
                    {
                        sql += " ,pic='" + pic + "'";
                        FileSys.delFile(oldPic);
                    }
                    if (picSmall.Length > 0)
                    {
                        sql += " ,picSmall='" + picSmall + "'";
                        FileSys.delFile(oldPicSmall);
                    }
                    sql   += " WHERE NewsID=" + NewsID;
                    db.sql = sql;
                    if (db.ExecSql() != "1")
                    {
                        alert.Show(Page, "保存失败");
                    }
                    else
                    {
                        GV.EditIndex = -1;
                        bindGv();
                    }
                }
                else
                {
                    //添加
                    NewsID = clsNews.MaxNewsid();

                    db.sql = "INSERT INTO News(ParentNewsID,NewsID,title,ColorId,pro_imgTypeid,pic,picSmall,EditTime,AddTime,OrderId) VALUES(" + productid + "," + NewsID + ",'" + title + "'," + colorid + "," + imgTypeid + ",'" + pic + "','" + picSmall + "',getdate(),getdate()," + orderid + ")";
                    if (db.ExecSql() != "1")
                    {
                        Response.Write("添加失败,sql=" + db.sql);
                        //alert.Show(Page, "添加失败");
                        Response.End();
                    }
                    else
                    {
                        GV.EditIndex = -1;
                        bindGv();
                    }
                }
            }
            #endregion
        }