Esempio n. 1
0
        private void GetReceiptliens(string OrderNo, int SourceType)
        {
            WarehouseReceiptLine_Service warehouserecieptlineservice = new WarehouseReceiptLine_Service();

            warehouserecieptlineservice.UseDefaultCredentials = true;

            List <WarehouseReceiptLine_Filter> WarehouseRecieptFilterArray = new List <WarehouseReceiptLine_Filter>();

            WarehouseReceiptLine_Filter SourceNoFilter = new WarehouseReceiptLine_Filter();

            SourceNoFilter.Field    = WarehouseReceiptLine_Fields.Source_No;
            SourceNoFilter.Criteria = OrderNo;
            WarehouseRecieptFilterArray.Add(SourceNoFilter);

            WarehouseReceiptLine_Filter SourceTypeFilter = new WarehouseReceiptLine_Filter();

            SourceTypeFilter.Field    = WarehouseReceiptLine_Fields.Source_Type;
            SourceTypeFilter.Criteria = SourceType.ToString();
            WarehouseRecieptFilterArray.Add(SourceTypeFilter);

            WarehouseReceiptLine [] RecieptLine = warehouserecieptlineservice.ReadMultiple(WarehouseRecieptFilterArray.ToArray(), "", 1000);

            if (RecieptLine.Count() > 0)
            {
                PurchaseLineList.Clear();
                POL = null;

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



                foreach (var POLl in RecieptLine)
                {
                    PurchaseLineList.Add(new PurchaseLine(POLl.No.ToString(), POLl.Description.ToString(), POLl.Qty_Outstanding, POLl.Unit_of_Measure_Code, 1, Warehouse.WSItemUsesMhdTracking(POLl.Item_No.ToString()), OrderNo, POLl.Item_No, POLl.Line_No));
                }

                lbNoOfLines.Text = (RecieptLine.Count() - ItemWithNoTracking).ToString();
                lbNoOfLines.Text = string.Format("{0} {1} {2}", (POLindex + 1), "af", PurchaseLineList.Count());
                Globals.step++;
                POL = PurchaseLineList.First();
                lbDescription.Text  = POL.TheDescription;
                lbNo.Text           = POL.TheItemNo;
                lbQuantity.Text     = POL.TheQuantity.ToString();
                lbUnitOfMesure.Text = POL.TheUnitOfMesure;

                lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText7");
            }
            else
            {
                tbInputData.Text = "";
                MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message1"));
            }
        }
Esempio n. 2
0
 public void ExtractData()
 {
     if (POLindex > -1)
     {
         POL = PurchaseLineList.ElementAt(POLindex);
         tbInputData.Text   = "";
         lbMHD.Text         = "";
         lbLotNo.Text       = "";
         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;
         lbNoOfLines.Text    = string.Format("{0} {1} {2}", (POLindex + 1), "af", PurchaseLineList.Count());
     }
 }
Esempio n. 3
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
        }