protected void btnAdd_Click(object sender, EventArgs e)
 {
     MBusinessTypeData model = new MBusinessTypeData();
     MBusinessTypeBB businessTypeBB = new MBusinessTypeBB();
     try
     {
         if (this.State == "1")
         {
             this.SetModel(ref model);
             businessTypeBB.AddRecord(model);
         }
         else if (this.State == "2")
         {
             model = businessTypeBB.GetModel(this.IdValue);
             this.SetModel(ref model);
             businessTypeBB.ModifyRecord(model);
         }
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true);
         return;
     }
     finally
     {
         businessTypeBB.Dispose();
     }
 }
    /// <summary>
    /// ɾ��
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        MBusinessTypeBB businessTypeBB = new MBusinessTypeBB();
        try
        {
            //��ȡѡ�е�����Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    string messageNo = Convert.ToString(chkId.ValidationGroup);
                    businessTypeBB.DeleteRecord(messageNo);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            businessTypeBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// ��Grid
    /// </summary>
    protected void BindGrid()
    {
        MBusinessTypeBB businessTypeBB = new MBusinessTypeBB();
        DataSet ds = new DataSet();

        try
        {
            ds = businessTypeBB.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
        {
            businessTypeBB.Dispose();
        }
    }
 private void ShowInfo(string id)
 {
     MBusinessTypeBB businessTypeBB = new MBusinessTypeBB();
     MBusinessTypeData model = new MBusinessTypeData();
     try
     {
         model = businessTypeBB.GetModel(id);
         this.messageNo.Text = model.messageNo;
         this.messageNm.Text = model.messageNm;
         this.tableNm.Text = model.tableNm;
         this.recordKeyField.Text = model.recordKeyField;
         this.keyIsInt.Text = model.keyIsInt.ToString();
         this.titleField.Text = model.titleField;
         this.itemNo.Text = model.itemNo;
         this.remark.Text = model.remark;
         this.isRun.Text = model.isRun.ToString();
     }
     finally
     {
         businessTypeBB.Dispose();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
         {
             this.IdValue = Request.Params["id"];
         }
         if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty)
         {
             this.State = Request.Params["state"].ToString();
             switch (this.State)
             {
                 case "1":   //add
                     break;
                 case "2":   //update
                     //���ؿؼ�
                     MBusinessTypeBB businessTypeBB = new MBusinessTypeBB();
                     MBusinessTypeData businessTypeData = new MBusinessTypeData();
                     try
                     {
                         businessTypeData = businessTypeBB.GetModel(this.IdValue);
                         //����й��������˴�Ҫ��֤�Ƿ������޸�
                         this.ShowInfo(this.IdValue);
                     }
                     finally
                     {
                         businessTypeBB.Dispose();
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     this.BindGrid(this.IdValue);
 }