using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using OakLeaf.MM.Main; using OakLeaf.MM.Main.Business; using OakLeaf.MM.Main.Windows.Forms; using Apps4u.WinApp.Security; namespace Apps4u.WinApp.Forms.Misc { /// <summary> /// Summary description for UserLoginForm. /// </summary> public class a4uUserLoginForm : mmUserLoginForm { protected Apps4u.WinApp.Controls.Box_Items.a4uTextBox txtCompanyID; protected Apps4u.WinApp.Controls.Misc.a4uLabel lblCompanyID; public a4uUserLoginForm() { InitializeComponent(); } //protected override void AuthenticateUser() //{ //} #region FormElements private void InitializeComponent() { this.lblCompanyID = new Apps4u.WinApp.Controls.Misc.a4uLabel(); this.txtCompanyID = new Apps4u.WinApp.Controls.Box_Items.a4uTextBox(); this.grpLogin.SuspendLayout(); // // txtPassword // this.txtPassword.Location = new System.Drawing.Point(120, 96); this.txtPassword.Name = "txtPassword"; this.txtPassword.TabIndex = 2; // // focusLoadControl // this.focusLoadControl.Location = new System.Drawing.Point(120, 56); this.focusLoadControl.Name = "focusLoadControl"; // // lblPassword // this.lblPassword.Location = new System.Drawing.Point(41, 98); this.lblPassword.Name = "lblPassword"; this.lblPassword.TabIndex = 5; // // lblUserID // this.lblUserID.Location = new System.Drawing.Point(41, 58); this.lblUserID.Name = "lblUserID"; this.lblUserID.TabIndex = 4; // // grpLogin // this.grpLogin.Controls.Add(this.txtCompanyID); this.grpLogin.Controls.Add(this.lblCompanyID); this.grpLogin.Location = new System.Drawing.Point(22, 16); this.grpLogin.Name = "grpLogin"; this.grpLogin.Size = new System.Drawing.Size(300, 144); this.grpLogin.Controls.SetChildIndex(this.focusLoadControl, 0); this.grpLogin.Controls.SetChildIndex(this.lblCompanyID, 0); this.grpLogin.Controls.SetChildIndex(this.lblUserID, 0); this.grpLogin.Controls.SetChildIndex(this.lblPassword, 0); this.grpLogin.Controls.SetChildIndex(this.txtPassword, 0); this.grpLogin.Controls.SetChildIndex(this.txtCompanyID, 0); // // btnCancel // this.btnCancel.Name = "btnCancel"; // // btnOK // this.btnOK.Name = "btnOK"; this.btnOK.Click += new System.EventHandler(this.btnOK_Click); // // lblCompanyID // this.lblCompanyID.BindingSource = null; this.lblCompanyID.BindingSourceMember = null; this.lblCompanyID.ControlID = new System.Guid("00000000-0000-0000-0000-000000000000"); this.lblCompanyID.Location = new System.Drawing.Point(41, 26); this.lblCompanyID.Name = "lblCompanyID"; this.lblCompanyID.Size = new System.Drawing.Size(73, 16); this.lblCompanyID.TabIndex = 3; this.lblCompanyID.Text = "Company ID :"; this.lblCompanyID.ToolTipText = null; // // txtCompanyID // this.txtCompanyID.BindingSource = null; this.txtCompanyID.BindingSourceMember = null; this.txtCompanyID.ControlID = new System.Guid("00000000-0000-0000-0000-000000000000"); this.txtCompanyID.Format = null; this.txtCompanyID.FormatInfo = null; this.txtCompanyID.Location = new System.Drawing.Point(120, 24); this.txtCompanyID.Name = "txtCompanyID"; this.txtCompanyID.NullText = "(null)"; this.txtCompanyID.Size = new System.Drawing.Size(132, 20); this.txtCompanyID.TabIndex = 0; this.txtCompanyID.ToolTipText = null; // // a4uUserLoginForm // this.AcceptButton = null; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.Color.Gray; this.CancelButton = null; this.ClientSize = new System.Drawing.Size(344, 222); this.Name = "a4uUserLoginForm"; this.grpLogin.ResumeLayout(false); } #endregion public void btnOK_Click(object sender, System.EventArgs e) { bool lResult = this.Login_Click(); if (!lResult) this.txtCompanyID.Focus(); } public bool Login_Click() { // Change the cursor to an hourglass Cursor.Current = Cursors.WaitCursor; // Authenticate the user this.Authenticated = mmAppBase.UserMgr.AuthenticateUser( this.txtCompanyID.Text.Trim(), this.txtUserID.Text.Trim(), this.txtPassword.Text.Trim() ); // Change the cursor back to its default Cursor.Current = Cursors.Default; string cFinalMessage = ""; string CR = "\r" + "\n" ; if (!this.Authenticated) { // User not authenticated. Display the reason mmBusinessRule rules = mmAppBase.UserMgr.GetBusinessRuleObject(); if (rules.BrokenRuleCount > 0) { for (int iMessage = 0; iMessage <= rules.BrokenRuleCount-1; iMessage++) { cFinalMessage += rules.GetBrokenRule(iMessage).Trim() + CR ; } if (mmAppBase.Localize) mmAppDesktop.MessageBox.Show(cFinalMessage, "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, this.CurrentLanguage); else MessageBox.Show(cFinalMessage, "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } return this.Authenticated; } } }Thanks