예제 #1
0
파일: UserForm.cs 프로젝트: liwei5946/CEMS
 /// <summary>
 /// 修改按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void editButton_Click(object sender, EventArgs e)
 {
     string id = grid1[grid1.Selection.ActivePosition.Row, 0].ToString();//选中行的id
     UserEditForm kef = new UserEditForm(id);
     try
     {
         if (kef.ShowDialog() == DialogResult.OK)
         {
             Account acc = new Account();
             DataSet ds = acc.queryUsers();
             BindSourceGrid(grid1, ds.Tables[0]);
             grid1.Selection.SelectRow(1, true);
             grid1.Selection.FocusFirstCell(true);
         }
         ///MessageBox.Show(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
     }
     catch (Exception mye)
     {
         log.Error(mye.Message);
     }
 }
예제 #2
0
파일: UserForm.cs 프로젝트: liwei5946/CEMS
 /// <summary>
 /// 添加按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void addButton_Click(object sender, EventArgs e)
 {
     UserAddForm uaf = new UserAddForm();
     if (uaf.ShowDialog() == DialogResult.OK)
     {
         //重新绑定DataGridView;
         Account acc = new Account();
         DataSet ds = acc.queryUsers();
         BindSourceGrid(grid1, ds.Tables[0]);
         grid1.Selection.SelectRow(1, true);
         grid1.Selection.FocusFirstCell(true);
     }
 }
예제 #3
0
파일: UserForm.cs 프로젝트: liwei5946/CEMS
 /// <summary>
 /// 删除按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void delButton_Click(object sender, EventArgs e)
 {
     DialogResult dr;
     Boolean flag = false;
     if (grid1[grid1.Selection.ActivePosition.Row, 0] != null)
     {
         dr = MessageBox.Show("您确认删除用户\"" + grid1[grid1.Selection.ActivePosition.Row, 0].ToString() + "\"?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             Account acc = new Account();
             //flag = acc.deleteFaultById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             //flag = acc.deleteKnowledgeById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             flag = acc.deleteUserByUsername(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             if (flag)
             {
                 MessageBox.Show("删除成功!");
                 DataSet ds = acc.queryUsers();
                 BindSourceGrid(grid1, ds.Tables[0]);
                 grid1.Selection.SelectRow(1, true);
                 grid1.Selection.FocusFirstCell(true);
             }
             else
             {
                 MessageBox.Show("删除失败!");
             }
         }
     }
 }
예제 #4
0
파일: UserForm.cs 프로젝트: liwei5946/CEMS
        //窗体初始化
        private void AccountForm_Load(object sender, EventArgs e)
        {
            Cursor cr = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;//将光标置为等待状态

            //this.WindowState = FormWindowState.Maximized;
            //数据格
            Account acc = new Account();
            DataSet ds = acc.queryUsers();
            BindSourceGrid(grid1, ds.Tables[0]);
            grid1.Selection.SelectRow(1, true);
            grid1.Selection.FocusFirstCell(true);
            Cursor.Current = cr;//将光标置回原来状态
        }