Example #1
0
        private bool ScanIn()
        {
            string requestData = "action=scan_in";

            requestData += "&machine=" + TextBoxMachine.Text;
            requestData += "&workOrder=" + TextBoxWorkOrder.Text;
            requestData += "&employee=" + TextBoxEmployee.Text;

            try
            {
                Status status = WebApiRequest.ApiPostRequest(requestData);

                if (status.errorNumber != 0)
                {
                    System.Diagnostics.Debug.Write("API Error: " + status.errorNumber + " - \n\t" + status.errorMessage + "\n");
                    MessageBox.Show(status.errorMessage, "Error scanning into equipment");
                    return(false);
                }

                //MessageBox.Show("Successfully scanned into equipment");
                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write("API Exception: " + e.Message + "\n");
                MessageBox.Show(e.Message, "Exception scanning into equipment");
                return(false);
            }
        }
Example #2
0
        private bool ScanOut()
        {
            XmlDocument partsXml = new XmlDocument();
            XmlElement  parent   = (XmlElement)partsXml.AppendChild(partsXml.CreateElement("machineMaintParts"));

            foreach (string part in ScannerData.parts.Keys)
            {
                XmlElement partElement = (XmlElement)parent.AppendChild(partsXml.CreateElement("machineMaintPart"));
                partElement.SetAttribute("part", part);
                partElement.SetAttribute("quantity", ScannerData.parts[part].ToString());
            }

            string requestData = "action=scan_out";

            requestData += "&machineMaintId=" + ScannerData.id;
            requestData += "&partsXml=" + partsXml.InnerXml;

            try
            {
                Status status = WebApiRequest.ApiPostRequest(requestData);

                if (status.errorNumber != 0)
                {
                    System.Diagnostics.Debug.Write("API Error: " + status.errorNumber + " - \n\t" + status.errorMessage + "\n");
                    MessageBox.Show(status.errorMessage, "Error scanning out of equipment");
                    return(false);
                }

                //MessageBox.Show("Successfully scanned out of equipment");
                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write("API Exception: " + e.Message + "\n");
                MessageBox.Show(e.Message, "Exception scanning out of equipment");
                return(false);
            }
        }