protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
 {
     if (Page.IsValid)
     {
         Departmentmr department = new Departmentmr();       //����Departmentmr����
         department.DepartmentId = Convert.ToInt32(txtDepartmentId.Text.Trim());
         if (!department.CheckDepartment(department.DepartmentId))//ʹ��CheckDepartment������֤�Ƿ����
         {
             department.DepartmentId = Convert.ToInt32(txtDepartmentId.Text.Trim());
             department.DepartmentName = txtDepartmentName.Text;
             if (department.InsertByStr())
             {
                 lblMessage.Text = "�ɹ�����ò�����Ϣ��";
                 Server.Transfer("DepartmentManage.aspx");
             }
             else
             {
                 lblMessage.Text = "��Ӳ���ʧ�ܣ�";
             }
         }
         else//�û����ڣ�������ʾ
         {
             lblMessage.Text = "���ݿ��д��ھ��иñ�ŵIJ��ţ����������룡";
         }
     }
 }
 //GridView�ؼ�RowDeleting�¼�
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     string departmentid = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); //ȡ��Ҫɾ����¼������ֵ
     Departmentmr department = new Departmentmr();//����Departmentmr�����department
     if (department.DeleteByStr(departmentid))//��������ʹ��DeleteByProc����ɾ���û�
     {
         Response.Write("<script language=javascript>alert('ɾ���ɹ�!')</script>");
     }
     else
     {
         Response.Write("<script language=javascript>alert('ɾ��ʧ��!')</script>");
     }
     GridView1.EditIndex = -1;
     GridViewBind();//���°�����
 }
 //GridView�ؼ�RowUpdating�¼�
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     string departmentid = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); //ȡ����¼������ֵ
     Departmentmr department = new Departmentmr();
     department.DepartmentName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDepartmentName")).Text;
     if (department.UpdateByStr(departmentid))//ʹ��Usersmr��UpdateByProc�����޸��û���Ϣ
     {
         GridViewBind();
         Response.Write("<script language=javascript>alert('�޸ijɹ�!')</script>");
     }
     else
     {
         Response.Write("<script language=javascript>alert('�޸ijɹ�!')</script>");
     }
     GridView1.EditIndex = -1;
     GridViewBind();
 }
 private void GridViewBind()
 {
     Departmentmr department = new Departmentmr();//����Usersmr�����user
     DataSet ds = department.QueryDepartment();//ʹ��Usersmr��QueryUsers������ѯ�����û���Ϣ
     GridView1.DataSource = ds;//ΪGridView�ؼ���������Դ
     GridView1.DataBind();//GridView�ؼ�������
 }