protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string idValue = Request.Params["id"];
         if (idValue != null)
         {
             int id = Convert.ToInt32(idValue);
             LMessageSortBB messageSortBB = new LMessageSortBB();
             try
             {
                 LMessageSortData messageSortData = new LMessageSortData();
                 messageSortData = messageSortBB.GetModel(id);
                 //����й��������˴�Ҫ��֤�Ƿ�����ɾ��
                 messageSortBB.DeleteRecord(id);
                 this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
             }
             catch (Exception ex)
             {
                 this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3)", true);
                 return;
             }
             finally
             {
                 messageSortBB.Dispose();
             }
         }
     }
 }
    /// <summary>
    /// ���ݱ���
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        LMessageSortData model = new LMessageSortData();
        LMessageSortBB messageSortBB = new LMessageSortBB();
        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                this.IdValue = messageSortBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = messageSortBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                messageSortBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            messageSortBB.Dispose();
        }

        Response.Redirect("LMessageSortList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false);
    }
    /// <summary>
    /// ɾ��
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LMessageSortBB messageSortBB = new LMessageSortBB();
        try
        {
            //��ȡѡ�е�����Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    messageSortBB.DeleteRecord(id);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            messageSortBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
 /// <summary>
 /// չʾ����
 /// </summary>
 /// <param name="id">��¼Id</param>
 private void ShowInfo(int id)
 {
     LMessageSortBB messageSortBB = new LMessageSortBB();
     LMessageSortData model = new LMessageSortData();
     try
     {
         model = messageSortBB.GetModel(id);
         this.sortNm.Text = model.sortNm;
     }
     finally
     {
         messageSortBB.Dispose();
     }
 }
    /// <summary>
    /// ��Grid
    /// </summary>
    protected void BindGrid()
    {
        LMessageSortBB messageSortBB = new LMessageSortBB();
        DataSet ds = new DataSet();

        try
        {
            ds = messageSortBB.GetList(this.StrWhere);
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();
            //��ֵ��¼������ҳ������
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            messageSortBB.Dispose();
        }
    }
 private void BindList()
 {
     LMessageSortBB messageSortBB = new LMessageSortBB();
     DataSet ds = new DataSet();
     try
     {
         ds = messageSortBB.GetList("");
         this.sort.DataTextField = "sortNm";
         this.sort.DataValueField = "id";
         this.sort.DataSource = ds;
         this.sort.DataBind();
     }
     finally
     {
         messageSortBB.Dispose();
     }
 }
 /// <summary>
 /// ������������
 /// </summary>
 private void BindList()
 {
     LMessageSortBB messageSortBB = new LMessageSortBB();
     try
     {
         DataSet ds = messageSortBB.GetList("");
         this.sortNm.DataTextField = "sortNm";
         this.sortNm.DataValueField = "id";
         this.sortNm.DataSource = ds.Tables[0];
         this.sortNm.DataBind();
         this.sortNm.Items.Insert(0, new ListItem("-��ѡ��-", ""));
     }
     finally
     {
         messageSortBB.Dispose();
     }
 }