diff --git a/Common/GlobalData.cs b/Common/GlobalData.cs index b47ff1663..44b7e9260 100644 --- a/Common/GlobalData.cs +++ b/Common/GlobalData.cs @@ -18,7 +18,10 @@ namespace Common public static DBSettings LocalUsersDB = null; public static IUser CurrentUser; - public static Common.AuthorizedAs AuthorizedAs; + public static IUser CurrentUser2; + public static IUser CurrentUser3; + + public static Common.AuthorizedAs AuthorizedAs; public static DateTime LastAuthorization = DateTime.Now; public static int MinPasswdLength = 0; @@ -26,7 +29,14 @@ namespace Common public static string GetCurrentUserName() { - return (CurrentUser != null && CurrentUser.UserName != null) ? CurrentUser.UserName : string.Empty; + if (CurrentUser == null || CurrentUser.UserName == null) + return string.Empty; + else if (CurrentUser2 == null || CurrentUser2.UserName == null) + return CurrentUser.UserName; + else if (CurrentUser3 == null || CurrentUser3.UserName == null) + return string.Format("{0},{1}", CurrentUser.UserName, CurrentUser2.UserName); + else + return string.Format("{0},{1},{2}", CurrentUser.UserName, CurrentUser2.UserName, CurrentUser3.UserName); } } } diff --git a/SharedDatabase/Forms/DoubleLoginDlg.Designer.cs b/SharedDatabase/Forms/DoubleLoginDlg.Designer.cs new file mode 100644 index 000000000..0a9ef700e --- /dev/null +++ b/SharedDatabase/Forms/DoubleLoginDlg.Designer.cs @@ -0,0 +1,199 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +namespace SharedDatabase.Forms +{ + partial class DoubleLoginDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DoubleLoginDlg)); + this.aliasLabel1 = new System.Windows.Forms.Label(); + this.passwordLabel1 = new System.Windows.Forms.Label(); + this.passwordTextBox1 = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.userNameTextBox1 = new System.Windows.Forms.TextBox(); + this.workplaceGroupBox1 = new System.Windows.Forms.GroupBox(); + this.loginStatePictureBox1 = new System.Windows.Forms.PictureBox(); + this.workplaceGroupBox2 = new System.Windows.Forms.GroupBox(); + this.loginStatePictureBox2 = new System.Windows.Forms.PictureBox(); + this.userNameTextBox2 = new System.Windows.Forms.TextBox(); + this.aliasLabel2 = new System.Windows.Forms.Label(); + this.passwordLabel2 = new System.Windows.Forms.Label(); + this.passwordTextBox2 = new System.Windows.Forms.TextBox(); + this.workplaceGroupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox1)).BeginInit(); + this.workplaceGroupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox2)).BeginInit(); + this.SuspendLayout(); + // + // aliasLabel1 + // + resources.ApplyResources(this.aliasLabel1, "aliasLabel1"); + this.aliasLabel1.Name = "aliasLabel1"; + this.aliasLabel1.Click += new System.EventHandler(this.aliasLabel1_Click); + // + // passwordLabel1 + // + resources.ApplyResources(this.passwordLabel1, "passwordLabel1"); + this.passwordLabel1.Name = "passwordLabel1"; + // + // passwordTextBox1 + // + resources.ApplyResources(this.passwordTextBox1, "passwordTextBox1"); + this.passwordTextBox1.Name = "passwordTextBox1"; + this.passwordTextBox1.UseSystemPasswordChar = true; + this.passwordTextBox1.TextChanged += new System.EventHandler(this.passwordTextBox1_TextChanged); + this.passwordTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox1_KeyPress); + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // userNameTextBox1 + // + resources.ApplyResources(this.userNameTextBox1, "userNameTextBox1"); + this.userNameTextBox1.Name = "userNameTextBox1"; + this.userNameTextBox1.TextChanged += new System.EventHandler(this.userNameTextBox1_TextChanged); + this.userNameTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox1_KeyPress); + // + // workplaceGroupBox1 + // + this.workplaceGroupBox1.Controls.Add(this.loginStatePictureBox1); + this.workplaceGroupBox1.Controls.Add(this.userNameTextBox1); + this.workplaceGroupBox1.Controls.Add(this.aliasLabel1); + this.workplaceGroupBox1.Controls.Add(this.passwordLabel1); + this.workplaceGroupBox1.Controls.Add(this.passwordTextBox1); + resources.ApplyResources(this.workplaceGroupBox1, "workplaceGroupBox1"); + this.workplaceGroupBox1.Name = "workplaceGroupBox1"; + this.workplaceGroupBox1.TabStop = false; + // + // loginStatePictureBox1 + // + resources.ApplyResources(this.loginStatePictureBox1, "loginStatePictureBox1"); + this.loginStatePictureBox1.Name = "loginStatePictureBox1"; + this.loginStatePictureBox1.TabStop = false; + // + // workplaceGroupBox2 + // + this.workplaceGroupBox2.Controls.Add(this.loginStatePictureBox2); + this.workplaceGroupBox2.Controls.Add(this.userNameTextBox2); + this.workplaceGroupBox2.Controls.Add(this.aliasLabel2); + this.workplaceGroupBox2.Controls.Add(this.passwordLabel2); + this.workplaceGroupBox2.Controls.Add(this.passwordTextBox2); + resources.ApplyResources(this.workplaceGroupBox2, "workplaceGroupBox2"); + this.workplaceGroupBox2.Name = "workplaceGroupBox2"; + this.workplaceGroupBox2.TabStop = false; + // + // loginStatePictureBox2 + // + resources.ApplyResources(this.loginStatePictureBox2, "loginStatePictureBox2"); + this.loginStatePictureBox2.Name = "loginStatePictureBox2"; + this.loginStatePictureBox2.TabStop = false; + // + // userNameTextBox2 + // + resources.ApplyResources(this.userNameTextBox2, "userNameTextBox2"); + this.userNameTextBox2.Name = "userNameTextBox2"; + this.userNameTextBox2.TextChanged += new System.EventHandler(this.userNameTextBox2_TextChanged); + this.userNameTextBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox2_KeyPress); + // + // aliasLabel2 + // + resources.ApplyResources(this.aliasLabel2, "aliasLabel2"); + this.aliasLabel2.Name = "aliasLabel2"; + this.aliasLabel2.Click += new System.EventHandler(this.aliasLabel2_Click); + // + // passwordLabel2 + // + resources.ApplyResources(this.passwordLabel2, "passwordLabel2"); + this.passwordLabel2.Name = "passwordLabel2"; + // + // passwordTextBox2 + // + resources.ApplyResources(this.passwordTextBox2, "passwordTextBox2"); + this.passwordTextBox2.Name = "passwordTextBox2"; + this.passwordTextBox2.UseSystemPasswordChar = true; + this.passwordTextBox2.TextChanged += new System.EventHandler(this.passwordTextBox2_TextChanged); + this.passwordTextBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox2_KeyPress); + // + // DoubleLoginDlg + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.LightGray; + this.CancelButton = this.cancelButton; + this.Controls.Add(this.workplaceGroupBox2); + this.Controls.Add(this.workplaceGroupBox1); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "DoubleLoginDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LoginDlg_FormClosing); + this.Load += new System.EventHandler(this.LoginDlg_Load); + this.workplaceGroupBox1.ResumeLayout(false); + this.workplaceGroupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox1)).EndInit(); + this.workplaceGroupBox2.ResumeLayout(false); + this.workplaceGroupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox2)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label aliasLabel1; + private System.Windows.Forms.Label passwordLabel1; + private System.Windows.Forms.TextBox userNameTextBox1; + private System.Windows.Forms.TextBox passwordTextBox1; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.GroupBox workplaceGroupBox1; + private System.Windows.Forms.PictureBox loginStatePictureBox1; + private System.Windows.Forms.GroupBox workplaceGroupBox2; + private System.Windows.Forms.PictureBox loginStatePictureBox2; + private System.Windows.Forms.TextBox userNameTextBox2; + private System.Windows.Forms.Label aliasLabel2; + private System.Windows.Forms.Label passwordLabel2; + private System.Windows.Forms.TextBox passwordTextBox2; + } +} \ No newline at end of file diff --git a/SharedDatabase/Forms/DoubleLoginDlg.cs b/SharedDatabase/Forms/DoubleLoginDlg.cs new file mode 100644 index 000000000..907ef3793 --- /dev/null +++ b/SharedDatabase/Forms/DoubleLoginDlg.cs @@ -0,0 +1,525 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Drawing; +using System.Windows.Forms; +using Common; +using GemCard; +using SharedDatabase.Entities; +using SharedDatabase.Resources; + +namespace SharedDatabase.Forms +{ + /// + /// Provides login dialog as well as user authorization using TBF.User.Authorize(...) + /// (i.e. when DialogResult is OK, user was authorized). + /// + public partial class DoubleLoginDlg : Form + { + // Private fields + string predefinedUser; + GID[] requiredGroupMembership; + bool noDatabase; + Color oriBackColor; + + /// Smart card support, card S/N is used as user.Tag + GemCard.CardNative card; + string[] cardReaders; + string smartCardReader; + + User authorizedUser1; /// Authorized user 1 or null + User authorizedUser2; /// Authorized user 2 or null + + public LoginMethod Method1; + public LoginMethod Method2; + + public string VersionString; + + /// + /// Constructor. + /// + public DoubleLoginDlg() + { + InitializeComponent(); + + loginStatePictureBox1.Image = Properties.Resources.questionMark; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + authorizedUser1 = null; + authorizedUser2 = null; + + oriBackColor = BackColor; + } + + /// + /// Constructor with a predefined user. + /// + public DoubleLoginDlg(string predefinedUser) + : this() + { + this.predefinedUser = predefinedUser; + userNameTextBox1.Text = predefinedUser; + } + + /// + /// Constructor with two owrkplace names. + /// + /// Name of workplace A + /// Name of workplace B + public DoubleLoginDlg(string workplace1, string workplace2) + : this() + { + workplaceGroupBox1.Text = workplace1; + workplaceGroupBox2.Text = workplace2; + } + + /// + /// Constructor with 'no Database' flag. + /// + public DoubleLoginDlg(bool noDatabase) + : this() + { + this.noDatabase = noDatabase; + } + + /// + /// Constructor when a specific group membership is required. + /// + public DoubleLoginDlg(GID[] requiredGroupMembership) + : this() + { + this.requiredGroupMembership = requiredGroupMembership; + } + + /// + /// Constructor with a predefined user when a specific group membership is required. + /// + public DoubleLoginDlg(string predefinedUser, GID[] requiredGroupMembership) + : this() + { + this.predefinedUser = predefinedUser; + userNameTextBox1.Text = predefinedUser; + this.requiredGroupMembership = requiredGroupMembership; + } + + private void LoginDlg_Load(object sender, EventArgs e) + { + Localize(); + + if (predefinedUser == null) + { + userNameTextBox1.Select(); + } + else + { + passwordTextBox1.Select(); + } + + /// + /// Smart card reader detection + /// + smartCardReader = null; /// null = No smart card reader detected + try + { + card = new CardNative(); + + /// Find NFC smart card reader + cardReaders = card.ListReaders(); + foreach (var crd in cardReaders) + { + if (crd.Contains("NFC")) + { + smartCardReader = crd; /// NFC smart card reader detected + break; + } + } + + if (!string.IsNullOrEmpty(smartCardReader)) + { + /// Reader found, initialize NFC smart card reader + + card.OnCardInserted += delegate(object sndr, CardInsertedEventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnCardInserted), sndr, args); } + else OnCardInserted(sndr, args); + }; + + card.OnCardRemoved += delegate(object sndr, CardRemovedEventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnCardRemoved), sndr, args); } + else OnCardRemoved(sndr, args); + }; + + card.StartCardEvents(smartCardReader); + + Text += " (NFC)"; + } + } + catch (Exception) + { + smartCardReader = null; + } + } + + void Localize() + { + Text = Strings.User_Login + (string.IsNullOrEmpty(VersionString) ? "" : (" " + VersionString)); + aliasLabel1.Text = GetAliasLabel(Method1); + aliasLabel2.Text = GetAliasLabel(Method2); + passwordLabel1.Text = Strings.Password; + passwordLabel2.Text = Strings.Password; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + } + + string GetAliasLabel(LoginMethod method) + { + switch (method) + { + default: + case LoginMethod.UserName: return Strings.User_name; + case LoginMethod.FullName: return Strings.Full_name; + case LoginMethod.Number: return Strings.User_code; + } + } + + /// + /// Try to authorize the user when OK clicked. + /// + private void okButton_Click(object sender, EventArgs e) + { + User tempUser; + + if (authorizedUser1 == null) + { + if (string.IsNullOrEmpty(userNameTextBox1.Text) || string.IsNullOrEmpty(passwordTextBox1.Text)) + { + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1)) != null) + { + authorizedUser1 = tempUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + } + else + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + } + + if (authorizedUser2 == null) + { + if (string.IsNullOrEmpty(userNameTextBox2.Text) || string.IsNullOrEmpty(passwordTextBox2.Text)) + { + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2)) != null) + { + authorizedUser2 = tempUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + } + else + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); + DialogResult = DialogResult.None; + return; + } + + + User TryAuthorize(string user, string password, LoginMethod method) + { + if (Common.Utils.IsPowerUser(user, password)) + { + return new User(user, 6, true); + } + + User loadedUser = null; + bool authorized = false; + if (!noDatabase) + { + DBSettings db = GlobalData.LocalUsersDB; + + loadedUser = User.LoadUserByName(user, db); + if (loadedUser != null) + { + switch (method) + { + default: + case LoginMethod.UserName: + authorized = loadedUser.Authorize(user, password, requiredGroupMembership); + break; + case LoginMethod.FullName: + authorized = loadedUser.AuthorizeFullName(user, password, requiredGroupMembership); + break; + case LoginMethod.Number: + int number; + if (!int.TryParse(user, out number)) break; + authorized = loadedUser.AuthorizeNumber(number, password, requiredGroupMembership); + break; + } + } + } + + return authorized ? loadedUser : null; + } + + + /// + /// Cancel clicked, do not try to authorize. + /// + private void cancelButton_Click(object sender, EventArgs e) + { + if (requiredGroupMembership == null) + { + Entities.User.Unauthorize(); + } + + DialogResult = DialogResult.Cancel; + Close(); + return; + } + + private void aliasLabel1_Click(object sender, EventArgs e) + { + if (++Method1 == LoginMethod.Count) Method1 = 0; + aliasLabel1.Text = GetAliasLabel(Method1); + } + + private void aliasLabel2_Click(object sender, EventArgs e) + { + if (++Method2 == LoginMethod.Count) Method2 = 0; + aliasLabel2.Text = GetAliasLabel(Method2); + } + + void OnCardInserted(object sender, CardInsertedEventArgs args) + { + BackColor = Color.Green; + card.Connect(smartCardReader, SHARE.Shared, PROTOCOL.T0orT1); + + /// Read the serial number of the card + APDUResponse response = card.Transmit(new APDUCommand(0xFF, 0xCA, 0x00, 0x00, null, 7)); + string tag = response.ToString(); + + card.Disconnect(DISCONNECT.Leave); + + + bool authorized = false; + DBSettings db = GlobalData.LocalUsersDB; + IUser oriUser = GlobalData.CurrentUser; + + User loadedUser = User.LoadUserByTag(tag, db); + if (loadedUser != null) + { + authorized = loadedUser.AuthorizeTag(tag, requiredGroupMembership); + } + + + if (ActiveControl == userNameTextBox1 || ActiveControl == passwordTextBox1) + { + if (authorized) + { + userNameTextBox1.Text = loadedUser.UserName; + passwordTextBox1.Text = string.Empty; + authorizedUser1 = loadedUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + userNameTextBox2.Focus(); + } + else + { + userNameTextBox1.Text = string.Empty; + passwordTextBox1.Text = string.Empty; + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + } + else if (ActiveControl == userNameTextBox2 || ActiveControl == passwordTextBox2) + { + if (authorized) + { + userNameTextBox2.Text = loadedUser.UserName; + passwordTextBox2.Text = string.Empty; + authorizedUser2 = loadedUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + userNameTextBox1.Focus(); + } + else + { + userNameTextBox2.Text = string.Empty; + passwordTextBox2.Text = string.Empty; + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + } + + if (authorizedUser1 == null && !string.IsNullOrEmpty(userNameTextBox1.Text) && !string.IsNullOrEmpty(passwordTextBox1.Text)) + { + authorizedUser1 = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1); + loginStatePictureBox1.Image = (authorizedUser1 != null) ? Properties.Resources.accepted : Properties.Resources.rejected; + } + + if (authorizedUser2 == null && !string.IsNullOrEmpty(userNameTextBox2.Text) && !string.IsNullOrEmpty(passwordTextBox2.Text)) + { + authorizedUser2 = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2); + loginStatePictureBox2.Image = (authorizedUser2 != null) ? Properties.Resources.accepted : Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + //MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); + DialogResult = DialogResult.None; + return; + } + + + void OnCardRemoved(object sender, CardRemovedEventArgs args) + { + BackColor = oriBackColor; + } + + private void LoginDlg_FormClosing(object sender, FormClosingEventArgs e) + { + if (!string.IsNullOrEmpty(smartCardReader)) + { + card.StopCardEvents(); + } + } + + /// + /// 1st user / password TextBox processing + /// + private void userNameTextBox1_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox1.Focus(); + } + } + private void passwordTextBox1_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + User tempUser; + if (string.IsNullOrEmpty(userNameTextBox1.Text) || string.IsNullOrEmpty(passwordTextBox1.Text)) + { + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1)) != null) + { + authorizedUser1 = tempUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + } + else + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + userNameTextBox2.Focus(); + } + } + private void userNameTextBox1_TextChanged(object sender, EventArgs e) + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + private void passwordTextBox1_TextChanged(object sender, EventArgs e) + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + + + /// + /// 2nd user / password TextBox processing + /// + private void userNameTextBox2_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox2.Focus(); + } + } + private void passwordTextBox2_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + User tempUser; + if (string.IsNullOrEmpty(userNameTextBox2.Text) || string.IsNullOrEmpty(passwordTextBox2.Text)) + { + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2)) != null) + { + authorizedUser2 = tempUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + } + else + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + userNameTextBox1.Focus(); + } + } + private void userNameTextBox2_TextChanged(object sender, EventArgs e) + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + private void passwordTextBox2_TextChanged(object sender, EventArgs e) + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + + + /// + /// Returns true when both users are already logged in + /// + bool AreAllUsersKnown() + { + return (authorizedUser1 != null) && (authorizedUser2 != null); + } + + /// + /// Actions before closing this dialog on successful login of all users + /// + void PrepareClosingDlg() + { + GlobalData.CurrentUser = authorizedUser1; + GlobalData.CurrentUser2 = authorizedUser2; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/SharedDatabase/Forms/DoubleLoginDlg.resx b/SharedDatabase/Forms/DoubleLoginDlg.resx new file mode 100644 index 000000000..f6c8935df --- /dev/null +++ b/SharedDatabase/Forms/DoubleLoginDlg.resx @@ -0,0 +1,495 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 28, 26 + + + 58, 13 + + + 0 + + + User name + + + aliasLabel1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 2 + + + True + + + 28, 53 + + + 53, 13 + + + 1 + + + Password + + + passwordLabel1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 3 + + + 115, 50 + + + 168, 20 + + + 3 + + + passwordTextBox1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 4 + + + + Top, Right + + + 405, 62 + + + 105, 37 + + + 5 + + + Cancel + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + Top, Right + + + 405, 16 + + + 105, 37 + + + 4 + + + OK + + + okButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 115, 24 + + + 168, 20 + + + 2 + + + userNameTextBox1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 1 + + + Top, Right + + + 308, 26 + + + 40, 40 + + + 4 + + + loginStatePictureBox1 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 0 + + + 12, 12 + + + 370, 86 + + + 6 + + + Work place A + + + workplaceGroupBox1 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Top, Right + + + NoControl + + + 308, 26 + + + 40, 40 + + + 4 + + + loginStatePictureBox2 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 0 + + + 115, 24 + + + 168, 20 + + + 2 + + + userNameTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 1 + + + True + + + NoControl + + + 28, 26 + + + 58, 13 + + + 0 + + + User name + + + aliasLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 2 + + + True + + + NoControl + + + 28, 53 + + + 53, 13 + + + 1 + + + Password + + + passwordLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 3 + + + 115, 50 + + + 168, 20 + + + 3 + + + passwordTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 4 + + + 12, 106 + + + 370, 86 + + + 7 + + + Work place B + + + workplaceGroupBox2 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 525, 204 + + + CenterScreen + + + User login + + + DoubleLoginDlg + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SharedDatabase/Forms/TripleLoginDlg.Designer.cs b/SharedDatabase/Forms/TripleLoginDlg.Designer.cs new file mode 100644 index 000000000..3928e9455 --- /dev/null +++ b/SharedDatabase/Forms/TripleLoginDlg.Designer.cs @@ -0,0 +1,260 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +namespace SharedDatabase.Forms +{ + partial class TripleLoginDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TripleLoginDlg)); + this.aliasLabel1 = new System.Windows.Forms.Label(); + this.passwordLabel1 = new System.Windows.Forms.Label(); + this.passwordTextBox1 = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.userNameTextBox1 = new System.Windows.Forms.TextBox(); + this.workplaceGroupBox1 = new System.Windows.Forms.GroupBox(); + this.loginStatePictureBox1 = new System.Windows.Forms.PictureBox(); + this.workplaceGroupBox2 = new System.Windows.Forms.GroupBox(); + this.loginStatePictureBox2 = new System.Windows.Forms.PictureBox(); + this.userNameTextBox2 = new System.Windows.Forms.TextBox(); + this.aliasLabel2 = new System.Windows.Forms.Label(); + this.passwordLabel2 = new System.Windows.Forms.Label(); + this.passwordTextBox2 = new System.Windows.Forms.TextBox(); + this.workplaceGroupBox3 = new System.Windows.Forms.GroupBox(); + this.loginStatePictureBox3 = new System.Windows.Forms.PictureBox(); + this.userNameTextBox3 = new System.Windows.Forms.TextBox(); + this.aliasLabel3 = new System.Windows.Forms.Label(); + this.passwordLabel3 = new System.Windows.Forms.Label(); + this.passwordTextBox3 = new System.Windows.Forms.TextBox(); + this.workplaceGroupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox1)).BeginInit(); + this.workplaceGroupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox2)).BeginInit(); + this.workplaceGroupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox3)).BeginInit(); + this.SuspendLayout(); + // + // aliasLabel1 + // + resources.ApplyResources(this.aliasLabel1, "aliasLabel1"); + this.aliasLabel1.Name = "aliasLabel1"; + this.aliasLabel1.Click += new System.EventHandler(this.aliasLabel1_Click); + // + // passwordLabel1 + // + resources.ApplyResources(this.passwordLabel1, "passwordLabel1"); + this.passwordLabel1.Name = "passwordLabel1"; + // + // passwordTextBox1 + // + resources.ApplyResources(this.passwordTextBox1, "passwordTextBox1"); + this.passwordTextBox1.Name = "passwordTextBox1"; + this.passwordTextBox1.UseSystemPasswordChar = true; + this.passwordTextBox1.TextChanged += new System.EventHandler(this.passwordTextBox1_TextChanged); + this.passwordTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox1_KeyPress); + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // userNameTextBox1 + // + resources.ApplyResources(this.userNameTextBox1, "userNameTextBox1"); + this.userNameTextBox1.Name = "userNameTextBox1"; + this.userNameTextBox1.TextChanged += new System.EventHandler(this.userNameTextBox1_TextChanged); + this.userNameTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox1_KeyPress); + // + // workplaceGroupBox1 + // + this.workplaceGroupBox1.Controls.Add(this.loginStatePictureBox1); + this.workplaceGroupBox1.Controls.Add(this.userNameTextBox1); + this.workplaceGroupBox1.Controls.Add(this.aliasLabel1); + this.workplaceGroupBox1.Controls.Add(this.passwordLabel1); + this.workplaceGroupBox1.Controls.Add(this.passwordTextBox1); + resources.ApplyResources(this.workplaceGroupBox1, "workplaceGroupBox1"); + this.workplaceGroupBox1.Name = "workplaceGroupBox1"; + this.workplaceGroupBox1.TabStop = false; + // + // loginStatePictureBox1 + // + resources.ApplyResources(this.loginStatePictureBox1, "loginStatePictureBox1"); + this.loginStatePictureBox1.Name = "loginStatePictureBox1"; + this.loginStatePictureBox1.TabStop = false; + // + // workplaceGroupBox2 + // + this.workplaceGroupBox2.Controls.Add(this.loginStatePictureBox2); + this.workplaceGroupBox2.Controls.Add(this.userNameTextBox2); + this.workplaceGroupBox2.Controls.Add(this.aliasLabel2); + this.workplaceGroupBox2.Controls.Add(this.passwordLabel2); + this.workplaceGroupBox2.Controls.Add(this.passwordTextBox2); + resources.ApplyResources(this.workplaceGroupBox2, "workplaceGroupBox2"); + this.workplaceGroupBox2.Name = "workplaceGroupBox2"; + this.workplaceGroupBox2.TabStop = false; + // + // loginStatePictureBox2 + // + resources.ApplyResources(this.loginStatePictureBox2, "loginStatePictureBox2"); + this.loginStatePictureBox2.Name = "loginStatePictureBox2"; + this.loginStatePictureBox2.TabStop = false; + // + // userNameTextBox2 + // + resources.ApplyResources(this.userNameTextBox2, "userNameTextBox2"); + this.userNameTextBox2.Name = "userNameTextBox2"; + this.userNameTextBox2.TextChanged += new System.EventHandler(this.userNameTextBox2_TextChanged); + this.userNameTextBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox2_KeyPress); + // + // aliasLabel2 + // + resources.ApplyResources(this.aliasLabel2, "aliasLabel2"); + this.aliasLabel2.Name = "aliasLabel2"; + this.aliasLabel2.Click += new System.EventHandler(this.aliasLabel2_Click); + // + // passwordLabel2 + // + resources.ApplyResources(this.passwordLabel2, "passwordLabel2"); + this.passwordLabel2.Name = "passwordLabel2"; + // + // passwordTextBox2 + // + resources.ApplyResources(this.passwordTextBox2, "passwordTextBox2"); + this.passwordTextBox2.Name = "passwordTextBox2"; + this.passwordTextBox2.UseSystemPasswordChar = true; + this.passwordTextBox2.TextChanged += new System.EventHandler(this.passwordTextBox2_TextChanged); + this.passwordTextBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox2_KeyPress); + // + // workplaceGroupBox3 + // + this.workplaceGroupBox3.Controls.Add(this.loginStatePictureBox3); + this.workplaceGroupBox3.Controls.Add(this.userNameTextBox3); + this.workplaceGroupBox3.Controls.Add(this.aliasLabel3); + this.workplaceGroupBox3.Controls.Add(this.passwordLabel3); + this.workplaceGroupBox3.Controls.Add(this.passwordTextBox3); + resources.ApplyResources(this.workplaceGroupBox3, "workplaceGroupBox3"); + this.workplaceGroupBox3.Name = "workplaceGroupBox3"; + this.workplaceGroupBox3.TabStop = false; + // + // loginStatePictureBox3 + // + resources.ApplyResources(this.loginStatePictureBox3, "loginStatePictureBox3"); + this.loginStatePictureBox3.Name = "loginStatePictureBox3"; + this.loginStatePictureBox3.TabStop = false; + // + // userNameTextBox3 + // + resources.ApplyResources(this.userNameTextBox3, "userNameTextBox3"); + this.userNameTextBox3.Name = "userNameTextBox3"; + this.userNameTextBox3.TextChanged += new System.EventHandler(this.userNameTextBox3_TextChanged); + this.userNameTextBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox3_KeyPress); + // + // aliasLabel3 + // + resources.ApplyResources(this.aliasLabel3, "aliasLabel3"); + this.aliasLabel3.Name = "aliasLabel3"; + this.aliasLabel3.Click += new System.EventHandler(this.aliasLabel3_Click); + // + // passwordLabel3 + // + resources.ApplyResources(this.passwordLabel3, "passwordLabel3"); + this.passwordLabel3.Name = "passwordLabel3"; + // + // passwordTextBox3 + // + resources.ApplyResources(this.passwordTextBox3, "passwordTextBox3"); + this.passwordTextBox3.Name = "passwordTextBox3"; + this.passwordTextBox3.UseSystemPasswordChar = true; + this.passwordTextBox3.TextChanged += new System.EventHandler(this.passwordTextBox3_TextChanged); + this.passwordTextBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox3_KeyPress); + // + // TripleLoginDlg + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.LightGray; + this.CancelButton = this.cancelButton; + this.Controls.Add(this.workplaceGroupBox3); + this.Controls.Add(this.workplaceGroupBox2); + this.Controls.Add(this.workplaceGroupBox1); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "TripleLoginDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LoginDlg_FormClosing); + this.Load += new System.EventHandler(this.LoginDlg_Load); + this.workplaceGroupBox1.ResumeLayout(false); + this.workplaceGroupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox1)).EndInit(); + this.workplaceGroupBox2.ResumeLayout(false); + this.workplaceGroupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox2)).EndInit(); + this.workplaceGroupBox3.ResumeLayout(false); + this.workplaceGroupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.loginStatePictureBox3)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label aliasLabel1; + private System.Windows.Forms.Label passwordLabel1; + private System.Windows.Forms.TextBox userNameTextBox1; + private System.Windows.Forms.TextBox passwordTextBox1; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.GroupBox workplaceGroupBox1; + private System.Windows.Forms.PictureBox loginStatePictureBox1; + private System.Windows.Forms.GroupBox workplaceGroupBox2; + private System.Windows.Forms.PictureBox loginStatePictureBox2; + private System.Windows.Forms.TextBox userNameTextBox2; + private System.Windows.Forms.Label aliasLabel2; + private System.Windows.Forms.Label passwordLabel2; + private System.Windows.Forms.TextBox passwordTextBox2; + private System.Windows.Forms.GroupBox workplaceGroupBox3; + private System.Windows.Forms.PictureBox loginStatePictureBox3; + private System.Windows.Forms.TextBox userNameTextBox3; + private System.Windows.Forms.Label aliasLabel3; + private System.Windows.Forms.Label passwordLabel3; + private System.Windows.Forms.TextBox passwordTextBox3; + } +} \ No newline at end of file diff --git a/SharedDatabase/Forms/TripleLoginDlg.cs b/SharedDatabase/Forms/TripleLoginDlg.cs new file mode 100644 index 000000000..1471d35fe --- /dev/null +++ b/SharedDatabase/Forms/TripleLoginDlg.cs @@ -0,0 +1,633 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Drawing; +using System.Windows.Forms; +using Common; +using GemCard; +using SharedDatabase.Entities; +using SharedDatabase.Resources; + +namespace SharedDatabase.Forms +{ + /// + /// Provides login dialog as well as user authorization using TBF.User.Authorize(...) + /// (i.e. when DialogResult is OK, user was authorized). + /// + public partial class TripleLoginDlg : Form + { + // Private fields + string predefinedUser; + GID[] requiredGroupMembership; + bool noDatabase; + Color oriBackColor; + + /// Smart card support, card S/N is used as user.Tag + GemCard.CardNative card; + string[] cardReaders; + string smartCardReader; + + User authorizedUser1; /// Authorized user 1 or null + User authorizedUser2; /// Authorized user 2 or null + User authorizedUser3; /// Authorized user 3 or null + + public LoginMethod Method1; + public LoginMethod Method2; + public LoginMethod Method3; + + public string VersionString; + + /// + /// Constructor. + /// + public TripleLoginDlg() + { + InitializeComponent(); + + loginStatePictureBox1.Image = Properties.Resources.questionMark; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + loginStatePictureBox3.Image = Properties.Resources.questionMark; + authorizedUser1 = null; + authorizedUser2 = null; + authorizedUser3 = null; + + oriBackColor = BackColor; + } + + /// + /// Constructor with a predefined user. + /// + public TripleLoginDlg(string predefinedUser) + : this() + { + this.predefinedUser = predefinedUser; + userNameTextBox1.Text = predefinedUser; + } + + /// + /// Constructor with two owrkplace names. + /// + /// Name of workplace A + /// Name of workplace B + public TripleLoginDlg(string workplace1, string workplace2, string workplace3) + : this() + { + workplaceGroupBox1.Text = workplace1; + workplaceGroupBox2.Text = workplace2; + workplaceGroupBox3.Text = workplace3; + } + + /// + /// Constructor with 'no Database' flag. + /// + public TripleLoginDlg(bool noDatabase) + : this() + { + this.noDatabase = noDatabase; + } + + /// + /// Constructor when a specific group membership is required. + /// + public TripleLoginDlg(GID[] requiredGroupMembership) + : this() + { + this.requiredGroupMembership = requiredGroupMembership; + } + + /// + /// Constructor with a predefined user when a specific group membership is required. + /// + public TripleLoginDlg(string predefinedUser, GID[] requiredGroupMembership) + : this() + { + this.predefinedUser = predefinedUser; + userNameTextBox1.Text = predefinedUser; + this.requiredGroupMembership = requiredGroupMembership; + } + + private void LoginDlg_Load(object sender, EventArgs e) + { + Localize(); + + if (predefinedUser == null) + { + userNameTextBox1.Select(); + } + else + { + passwordTextBox1.Select(); + } + + /// + /// Smart card reader detection + /// + smartCardReader = null; /// null = No smart card reader detected + try + { + card = new CardNative(); + + /// Find NFC smart card reader + cardReaders = card.ListReaders(); + foreach (var crd in cardReaders) + { + if (crd.Contains("NFC")) + { + smartCardReader = crd; /// NFC smart card reader detected + break; + } + } + + if (!string.IsNullOrEmpty(smartCardReader)) + { + /// Reader found, initialize NFC smart card reader + + card.OnCardInserted += delegate(object sndr, CardInsertedEventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnCardInserted), sndr, args); } + else OnCardInserted(sndr, args); + }; + + card.OnCardRemoved += delegate(object sndr, CardRemovedEventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnCardRemoved), sndr, args); } + else OnCardRemoved(sndr, args); + }; + + card.StartCardEvents(smartCardReader); + + Text += " (NFC)"; + } + } + catch (Exception) + { + smartCardReader = null; + } + } + + void Localize() + { + Text = Strings.User_Login + (string.IsNullOrEmpty(VersionString) ? "" : (" " + VersionString)); + aliasLabel1.Text = GetAliasLabel(Method1); + aliasLabel2.Text = GetAliasLabel(Method2); + aliasLabel3.Text = GetAliasLabel(Method3); + passwordLabel1.Text = Strings.Password; + passwordLabel2.Text = Strings.Password; + passwordLabel3.Text = Strings.Password; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + } + + string GetAliasLabel(LoginMethod method) + { + switch (method) + { + default: + case LoginMethod.UserName: return Strings.User_name; + case LoginMethod.FullName: return Strings.Full_name; + case LoginMethod.Number: return Strings.User_code; + } + } + + /// + /// Try to authorize the user when OK clicked. + /// + private void okButton_Click(object sender, EventArgs e) + { + User tempUser; + + if (authorizedUser1 == null) + { + if (string.IsNullOrEmpty(userNameTextBox1.Text) || string.IsNullOrEmpty(passwordTextBox1.Text)) + { + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1)) != null) + { + authorizedUser1 = tempUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + } + else + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + } + + if (authorizedUser2 == null) + { + if (string.IsNullOrEmpty(userNameTextBox2.Text) || string.IsNullOrEmpty(passwordTextBox2.Text)) + { + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2)) != null) + { + authorizedUser2 = tempUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + } + else + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + } + + if (authorizedUser3 == null) + { + if (string.IsNullOrEmpty(userNameTextBox3.Text) || string.IsNullOrEmpty(passwordTextBox3.Text)) + { + loginStatePictureBox3.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox3.Text, passwordTextBox3.Text, Method3)) != null) + { + authorizedUser3 = tempUser; + loginStatePictureBox3.Image = Properties.Resources.accepted; + } + else + { + authorizedUser3 = null; + loginStatePictureBox3.Image = Properties.Resources.rejected; + } + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); + DialogResult = DialogResult.None; + return; + } + + + User TryAuthorize(string user, string password, LoginMethod method) + { + if (Common.Utils.IsPowerUser(user, password)) + { + return new User(user, 6, true); + } + + User loadedUser = null; + bool authorized = false; + if (!noDatabase) + { + DBSettings db = GlobalData.LocalUsersDB; + + loadedUser = User.LoadUserByName(user, db); + if (loadedUser != null) + { + switch (method) + { + default: + case LoginMethod.UserName: + authorized = loadedUser.Authorize(user, password, requiredGroupMembership); + break; + case LoginMethod.FullName: + authorized = loadedUser.AuthorizeFullName(user, password, requiredGroupMembership); + break; + case LoginMethod.Number: + int number; + if (!int.TryParse(user, out number)) break; + authorized = loadedUser.AuthorizeNumber(number, password, requiredGroupMembership); + break; + } + } + } + + return authorized ? loadedUser : null; + } + + + /// + /// Cancel clicked, do not try to authorize. + /// + private void cancelButton_Click(object sender, EventArgs e) + { + if (requiredGroupMembership == null) + { + Entities.User.Unauthorize(); + } + + DialogResult = DialogResult.Cancel; + Close(); + return; + } + + private void aliasLabel1_Click(object sender, EventArgs e) + { + if (++Method1 == LoginMethod.Count) Method1 = 0; + aliasLabel1.Text = GetAliasLabel(Method1); + } + + private void aliasLabel2_Click(object sender, EventArgs e) + { + if (++Method2 == LoginMethod.Count) Method2 = 0; + aliasLabel2.Text = GetAliasLabel(Method2); + } + + private void aliasLabel3_Click(object sender, EventArgs e) + { + if (++Method3 == LoginMethod.Count) Method3 = 0; + aliasLabel3.Text = GetAliasLabel(Method3); + } + + void OnCardInserted(object sender, CardInsertedEventArgs args) + { + BackColor = Color.Green; + card.Connect(smartCardReader, SHARE.Shared, PROTOCOL.T0orT1); + + /// Read the serial number of the card + APDUResponse response = card.Transmit(new APDUCommand(0xFF, 0xCA, 0x00, 0x00, null, 7)); + string tag = response.ToString(); + + card.Disconnect(DISCONNECT.Leave); + + + bool authorized = false; + DBSettings db = GlobalData.LocalUsersDB; + IUser oriUser = GlobalData.CurrentUser; + + User loadedUser = User.LoadUserByTag(tag, db); + if (loadedUser != null) + { + authorized = loadedUser.AuthorizeTag(tag, requiredGroupMembership); + } + + + if (ActiveControl == userNameTextBox1 || ActiveControl == passwordTextBox1) + { + if (authorized) + { + userNameTextBox1.Text = loadedUser.UserName; + passwordTextBox1.Text = string.Empty; + authorizedUser1 = loadedUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + userNameTextBox2.Focus(); + } + else + { + userNameTextBox1.Text = string.Empty; + passwordTextBox1.Text = string.Empty; + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + } + else if (ActiveControl == userNameTextBox2 || ActiveControl == passwordTextBox2) + { + if (authorized) + { + userNameTextBox2.Text = loadedUser.UserName; + passwordTextBox2.Text = string.Empty; + authorizedUser2 = loadedUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + userNameTextBox3.Focus(); + } + else + { + userNameTextBox2.Text = string.Empty; + passwordTextBox2.Text = string.Empty; + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + } + else if (ActiveControl == userNameTextBox3 || ActiveControl == passwordTextBox3) + { + if (authorized) + { + userNameTextBox3.Text = loadedUser.UserName; + passwordTextBox3.Text = string.Empty; + authorizedUser3 = loadedUser; + loginStatePictureBox3.Image = Properties.Resources.accepted; + userNameTextBox1.Focus(); + } + else + { + userNameTextBox3.Text = string.Empty; + passwordTextBox3.Text = string.Empty; + authorizedUser3 = null; + loginStatePictureBox3.Image = Properties.Resources.rejected; + } + } + + if (authorizedUser1 == null && !string.IsNullOrEmpty(userNameTextBox1.Text) && !string.IsNullOrEmpty(passwordTextBox1.Text)) + { + authorizedUser1 = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1); + loginStatePictureBox1.Image = (authorizedUser1 != null) ? Properties.Resources.accepted : Properties.Resources.rejected; + } + + if (authorizedUser2 == null && !string.IsNullOrEmpty(userNameTextBox2.Text) && !string.IsNullOrEmpty(passwordTextBox2.Text)) + { + authorizedUser2 = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2); + loginStatePictureBox2.Image = (authorizedUser2 != null) ? Properties.Resources.accepted : Properties.Resources.rejected; + } + + if (authorizedUser3 == null && !string.IsNullOrEmpty(userNameTextBox3.Text) && !string.IsNullOrEmpty(passwordTextBox3.Text)) + { + authorizedUser3 = TryAuthorize(userNameTextBox3.Text, passwordTextBox3.Text, Method3); + loginStatePictureBox3.Image = (authorizedUser3 != null) ? Properties.Resources.accepted : Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + //MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); + DialogResult = DialogResult.None; + return; + } + + + void OnCardRemoved(object sender, CardRemovedEventArgs args) + { + BackColor = oriBackColor; + } + + private void LoginDlg_FormClosing(object sender, FormClosingEventArgs e) + { + if (!string.IsNullOrEmpty(smartCardReader)) + { + card.StopCardEvents(); + } + } + + /// + /// 1st user / password TextBox processing + /// + private void userNameTextBox1_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox1.Focus(); + } + } + private void passwordTextBox1_KeyPress(object sender, KeyPressEventArgs e) + + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + User tempUser; + if (string.IsNullOrEmpty(userNameTextBox1.Text) || string.IsNullOrEmpty(passwordTextBox1.Text)) + { + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox1.Text, passwordTextBox1.Text, Method1)) != null) + { + authorizedUser1 = tempUser; + loginStatePictureBox1.Image = Properties.Resources.accepted; + } + else + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + userNameTextBox2.Focus(); + } + } + private void userNameTextBox1_TextChanged(object sender, EventArgs e) + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + private void passwordTextBox1_TextChanged(object sender, EventArgs e) + { + authorizedUser1 = null; + loginStatePictureBox1.Image = Properties.Resources.questionMark; + } + + + /// + /// 2nd user / password TextBox processing + /// + private void userNameTextBox2_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox2.Focus(); + } + } + private void passwordTextBox2_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + User tempUser; + if (string.IsNullOrEmpty(userNameTextBox2.Text) || string.IsNullOrEmpty(passwordTextBox2.Text)) + { + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox2.Text, passwordTextBox2.Text, Method2)) != null) + { + authorizedUser2 = tempUser; + loginStatePictureBox2.Image = Properties.Resources.accepted; + } + else + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + userNameTextBox3.Focus(); + } + } + private void userNameTextBox2_TextChanged(object sender, EventArgs e) + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + private void passwordTextBox2_TextChanged(object sender, EventArgs e) + { + authorizedUser2 = null; + loginStatePictureBox2.Image = Properties.Resources.questionMark; + } + + + /// + /// 3rd user / password TextBox processing + /// + private void userNameTextBox3_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + passwordTextBox3.Focus(); + } + } + private void passwordTextBox3_KeyPress(object sender, KeyPressEventArgs e) + { + if (Convert.ToInt32(e.KeyChar) == 13) + { + User tempUser; + if (string.IsNullOrEmpty(userNameTextBox3.Text) || string.IsNullOrEmpty(passwordTextBox3.Text)) + { + loginStatePictureBox3.Image = Properties.Resources.questionMark; + } + else if ((tempUser = TryAuthorize(userNameTextBox3.Text, passwordTextBox3.Text, Method3)) != null) + { + authorizedUser3 = tempUser; + loginStatePictureBox3.Image = Properties.Resources.accepted; + } + else + { + authorizedUser3 = null; + loginStatePictureBox3.Image = Properties.Resources.rejected; + } + + if (AreAllUsersKnown()) + { + PrepareClosingDlg(); + return; + } + + userNameTextBox1.Focus(); + } + } + private void userNameTextBox3_TextChanged(object sender, EventArgs e) + { + authorizedUser3 = null; + loginStatePictureBox3.Image = Properties.Resources.questionMark; + } + private void passwordTextBox3_TextChanged(object sender, EventArgs e) + { + authorizedUser3 = null; + loginStatePictureBox3.Image = Properties.Resources.questionMark; + } + + + /// + /// Returns true when all 3 users are already logged in + /// + bool AreAllUsersKnown() + { + return (authorizedUser1 != null) && (authorizedUser2 != null) && (authorizedUser3 != null); + } + + /// + /// Actions before closing this dialog on successful login of all users + /// + void PrepareClosingDlg() + { + GlobalData.CurrentUser = authorizedUser1; + GlobalData.CurrentUser2 = authorizedUser2; + GlobalData.CurrentUser3 = authorizedUser3; + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/SharedDatabase/Forms/TripleLoginDlg.resx b/SharedDatabase/Forms/TripleLoginDlg.resx new file mode 100644 index 000000000..d52a0932e --- /dev/null +++ b/SharedDatabase/Forms/TripleLoginDlg.resx @@ -0,0 +1,720 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 28, 26 + + + 58, 13 + + + 0 + + + User name + + + aliasLabel1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 2 + + + True + + + 28, 53 + + + 53, 13 + + + 1 + + + Password + + + passwordLabel1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 3 + + + 115, 50 + + + 168, 20 + + + 3 + + + passwordTextBox1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 4 + + + + Top, Right + + + 405, 62 + + + 105, 37 + + + 5 + + + Cancel + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + Top, Right + + + 405, 16 + + + 105, 37 + + + 4 + + + OK + + + okButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 115, 24 + + + 168, 20 + + + 2 + + + userNameTextBox1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 1 + + + loginStatePictureBox1 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 0 + + + 12, 12 + + + 370, 86 + + + 6 + + + Work place A + + + workplaceGroupBox1 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + Top, Right + + + 308, 26 + + + 40, 40 + + + 4 + + + loginStatePictureBox1 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox1 + + + 0 + + + loginStatePictureBox2 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 0 + + + userNameTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 1 + + + aliasLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 2 + + + passwordLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 3 + + + passwordTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 4 + + + 12, 106 + + + 370, 86 + + + 7 + + + Work place B + + + workplaceGroupBox2 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Top, Right + + + NoControl + + + 308, 26 + + + 40, 40 + + + 4 + + + loginStatePictureBox2 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 0 + + + 115, 24 + + + 168, 20 + + + 2 + + + userNameTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 1 + + + True + + + NoControl + + + 28, 26 + + + 58, 13 + + + 0 + + + User name + + + aliasLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 2 + + + True + + + NoControl + + + 28, 53 + + + 53, 13 + + + 1 + + + Password + + + passwordLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 3 + + + 115, 50 + + + 168, 20 + + + 3 + + + passwordTextBox2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox2 + + + 4 + + + Top, Right + + + NoControl + + + 308, 26 + + + 40, 40 + + + 4 + + + loginStatePictureBox3 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox3 + + + 0 + + + 115, 24 + + + 168, 20 + + + 2 + + + userNameTextBox3 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox3 + + + 1 + + + True + + + NoControl + + + 28, 26 + + + 58, 13 + + + 0 + + + User name + + + aliasLabel3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox3 + + + 2 + + + True + + + NoControl + + + 28, 53 + + + 53, 13 + + + 1 + + + Password + + + passwordLabel3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox3 + + + 3 + + + 115, 50 + + + 168, 20 + + + 3 + + + passwordTextBox3 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + workplaceGroupBox3 + + + 4 + + + 12, 198 + + + 370, 86 + + + 8 + + + Work place C + + + workplaceGroupBox3 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 525, 298 + + + CenterScreen + + + User login + + + TripleLoginDlg + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SharedDatabase/Pictures/accepted.bmp b/SharedDatabase/Pictures/accepted.bmp new file mode 100644 index 000000000..e02ac90d8 Binary files /dev/null and b/SharedDatabase/Pictures/accepted.bmp differ diff --git a/SharedDatabase/Pictures/questionMark.bmp b/SharedDatabase/Pictures/questionMark.bmp new file mode 100644 index 000000000..dcd01880e Binary files /dev/null and b/SharedDatabase/Pictures/questionMark.bmp differ diff --git a/SharedDatabase/Pictures/rejected.bmp b/SharedDatabase/Pictures/rejected.bmp new file mode 100644 index 000000000..814ca5c09 Binary files /dev/null and b/SharedDatabase/Pictures/rejected.bmp differ diff --git a/SharedDatabase/Properties/Resources.Designer.cs b/SharedDatabase/Properties/Resources.Designer.cs new file mode 100644 index 000000000..0ce8a1242 --- /dev/null +++ b/SharedDatabase/Properties/Resources.Designer.cs @@ -0,0 +1,93 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SharedDatabase.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharedDatabase.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap accepted { + get { + object obj = ResourceManager.GetObject("accepted", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap questionMark { + get { + object obj = ResourceManager.GetObject("questionMark", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap rejected { + get { + object obj = ResourceManager.GetObject("rejected", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/SharedDatabase/Properties/Resources.resx b/SharedDatabase/Properties/Resources.resx new file mode 100644 index 000000000..b56df7c17 --- /dev/null +++ b/SharedDatabase/Properties/Resources.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Pictures\accepted.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Pictures\questionMark.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Pictures\rejected.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/SharedDatabase/SharedDatabase.csproj b/SharedDatabase/SharedDatabase.csproj index 589e0a963..b60c83ac7 100644 --- a/SharedDatabase/SharedDatabase.csproj +++ b/SharedDatabase/SharedDatabase.csproj @@ -78,6 +78,12 @@ + + Form + + + DoubleLoginDlg.cs + Form @@ -96,6 +102,12 @@ PasswordChangeDlg.cs + + Form + + + TripleLoginDlg.cs + Form @@ -130,6 +142,11 @@ + + True + True + Resources.resx + True True @@ -157,8 +174,10 @@ GemCard - + + DoubleLoginDlg.cs + EditSelectedUser.cs @@ -168,9 +187,17 @@ PasswordChangeDlg.cs + + TripleLoginDlg.cs + UserManagementDlg.cs + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + @@ -179,6 +206,11 @@ + + + + +