Beispiel #1
0
        private void maskedTextBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (Globals.GlobalStep)
                {
                case 0:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }

                    // Hent Købsordredata
                    GetPurchaseOrder(tbInputData.Text);
                    btnDecoder.Visible = true;
                }
                break;

                case 1:
                {
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText2");
                    if (Vendorlot != "")
                    {
                        tbInputData.Text = Vendorlot;
                        tbInputData.SelectAll();
                    }
                    else
                    if (Decoding.theCode10.Equals(""))
                    {
                        tbInputData.Text = "";
                    }
                    else
                    {
                        tbInputData.Text = Decoding.theCode10.ToString();
                    }
                    Globals.step++;
                    btnDecoder.Visible = false;
                    btSearch.Visible   = true;
                }
                break;

                case 2:
                {
                    btnNext.Enabled    = false;
                    btnPrevius.Enabled = false;
                    btnDecoder.Visible = false;
                    btSearch.Visible   = false;
                    Vendorlot          = tbInputData.Text;
                    Globals.step++;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");
                    tbInputData.Text  = "";

                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    POL = PurchaseLineList.ElementAt(POLindex);
                    try
                    {
                        if (Decoding.theCode37.Equals(""))
                        {
                            remaning = WareHouse.WSReturnRemaningQuantity(OrderType, POL.TheSourceNo.ToString(), POL.TheItemNo.ToString());
                        }
                        else
                        {
                            remaning = decimal.Parse(Decoding.theCode37.ToString());
                        }


                        tbInputData.Text = remaning.ToString();
                        lbQuantity.Text  = remaning.ToString();
                        tbInputData.SelectAll();
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                    }
                }
                break;

                case 3:
                {
                    decimal d = 0;
                    if (!decimal.TryParse(tbInputData.Text, out d))
                    {
                        break;
                    }
                    lbQuantity.Text = tbInputData.Text;
                    #region Add Qty to purchaseorder
                    if (d > remaning)
                    {
                        if (MessageBox.Show(string.Format(mt.ReadResFile(this.Name.ToString() + "Message9"), remaning.ToString(), Environment.NewLine, tbInputData.Text), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            BalanceWarehouse WareHouse = new BalanceWarehouse();
                            WareHouse.UseDefaultCredentials = true;
                            try
                            {
                                WareHouse.WSAddQuantityToPurchaseOrder(POL.TheSourceNo, POL.TheItemNo, (d - remaning), POL.TheUnitOfMesure);
                            }
                            catch (Exception ex)
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                                break;
                            }
                            try
                            {
                                WareHouse.WSCreateWarehouseInboundDoc(OrderNo);
                            }
                            catch (Exception ex)
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                                break;
                            }
                            try
                            {
                                // Hent modtagelseslinjer på ny med de nye antal i.
                                GetReceiptliens(OrderNo, OrderType);
                                // GetReceiptlines tæller Globals.Step op med en så den skal sættes 1 ned.
                                Globals.GlobalStep--;
                                ExtractData();
                            }
                            catch (Exception ex)
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                                break;
                            }
                        }
                        else
                        {
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                            break;
                        }
                    }
                    #endregion

                    POL.TheQuantity = d;
                    PurchaseLineList.Insert(POLindex, POL);
                    PurchaseLineList.RemoveAt(POLindex + 1);
                    tbInputData.Text = "";
                    tbInputData.Focus();
                    tbInputData.SelectAll();
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                    #region QaSample
                    decimal SQ  = 0;
                    string  UOM = "";

                    try
                    {
                        BalanceWarehouse WareHouse = new BalanceWarehouse();
                        WareHouse.UseDefaultCredentials = true;

                        if (WareHouse.WSItemQaSample(POL.TheItemNo, ref SQ, ref UOM))
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Message6"), POL.TheItemNo.ToString(), SQ.ToString("F2"), UOM.ToString()),
                                                                   mt.ReadResFile(this.Name.ToString() + "Message6Caption"));
                        }
                        WareHouse.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    #endregion

                    if (POL.TheUseMHD)
                    {
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText5");
                        tbInputData.Mask  = mt.ReadResFile(this.Name.ToString() + "DateMask");
                        Globals.step++;
                    }
                    else
                    {
                        // Hent Lotnummer fra nummerserie og opret Lot Info  Start.

                        BalanceWarehouse WareHouse = new BalanceWarehouse();
                        WareHouse.UseDefaultCredentials = true;

                        if (WareHouse.WSItemUsesTracking(POL.TheItemNo))
                        {
                            #region Generate PID
                            try
                            {
                                GenereretPID = WareHouse.WSReturnNewPID();
                            }
                            catch (Exception ex)
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                            }
                            #endregion

                            #region Print PID Preview
                            try
                            {
                                WareHouse.WSPrintPidPrev(GenereretPID, Globals.theWinlogon, POL.TheItemNo, POL.TheQuantity.ToString(), POL.TheMHD.ToString(), Vendorlot, POL.TheUnitOfMesure.ToString());
                                if (Globals.theShowMessage)
                                {
                                    MessageBoxExample.MyMessageBox.ShowBox(GenereretPID.ToString());
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(ex.Message.ToString());
                            }
                            #endregion

                            // Hent Lotnummer fra nummerserie og opret Lot Info  S**t.
                            Globals.step     += 2;
                            tbInputData.Text  = "";
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                        }
                        else
                        {
                            Globals.step     += 3;
                            tbInputData.Text  = "";
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText6");
                            tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                        }
                    }
                }
                break;

                case 4:
                {
                    bool     OK       = false;
                    DateTime TestDate = new DateTime(1, 1, 1);

                    try
                    {
                        if (Decoding.theCode15.Equals(""))
                        {
                            TestDate = Convert.ToDateTime(tbInputData.Text);
                        }
                        else
                        {
                            TestDate = Convert.ToDateTime(Decoding.theCode15.ToString());
                        }

                        if (TestDate.CompareTo(DateTime.Now) >= 1)
                        {
                            OK = true;
                        }
                        else
                        {
                            OK = false;
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Message8"), TestDate.ToShortDateString(), Environment.NewLine, Environment.NewLine, DateTime.Today.ToShortDateString()));
                        }
                    }
                    catch (Exception ex)
                    {
                        OK = false;
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message.ToString());
                    }

                    if (OK)
                    {
                        lbMHD.Text = tbInputData.Text;
                        POL.TheMHD = DateTime.Parse(lbMHD.Text);
                        PurchaseLineList.Insert(POLindex, POL);
                        PurchaseLineList.RemoveAt(POLindex + 1);
                        tbInputData.Mask  = "";
                        tbInputData.Text  = "";
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                        Globals.step++;
                        // Hent Lotnummer fra nummerserie og opret Lot Info  Start.
                        BalanceWarehouse WareHouse = new BalanceWarehouse();
                        WareHouse.UseDefaultCredentials = true;
                        GenereretPID = WareHouse.WSReturnNewPID();
                        WareHouse.WSPrintPidPrev(GenereretPID, Globals.theWinlogon, POL.TheItemNo, POL.TheQuantity.ToString(), POL.TheMHD.ToString(), Vendorlot, POL.TheUnitOfMesure.ToString());
                        if (Globals.theShowMessage)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(GenereretPID.ToString());
                        }
                        WareHouse.Dispose();
                        // Hent Lotnummer fra nummerserie og opret Lot Info  S**t.
                    }
                    else
                    {
                        tbInputData.Text = "";
                    }
                }
                break;

                case 5:
                {
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    POL = PurchaseLineList.ElementAt(POLindex);

                    if (WareHouse.WSItemUsesTracking(POL.TheItemNo))
                    {
                        if (!GenereretPID.Equals(tbInputData.Text))
                        {
                            tbInputData.Text = "";
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message7"));
                            break;
                        }

                        try
                        {
                            if (WareHouse.WSLotInfoUsed(tbInputData.Text))
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message5"));
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                        }


                        try
                        {
                            if (!WareHouse.WSLotInfoExists(POL.TheItemNo, tbInputData.Text, Vendorlot))
                            {
                                MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message3"));
                                break;
                            }
                            lbLotNo.Text     = tbInputData.Text;
                            tbInputData.Text = "";
                            POL = PurchaseLineList.ElementAt(POLindex);
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText6");
                            tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                            Globals.step++;
                        }
                        catch (Exception ex)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                        }
                        finally
                        {
                            WareHouse.Dispose();
                        }
                    }
                }
                break;

                case 6:
                {
                    Decoding.theCode00 = "";
                    Decoding.theCode01 = "";
                    Decoding.theCode02 = "";
                    Decoding.theCode10 = "";
                    Decoding.theCode15 = "";
                    Decoding.theCode37 = "";
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    POL = PurchaseLineList.ElementAt(POLindex);
                    try
                    {
                        DateTime d;
                        if (POL.TheMHD.ToString() != "")
                        {
                            DateTime.TryParse(POL.TheMHD.ToString(), out d);
                        }
                        else
                        {
                            d = DateTime.Now;
                        }
                        this.pbIndicator.Image   = WindowsFormsApplication1.Properties.Resources.animatedCircle;
                        this.pbIndicator.Visible = true;

                        WareHouse.WSWhsPostReceiptLine(OrderType, POL.TheSourceNo, POL.TheItemNo, POL.TheQuantity, d, lbLotNo.Text, Vendorlot, POL.TheLinje, Globals.theLocation);
                    }
                    catch (Exception ex)
                    {
                        this.pbIndicator.Image   = null;
                        this.pbIndicator.Visible = false;

                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    lbQuantity.Text = WareHouse.WSReturnRemaningQuantity(OrderType, POL.TheSourceNo.ToString(), POL.TheItemNo.ToString()).ToString(CultureInfo.GetCultureInfo(Globals.theLanguageCode).NumberFormat);

                    this.pbIndicator.Image   = null;
                    this.pbIndicator.Visible = false;

                    if (lbQuantity.Text == "0")
                    {
                        PurchaseLineList.RemoveAt(POLindex);
                        if (POLindex > 0)
                        {
                            POLindex--;
                        }
                        tbInputData.Text   = "";
                        btnNext.Enabled    = true;
                        btnPrevius.Enabled = true;
                        if (PurchaseLineList.Count > 1)
                        {
                            //lbNoOfLines.Text = PurchaseLineList.Count.ToString();
                            lbNoOfLines.Text  = string.Format("{0} {1} {2}", (POLindex + 1), "af", PurchaseLineList.Count());
                            Globals.step      = 1;
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText7");

                            // Hent aktuel varelinje Start
                            POL = PurchaseLineList.ElementAt(POLindex);
                            lbDescription.Text = POL.TheDescription;
                            lbNo.Text          = POL.TheItemNo;
                            lbQuantity.Text    = POL.TheQuantity.ToString();
                            if (POL.TheQuantity <= 0)
                            {
                                tbInputData.Enabled = false;
                            }
                            else
                            {
                                tbInputData.Enabled = true;
                            }
                            lbUnitOfMesure.Text = POL.TheUnitOfMesure;
                            // Hent aktuel varelinje S**t
                            lbLotNo.Text    = "";
                            lbMHD.Text      = "";
                            lbQuantity.Text = "";
                        }

                        if (PurchaseLineList.Count == 1)
                        {
                            lbNoOfLines.Text = PurchaseLineList.Count.ToString();
                            lbNoOfLines.Text = string.Format("{0} {1} {2}", (POLindex + 1), "af", PurchaseLineList.Count());
                            // Hent aktuel varelinje Start
                            POL = PurchaseLineList.ElementAt(POLindex);
                            lbDescription.Text = POL.TheDescription;
                            lbNo.Text          = POL.TheItemNo;
                            lbQuantity.Text    = POL.TheQuantity.ToString();
                            if (POL.TheQuantity <= 0)
                            {
                                tbInputData.Enabled = false;
                            }
                            else
                            {
                                tbInputData.Enabled = true;
                            }
                            lbUnitOfMesure.Text = POL.TheUnitOfMesure;
                            lbLotNo.Text        = "";
                            lbMHD.Text          = "";

                            // Hent aktuel varelinje S**t

                            Globals.step       = 1;
                            lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText7");
                            btnDecoder.Visible = true;
                            btSearch.Visible   = true;
                        }
                        if (PurchaseLineList.Count == 0)
                        {
                            Globals.step = 0;
                        }
                    }
                    else
                    {
                        Globals.step       = 1;
                        lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText7");
                        btnDecoder.Visible = true;
                        btSearch.Visible   = true;
                        tbInputData.Text   = "";       // Globals.VendorLot;
                        tbInputData.SelectAll();
                        lbLotNo.Text       = "";
                        lbMHD.Text         = "";
                        btnNext.Enabled    = true;
                        btnPrevius.Enabled = true;
                    }
                    if (Globals.step == 0)
                    {
                        lblInputText.Text   = mt.ReadResFile(this.Name.ToString() + "LabelInputText1");
                        lbLotNo.Text        = "";
                        lbMHD.Text          = "";
                        lbName.Text         = "";
                        lbName2.Text        = "";
                        lbNo.Text           = "";
                        lbQuantity.Text     = "";
                        lbUnitOfMesure.Text = "";
                        lbAddress.Text      = "";
                        lbDescription.Text  = "";
                        tbInputData.Text    = "";
                        lbNoOfLines.Text    = "";
                        btnNext.Enabled     = true;
                        btnPrevius.Enabled  = true;
                        Vendorlot           = "";
                    }
                    WareHouse.Dispose();
                }
                break;
                }
            }
            #region ESC
            if ((e.KeyChar == (char)Keys.Escape) || (e.KeyChar == (char)Keys.Tab))
            {
                switch (Globals.step)
                {
                case 7:
                {
                    tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText6");
                    Globals.step--;
                }
                break;

                case 6:
                {
                    Globals.step--;
                }
                break;

                case 5:
                {
                    POL = PurchaseLineList.ElementAt(POLindex);


                    if (POL.TheUseMHD)
                    {
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText5");
                        tbInputData.Text  = POL.TheMHD.ToString();
                        Globals.step     -= 2;
                    }
                    else
                    {
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                        tbInputData.Text  = POL.TheLotNr.ToString();
                        Globals.step     -= 2;
                    }
                }
                break;

                case 4:
                {
                    Globals.step--;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");
                    POL = PurchaseLineList.ElementAt(POLindex);
                    tbInputData.Mask = "";
                    tbInputData.Text = POL.TheQuantity.ToString();
                }
                break;

                case 3:
                {
                    Globals.step--;
                    lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText2");
                    tbInputData.Text   = Vendorlot;
                    btnPrevius.Enabled = true;
                    btnNext.Enabled    = true;
                }
                break;

                case 2:
                {
                    Globals.step      = 0;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText1");
                    tbInputData.Text  = "";
                }
                break;

                case 1:
                {
                    Globals.step--;
                }
                break;

                case 0: this.Close();
                    break;
                }
            }
            #endregion
        }
