private void checkLogin(object sender, EventArgs e) { Console.SetError(this.errStream); string user = this.login.Text; string password = this.password.Text; string url = ArchiDox.Properties.Resources.loginURL; Dictionary <string, string> json = new Dictionary <string, string>(); json.Add("user", user); json.Add("password", password); string jsonContent = JsonConvert.SerializeObject(json); string postData = ""; foreach (string key in json.Keys) { postData += key + "=" + json[key] + "&"; } statusLabel.Visible = false; Console.Error.WriteLine("checkLogin started"); Console.Error.WriteLine(postData); try { string result = this.SendData("POST", url, postData); Console.Error.WriteLine(result); if (result.Length > 0) { try { JsonResponseResult responseObj = JsonConvert.DeserializeObject <JsonResponseResult>(result); Console.Error.WriteLine(responseObj.ToString()); if (responseObj.status == "OK") { Console.Error.WriteLine("Login Success: " + user); Console.Error.Flush(); Console.Error.Close(); this.errStream.Close(); Form sf = new SearchForm(); sf.Show(); this.Hide(); } else { statusLabel.Visible = true; statusLabel.Text = "Logowanie nie powiodło się! "; Console.Error.WriteLine("Login Error: " + user); Console.Error.WriteLine(responseObj.content); Console.Error.Flush(); } } catch (Exception ex) { string message = ex.Message; statusLabel.Visible = true; statusLabel.Text = "Logowanie nie powiodło się! "; Console.Error.WriteLine(message); Console.Error.Flush(); } } else { statusLabel.Visible = true; statusLabel.Text = "Brak odpowiedzi serwera!"; } } catch (WebException ex) { // Log exception and throw as for GET example above string message = ex.Message; statusLabel.Visible = true; statusLabel.Text = "Logowanie nie powiodło się! "; Console.Error.WriteLine(message); Console.Error.Flush(); //throw; } }
private void scanFinished(object sender, KeyEventArgs e) { List <Box> ordDL = (List <Box>)orderDetailsList.DataSource; if (e.KeyCode == Keys.Enter) { if (this.scan == false && ordDL.Count() > 0) { int idx = -1; foreach (Box box in ordDL) { if (box.id == this.code.Text) { Console.Error.WriteLine(box); Console.Error.WriteLine(ordDL.Count()); idx = ordDL.IndexOf(box); ordDL.RemoveAt(idx); string url = ArchiDox.Properties.Resources.boxStatusChangeURL; string postData = "box_id=" + box.id; string order_box = Global.SendData("POST", url, postData); JsonResponseResult responseObj = JsonConvert.DeserializeObject <JsonResponseResult>(order_box); if (responseObj.status == "OK") { Console.Error.WriteLine("Znaleziono pudło {0} i zmieniono mu status", box.id); } Console.Error.WriteLine(ordDL.Count()); Console.Error.WriteLine("Indeks:" + idx); Console.Error.WriteLine("Znaleziono pudło {0}", box.id); Console.Error.Flush(); break; } } orderDetailsList.DataSource = null; orderDetailsList.DataSource = ordDL; orderDetailsList.DisplayMember = "display_name"; orderDetailsList.ValueMember = "id"; orderDetailsList.Refresh(); if (orderDetailsList.Items.Count == 0) { refreshOrderList(); } } else if (this.scan == false && orderDetailsList.Items.Count == 0) { string complete_url = ArchiDox.Properties.Resources.orderCompleteURL; string completePostData = "order_id=" + this.order_id; string completeResult = Global.SendData("POST", complete_url, completePostData); try { JsonResponseConfirmOrder completeResponseObj = JsonConvert.DeserializeObject <JsonResponseConfirmOrder>(completeResult); if (completeResponseObj.status == "OK") { DialogResult dresult = MessageBox.Show("To zamówienie zostało skompletowane", "Zamówienie skompletowane", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (dresult == DialogResult.OK) { refreshOrderList(); } Console.Error.WriteLine("Zamówienie {0} zostało skompletowane", this.order_id); Console.Error.Flush(); } } catch (Exception ex) { Console.Error.WriteLine("Zamówienie {0} zostało skompletowane ale nie udało się go potwierdzić", this.order_id); Console.Error.Flush(); } } else if (this.scan == true) { try { if (addOrderBox(this.order_id, this.code.Text)) { Console.Error.WriteLine("Pudło {0} dodano do zamówienia " + this.order_id, this.code.Text); Console.Error.Flush(); } else { Console.Error.WriteLine("Pudło {0} nie zostałe dodane do zamówienia " + this.order_id, this.code.Text); Console.Error.Flush(); } } catch (Exception ex) { Console.Error.WriteLine("Pudło {0} nie zostałe dodane do zamówienia " + this.order_id, this.code.Text); Console.Error.Flush(); } } } else { Console.Error.WriteLine(e.KeyCode); Console.Error.Flush(); } }