/// <summary> /// Session Constructor /// </summary> public Session() { // Add the delegate event handlers m_sessionLogger = new SessionLogger(MessageHandler); m_loginSuccessNotify = new LoginNotify(HandleLoginSuccessful); m_disconnectNotify = new DisconnectNotify(HandleDisconnectNotify); }
private void timer1_Tick(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; btnLogin.Enabled = false; txtUserName.Enabled = false; txtUserPass.Enabled = false; progressBar1.Increment(3); pbFinalCheck.Visible = true; if (progressBar1.Value >= 50) { dt = user.Login(txtUserName.Text, txtUserPass.Text); if (dt.Rows.Count > 0) { if (progressBar1.Value >= 75) { getUserPicture(); } if (progressBar1.Value >= progressBar1.Maximum) { timer1.Stop(); // saving user full name for salesman and welcome notify userLoggedinFullName = dt.Rows[0][3].ToString(); Program.SalesMan = userLoggedinFullName; Program.UserID = Convert.ToInt32(dt.Rows[0][4]); LoginNotify.ShowBalloonTip(7, "تم تسجيل الدخول", ": المستخدم الحالى\n " + userLoggedinFullName, ToolTipIcon.Info); BrowserForm.getMainForm.ShowDialog(); this.Close(); } } else { timer1.Stop(); Cursor = Cursors.Default; pbFinalCheck.Visible = false; txtLoginMessage.Visible = true; progressBar1.Value = 0; btnLogin.Enabled = true; txtUserName.Enabled = true; txtUserPass.Enabled = true; txtUserPass.Focus(); txtUserPass.SelectionStart = 0; txtUserPass.SelectionLength = txtUserPass.TextLength; return; } } } catch (Exception ex) { timer1.Stop(); MessageBox.Show(ex.Message + "\n" + "... خطأ فى إعدادات البرنامج", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } }