Ejemplo n.º 1
0
 private void mainForm_Load(object sender, EventArgs e)
 {
     foreach(Control ctrl in this.Controls)
     {
         if (ctrl is MdiClient)
             ctrl.BackColor = Color.White;
     }
     shortbtnPanel.Enabled = false;
     navPanel.Enabled = false;
     login login1 = new login();
     login1.MdiParent = this;
     login1.Show();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     login l = new login();
     l.Show();
     this.Hide();
 }
Ejemplo n.º 3
0
        private void btnLogout_Click(object sender, EventArgs e)
        {
            while (ActiveMdiChild != null)
                ActiveMdiChild.Close();
            try
            {
                CookieContainer httpWeb = new CookieContainer();

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(GlobalClass.url + "/logout/");
                httpWebRequest.ContentType = "text/json";
                httpWebRequest.Method = "POST";
                httpWebRequest.CookieContainer = new CookieContainer();
                httpWebRequest.CookieContainer.Add(new Uri(GlobalClass.url + "/logout/"), new Cookie("sessionid", ""));

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    var sesion = httpResponse.Headers.Get("Set-Cookie");

                    GlobalClass.session = sesion.Substring(sesion.IndexOf('=') + 1, sesion.IndexOf(';') - sesion.IndexOf('=') - 1);
                    JToken response = JToken.Parse(result);
                    if (Convert.ToString(response["status"]).Contains("True"))
                    {
                        MessageBox.Show("Logged out.", "Logout!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        mainForm.navPanel.Enabled = false;
                        mainForm.shortbtnPanel.Enabled = false;
                        login logIn = new login();
                        mainForm.userInfo.Text = "";
                        logIn.MdiParent = this;
                        logIn.Show();
                    }
                    else
                    {
                        MessageBox.Show("Could Not log out");
                    }
                }//end of using
            }//end of outer try
            catch
            {
                MessageBox.Show("Unable to connect to Server");
            }
        }