private void Formlog_Load(object sender, EventArgs e) { startup(); Properties.Settings.Default.Reset(); if (Properties.Settings.Default.username != string.Empty && Properties.Settings.Default.password != string.Empty) { this.Hide(); sign_in log = new sign_in(); log.ShowDialog(); this.Close(); } }
private void Button1_Click(object sender, EventArgs e) { if (txtweb.Text == "e.g workplace.comeriver.com") { MessageBox.Show("Address Missing"); txtweb.Focus(); return; } if (txtname.Text == "e.g [email protected]") { MessageBox.Show("Email Missing"); txtname.Focus(); return; } if (txtpass.Text == "******") { MessageBox.Show("Password Missing"); txtpass.Focus(); return; } try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(txtweb.Text); request.Method = "POST"; //set method property string requestParams = "username: "******"password: "******"application/x-www-form-urlencoded"; //content type property request.ContentLength = byteArray.Length; //sets content lenght of the request using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(byteArray, 0, byteArray.Length); requestStream.Close(); //requestStream.Write(byteArray, 0, byteArray.Length); } // Get the response. using (WebResponse response = request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { StreamReader rdr = new StreamReader(responseStream, Encoding.UTF8); string Json = rdr.ReadToEnd(); // response from server MessageBox.Show(Json); } } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } Properties.Settings.Default.username = txtname.Text; Properties.Settings.Default.password = txtpass.Text; Properties.Settings.Default.weburl = txtweb.Text; Properties.Settings.Default.Save(); this.Hide(); sign_in log = new sign_in(); log.ShowDialog(); this.Close(); }