private void btn_Click(object sender, EventArgs e) { SimpleButton btn = sender as SimpleButton; DataRow dr = gridVMain.GetFocusedDataRow(); switch (btn.Name) { case "btnExcel": this.Cursor = Cursors.WaitCursor; StaticFunctions.GridViewExportToExcel(gridVMain, "系统用户信息", null); this.Cursor = Cursors.Arrow; break; case "btnAdd": gridVMain.ClearColumnsFilter(); gridVMain.ClearSorting(); SetWMode("ADD"); break; case "btnEdit": if (dr == null) { return; } SetWMode("EDIT"); break; case "btnCancel": if (dr == null) { return; } blInitBound = true; frmDataTable.RejectChanges(); //引发gridView1_FocusedRowChanged frmDataTable.AcceptChanges(); blInitBound = false; SetWMode("VIEW"); gridVMain_FocusedRowChanged(gridVMain, new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs(-1, gridVMain.FocusedRowHandle)); break; case "btnSave": if (dr == null) { return; } DoSave(); break; case "btnSetPsw": if (dr == null) { return; } if (MessageBox.Show("是否确认重置当前用户密码为 1?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } string[] strKey = "strEditSql,Key_Id,EUser_Id,EDept_Id,Fy_Id,flag".Split(",".ToCharArray()); DataTable dtAdd = this.DataRequest_By_DataTable(strSpName, strKey, new string[] { "PassWord='******'", dr[strKeyFiled].ToString(), CApplication.App.CurrentSession.UserId.ToString(), CApplication.App.CurrentSession.DeptId.ToString(), CApplication.App.CurrentSession.FyId.ToString(), "3" }); if (dtAdd == null) { return; } MessageBox.Show("操作完成."); break; case "btnRole": if (dr == null) { return; } frmBseUserRoleEdit frm = new frmBseUserRoleEdit(); frm.UserId = dr["User_Id"].ToString(); frm.UserInfo = "姓名:" + dr["Name"].ToString() + " 卡号:" + dr["CardNub"].ToString() + " 编号:" + dr["Number"].ToString(); frm.ShowDialog(); break; case "btnCopy": if (dr == null) { return; } if (txtSrcNumber.Text.Trim() == string.Empty) { MessageBox.Show("请输入来源员工工号."); return; } List <string> lisSpParmValue = new List <string>(); string[] strKeyCopy = "Number,Key_Id,EUser_Id,EDept_Id,Fy_Id,flag".Split(",".ToCharArray()); lisSpParmValue.AddRange(new string[] { txtSrcNumber.Text.Trim(), dr[strKeyFiled].ToString(), CApplication.App.CurrentSession.UserId.ToString(), CApplication.App.CurrentSession.DeptId.ToString(), CApplication.App.CurrentSession.FyId.ToString(), "21" }); DataTable dtCopy = this.DataRequest_By_DataTable(strSpName, strKeyCopy, lisSpParmValue.ToArray()); if (dtCopy == null) { return; } MessageBox.Show("操作完成."); break; case "btnRight": if (dr == null) { return; } frmBseUserRight frm2 = new frmBseUserRight(); frm2.UserId = dr["User_Id"].ToString(); frm2.UserName = dr["Number"].ToString() + "—" + dr["Name"].ToString(); frm2.ShowDialog(); break; default: break; } }
private void DoMyBtn(string strBtnName) { DataRow dr = gridVMain.GetFocusedDataRow(); switch (strBtnName) { case "btnSetRoleUser": if (dr == null) { return; } frmBseRoleUserEdit frm = new frmBseRoleUserEdit(); frm.RoleId = dr["Role_Id"].ToString(); frm.RoleName = dr["Role_Nme"].ToString(); frm.ShowDialog(); break; case "btnSetRoleRight": if (dr == null) { return; } frmBseRoleRight frm1 = new frmBseRoleRight(); frm1.RoleId = dr["Role_Id"].ToString(); frm1.RoleName = dr["Role_Nme"].ToString(); frm1.ShowDialog(this); break; case "btnSetUserRight": if (dr == null) { return; } frmBseUserRight frm2 = new frmBseUserRight(); frm2.UserId = dr["User_Id"].ToString(); frm2.UserName = dr["Number"].ToString() + "—" + dr["Name"].ToString(); frm2.ShowDialog(this); break; case "btnSetUserRole": if (dr == null) { return; } frmBseUserRoleEdit frm3 = new frmBseUserRoleEdit(); frm3.UserId = dr["User_Id"].ToString(); frm3.UserInfo = "姓名:" + dr["Name"].ToString() + " 编号:" + dr["Number"].ToString(); frm3.ShowDialog(); break; case "btnSetUserPsw": if (dr == null) { return; } string strMsg = "是否确认重置用户密码为 1 ,被重置用户:" + dr["Number"].ToString() + "—" + dr["Name"].ToString(); if (MessageBox.Show(strMsg, "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } string[] strKey = "strTableName,strTableFieldKey,strTableFieldValue,strSql,UserId,ActFlag".Split(",".ToCharArray()); string[] strVal = new string[] { "Bse_User", "User_Id", dr["User_Id"].ToString() , "PassWord='******'", CApplication.App.CurrentSession.UserId.ToString(), "EditPsd" }; DataTable dtRet = this.DataRequest_By_DataTable("Share_Update_Table_Value", strKey, strVal); if (dtRet.Rows[0][0].ToString() == "OK") { MessageBox.Show("重置成功."); } else { MessageBox.Show("重置失败."); } break; case "btnCreateBarcodeImage": if (gridVMain.SelectedRowsCount <= 0) { return; } tdCreateBarcodeImage = new Thread(new ThreadStart(CreateBarcodeImage)); tdCreateBarcodeImage.Start(); break; default: break; } }