Beispiel #2
0
        private void GetPurchaseOrder(string OrderNo)
        {
            PurchaseOrderCard_Service purchaseorderservice = new PurchaseOrderCard_Service();

            purchaseorderservice.UseDefaultCredentials = true;

            List <PurchaseOrderCard_Filter> PurchaseOrderFilterArray = new List <PurchaseOrderCard_Filter>();

            PurchaseOrderCard_Filter PurchaseOrderNoFilter = new PurchaseOrderCard_Filter();

            PurchaseOrderNoFilter.Field    = PurchaseOrderCard_Fields.No;
            PurchaseOrderNoFilter.Criteria = OrderNo;
            PurchaseOrderFilterArray.Add(PurchaseOrderNoFilter);

            PurchaseOrderCard [] PurchaseOrder = purchaseorderservice.ReadMultiple(PurchaseOrderFilterArray.ToArray(), "", 1000);

            if (PurchaseOrder.Count() > 0)
            {
                foreach (var PO in PurchaseOrder)
                {
                    if (PO.Status == 0)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message4"));
                        break;
                    }
                    lbName.Text = PO.Buy_from_Vendor_Name.ToString();
                    if (!string.IsNullOrEmpty(PO.Buy_from_Vendor_Name_2))
                    {
                        lbName2.Text = PO.Buy_from_Vendor_Name_2.ToString();
                    }
                    if (!string.IsNullOrEmpty(PO.Buy_from_Address))
                    {
                        lbAddress.Text = PO.Buy_from_Address.ToString();
                    }

                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    try
                    {
                        if (WareHouse.WSCreateWarehouseInboundDoc(OrderNo))
                        {
                            // Hent købsmodtagelseslinjer
                            GetReceiptliens(OrderNo, OrderType);
                        }
                    }
                    catch (Exception ex)
                    {
                        Globals.step      = 0;
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText1");
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                        tbInputData.Text   = "";
                        btnDecoder.Visible = true;
                    }
                }
            }
            else
            {
                tbInputData.Text = "";
                MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message2"));
            }
        }