using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_adclass : Fm.Bussiness.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GetPage("");
    }
    //查询数据并且分页
    void GetPage(string where)
    {
        FormPaging1.TableName = "Fm_adclass";
        FormPaging1.ColName = "acid";
        FormPaging1.Where = where;
        FormPaging1.Gv = GVad;
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Fm.EntityClass.adclass ac = new Fm.EntityClass.adclass();
        ac.acname = acname.Text;
        ac.acintro = acintro.Text;

        Fm.Bussiness.ad ad = new Fm.Bussiness.ad();
        if (actype_add.Checked)
        {
            ad.ADD(ac);
            Response.Redirect("Erro.aspx?eid=新分类添加成功!&url=adclass.aspx", false);
            
        }
        else if(actype_edit.Checked)
        {
            ac.acid = int.Parse(acid.Value);
            ad.Update(ac);
            Response.Redirect("Erro.aspx?eid=分类信息修改成功!&url=adclass.aspx", false);
        }
    }
    protected void GVad_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Fm.Bussiness.public_select ps = new Fm.Bussiness.public_select();
        if (ps.Queryps("delete from Fm_adclass where acid="+GVad.Rows[e.RowIndex].Cells[0].Text))
        {
            if (ps.Queryps("delete from Fm_ad where acid=" + GVad.Rows[e.RowIndex].Cells[0].Text))
            {
                Response.Redirect("Erro.aspx?eid=该分类删除成功!&url=adclass.aspx", false);
            }
        }
    }
    protected void GVad_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //actype_add.Checked = false;
        actype_edit.Checked = true;
        acid.Value = GVad.Rows[e.NewEditIndex].Cells[0].Text;
        acname.Text = GVad.Rows[e.NewEditIndex].Cells[1].Text;
        acintro.Text = GVad.Rows[e.NewEditIndex].Cells[2].Text;
    }
}
