/*private void butDelete_Click(object sender, System.EventArgs e) { * if(IsNew){ * DialogResult=DialogResult.Cancel; * return; * } * try{ * UserCur.Delete(); * } * catch(Exception ex){ * MessageBox.Show(ex.Message); * return; * } * DialogResult=DialogResult.OK; * }*/ private void butOK_Click(object sender, System.EventArgs e) { if (textUserName.Text == "") { MsgBox.Show(this, "Please enter a username."); return; } UserCur.UserName = textUserName.Text; UserCur.UserGroupNum = UserGroups.List[listUserGroup.SelectedIndex].UserGroupNum; if (listEmployee.SelectedIndex == 0) { UserCur.EmployeeNum = 0; } else { UserCur.EmployeeNum = Employees.ListShort[listEmployee.SelectedIndex - 1].EmployeeNum; } try{ Userods.InsertOrUpdate(IsNew, UserCur); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
/*private void butDelete_Click(object sender, System.EventArgs e) { * if(IsNew){ * DialogResult=DialogResult.Cancel; * return; * } * try{ * UserCur.Delete(); * } * catch(Exception ex){ * MessageBox.Show(ex.Message); * return; * } * DialogResult=DialogResult.OK; * }*/ private void butOK_Click(object sender, System.EventArgs e) { if (textUserName.Text == "") { MsgBox.Show(this, "Please enter a username."); return; } if (listEmployee.SelectedIndex > 0 && listProv.SelectedIndex > 0) { MsgBox.Show(this, "Cannot set an employee and a provider for the same user."); return; } UserCur.IsHidden = checkIsHidden.Checked; UserCur.UserName = textUserName.Text; UserCur.UserGroupNum = UserGroups.List[listUserGroup.SelectedIndex].UserGroupNum; if (listEmployee.SelectedIndex == 0) { UserCur.EmployeeNum = 0; } else { UserCur.EmployeeNum = Employees.ListShort[listEmployee.SelectedIndex - 1].EmployeeNum; } if (listProv.SelectedIndex == 0) { UserCur.ProvNum = 0; } else { UserCur.ProvNum = Providers.List[listProv.SelectedIndex - 1].ProvNum; } if (PrefB.GetBool("EasyNoClinics") || listClinic.SelectedIndex == 0) { UserCur.ClinicNum = 0; } else { UserCur.ClinicNum = Clinics.List[listClinic.SelectedIndex - 1].ClinicNum; } try{ Userods.InsertOrUpdate(IsNew, UserCur); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
///<summary>Not possible if no security admin.</summary> private void butCreateUsers_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length == 0) { MsgBox.Show(this, "Please select one or more providers first."); return; } for (int i = 0; i < gridMain.SelectedIndices.Length; i++) { if (table.Rows[i]["UserName"].ToString() != "") { MsgBox.Show(this, "Not allowed to create users on providers which already have users."); return; } } if (comboUserGroup.SelectedIndex == -1) { MsgBox.Show(this, "Please select a User Group first."); return; } for (int i = 0; i < gridMain.SelectedIndices.Length; i++) { Userod user = new Userod(); user.UserGroupNum = UserGroups.List[comboUserGroup.SelectedIndex].UserGroupNum; user.ProvNum = PIn.PInt(table.Rows[gridMain.SelectedIndices[i]]["ProvNum"].ToString()); user.UserName = GetUniqueUserName(table.Rows[gridMain.SelectedIndices[i]]["LName"].ToString(), table.Rows[gridMain.SelectedIndices[i]]["FName"].ToString()); user.Password = user.UserName; //this will be enhanced later. try{ Userods.InsertOrUpdate(true, user); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); changed = true; return; } } changed = true; FillGrid(); }