예제 #1
0
파일: SearchForm.cs 프로젝트: yorg76/test
        private void showDetails(object sender, EventArgs e)
        {
            int    selectedIndex = this.ordersList.SelectedIndex;
            Order  item          = (Order)this.ordersList.SelectedItem;
            string id            = item.id;

            this.order_id = int.Parse(id);
            Console.Error.WriteLine("Selected id " + id);
            string url          = ArchiDox.Properties.Resources.orderDetailsURL;
            string postData     = "order_id=" + id;
            string orderDetails = this.SendData("POST", url, postData);

            Console.Error.WriteLine("Order details:" + orderDetails);
            Console.Error.Flush();


            if (orderDetails.Length > 0 && this.listLoaded == true)
            {
                try
                {
                    JsonResponseOrderDetailsResult responseObj = JsonConvert.DeserializeObject <JsonResponseOrderDetailsResult>(orderDetails);
                    if (responseObj.status == "OK")
                    {
                        try
                        {
                            if (responseObj.content.Count > 0)
                            {
                                this.scan = false;
                                DialogResult dresult = MessageBox.Show("To zamówienie zostanie podjęte do realizacji", "Podjąć zamówienie ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                                if (dresult == DialogResult.Yes)
                                {
                                    string confirm_url     = ArchiDox.Properties.Resources.orderConfirmURL;
                                    string confirmPostData = "order_id=" + id;
                                    string confirmResult   = this.SendData("POST", confirm_url, confirmPostData);

                                    try
                                    {
                                        JsonResponseConfirmOrder confirmResponseObj = JsonConvert.DeserializeObject <JsonResponseConfirmOrder>(confirmResult);

                                        if (confirmResponseObj.status == "OK")
                                        {
                                            Console.Error.WriteLine("Zamówienie {0} zostało potwierdzone", id);
                                            orderDetailsList.DataSource    = responseObj.content;
                                            orderDetailsList.DisplayMember = "display_name";
                                            orderDetailsList.ValueMember   = "id";
                                            orderDetailsList.Visible       = true;
                                            ordersList.Visible             = false;
                                            code.Visible = true;
                                            try
                                            {
                                                hDcd    = new DecodeHandle(DecodeDeviceCap.Exists | DecodeDeviceCap.Barcode);
                                                reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;
                                                reqID   = hDcd.PostRequestMsgEx(reqType, wndMsg, Constants.WM_SCANNED, Constants.WM_TIMEOUT);
                                                Console.Error.WriteLine("Barcode decoder found");
                                                code.GotFocus += new System.EventHandler(this.scanCode);
                                                hDcd.SoftTrigger(DecodeInputType.Barcode, 5000);
                                                Console.Error.Flush();
                                            }
                                            catch (DecodeException)
                                            {
                                                Console.Error.WriteLine("Barcode decoder not found");
                                                Console.Error.Flush();
                                            }
                                            catch (Exception ee)
                                            {
                                                Console.Error.WriteLine("Barcode reader problem");
                                                Console.Error.WriteLine(ee.Message);
                                                Console.Error.WriteLine(ee.StackTrace);
                                                Console.Error.Flush();
                                            }
                                        }
                                        else
                                        {
                                            Console.Error.WriteLine(confirmResponseObj.error);
                                            Console.Error.Flush();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Error.WriteLine(ex.Message);
                                        Console.Error.WriteLine(ex.StackTrace);
                                        Console.Error.Flush();
                                    }
                                }
                                else if (dresult == DialogResult.No)
                                {
                                    Console.Error.Flush();
                                }
                            }
                            else if (responseObj.scan == true)
                            {
                                this.scan = true;
                                DialogResult dresult = MessageBox.Show("To zamówienie zostanie podjęte do realizacji i oczekuje skanowania nowych pudeł", "Podjąć zamówienie ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                                if (dresult == DialogResult.Yes)
                                {
                                    string confirm_url     = ArchiDox.Properties.Resources.orderConfirmURL;
                                    string confirmPostData = "order_id=" + id;
                                    string confirmResult   = this.SendData("POST", confirm_url, confirmPostData);
                                    try
                                    {
                                        JsonResponseConfirmOrder confirmResponseObj = JsonConvert.DeserializeObject <JsonResponseConfirmOrder>(confirmResult);

                                        if (confirmResponseObj.status == "OK")
                                        {
                                            Console.Error.WriteLine("Zamówienie {0} zostało potwierdzone", id);
                                            orderDetailsList.Visible = true;
                                            ordersList.Visible       = false;
                                            code.Visible             = true;
                                            try
                                            {
                                                hDcd    = new DecodeHandle(DecodeDeviceCap.Exists | DecodeDeviceCap.Barcode);
                                                reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;
                                                reqID   = hDcd.PostRequestMsgEx(reqType, wndMsg, Constants.WM_SCANNED, Constants.WM_TIMEOUT);
                                                Console.Error.WriteLine("Barcode decoder found");
                                                code.GotFocus += new System.EventHandler(this.scanCode);
                                                hDcd.SoftTrigger(DecodeInputType.Barcode, 5000);
                                                Console.Error.Flush();
                                            }
                                            catch (DecodeException)
                                            {
                                                Console.Error.WriteLine("Barcode decoder not found");
                                                Console.Error.Flush();
                                            }
                                            catch (Exception ee)
                                            {
                                                Console.Error.WriteLine("Barcode reader problem");
                                                Console.Error.WriteLine(ee.Message);
                                                Console.Error.WriteLine(ee.StackTrace);
                                                Console.Error.Flush();
                                            }
                                        }
                                        else
                                        {
                                            Console.Error.WriteLine(confirmResponseObj.error);
                                            Console.Error.Flush();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Error.WriteLine(ex.Message);
                                        Console.Error.WriteLine(ex.StackTrace);
                                        Console.Error.Flush();
                                    }
                                }
                                else
                                {
                                    Console.Error.Flush();
                                }
                            }

                            Console.Error.Flush();
                        }
                        catch (Exception ex)
                        {
                            Console.Error.WriteLine(ex.Message);
                            Console.Error.WriteLine(ex.StackTrace);
                            throw;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                    Console.Error.WriteLine(ex.StackTrace);
                    throw;
                }
            }
        }
예제 #2
0
        private void refreshDetails(object sender, EventArgs e)
        {
            order_backButton.Visible    = true;
            order_refreshButton.Visible = true;
            order_goButton.Visible      = true;

            backButton.Visible    = false;
            refreshButton.Visible = false;
            goButton.Visible      = false;
            finishButton.Visible  = false;

            int    selectedIndex = this.ordersList.SelectedIndex;
            Order  item          = (Order)this.ordersList.SelectedItem;
            string id            = item.id;

            this.order_id = int.Parse(id);
            Console.Error.WriteLine("Selected id " + id);
            string url          = ArchiDox.Properties.Resources.orderDetailsURL;
            string postData     = "order_id=" + id;
            string orderDetails = Global.SendData("POST", url, postData);

            Console.Error.WriteLine("Order details:" + orderDetails);
            Console.Error.Flush();


            if (orderDetails.Length > 0 && this.listLoaded == true)
            {
                try
                {
                    JsonResponseOrderDetailsResult responseObj = JsonConvert.DeserializeObject <JsonResponseOrderDetailsResult>(orderDetails);
                    if (responseObj.status == "OK")
                    {
                        try
                        {
                            if (responseObj.content.Count > 0 && responseObj.scan == false)
                            {
                                this.scan = false;
                                orderDetailsList.DataSource    = responseObj.content;
                                orderDetailsList.DisplayMember = "display_name";
                                orderDetailsList.ValueMember   = "id";
                                orderDetailsList.Visible       = true;
                                ordersList.Visible             = false;
                                code.Visible         = true;
                                finishButton.Visible = false;
                            }

                            else if (responseObj.scan == true)
                            {
                                orderDetailsList.Items.Clear();

                                this.scan = true;

                                orderDetailsList.Visible     = true;
                                ordersList.Visible           = false;
                                code.Visible                 = true;
                                order_refreshButton.Size     = new Size(123, 41);
                                order_refreshButton.Location = new Point(173, 499);
                                finishButton.Visible         = true;

                                try
                                {
                                    hDcd    = new DecodeHandle(DecodeDeviceCap.Exists | DecodeDeviceCap.Barcode);
                                    reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;
                                    reqID   = hDcd.PostRequestMsgEx(reqType, wndMsg, Constants.WM_SCANNED, Constants.WM_TIMEOUT);
                                    Console.Error.WriteLine("Barcode decoder found");
                                    code.GotFocus += new System.EventHandler(this.scanCode);
                                    hDcd.SoftTrigger(DecodeInputType.Barcode, 5000);
                                    Console.Error.Flush();
                                }
                                catch (Exception)
                                {
                                    Console.Error.WriteLine("Barcode decoder not found");
                                    Console.Error.Flush();
                                }
                            }

                            Console.Error.Flush();
                        }
                        catch (Exception ex)
                        {
                            Console.Error.WriteLine(ex.Message);
                            Console.Error.WriteLine(ex.StackTrace);
                            throw;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                    Console.Error.WriteLine(ex.StackTrace);
                    throw;
                }
            }
        }