Ejemplo n.º 1
0
        private void GetData()
        {
            BalanceWarehouse WareHouse = new BalanceWarehouse();

            WareHouse.UseDefaultCredentials = true;
            string   lokation    = "";
            string   placering   = "";
            string   varenr      = "";
            string   beskrivelse = "";
            decimal  antal       = 0;
            DateTime mhd         = DateTime.UtcNow;

            lot = tbInputData.Text;
            string uom = "";
            string vl  = "";

            try
            {
                if (!WareHouse.WSReturnLotInfo(lot, Globals.theLocation, ref placering, ref varenr, ref beskrivelse, ref antal, ref mhd, ref uom, ref vl))
                {
                    MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message1"));
                }
                else
                {
                    lokation            = Globals.theLocation;
                    lbPID.Text          = lot;
                    lbLocation.Text     = lokation;
                    lbBin.Text          = placering;
                    lbItemNo.Text       = varenr;
                    lbDescription.Text  = beskrivelse;
                    lbQuantity.Text     = antal.ToString(CultureInfo.GetCultureInfo(Globals.theLanguageCode).NumberFormat);
                    lbUnitOfMesure.Text = uom;
                    lbExpiredate.Text   = mhd.ToShortDateString();
                    lbVendorLot.Text    = vl;
                    lblInputText.Text   = mt.ReadResFile(this.Name.ToString() + "lblInputText2");
                    lbNewLocation.Text  = lokation;
                    BinContentTool btool = new BinContentTool();
                    lbStdBin.Text    = btool.GetDefaultBin(Globals.theLocation, varenr);
                    tbInputData.Text = "";
                    Globals.step     = 1;
                }
            }
            catch (Exception ex)
            {
                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
            }
            finally
            {
                WareHouse.Dispose();
                lbNewLocation.Text = lokation;
                tbInputData.Text   = "";
            }
        }
Ejemplo n.º 2
0
        private void GetData()
        {
            BalanceWarehouse WareHouse = new BalanceWarehouse();

            WareHouse.UseDefaultCredentials = true;

            try
            {
                lbLocation.Text    = Globals.theLocation;
                lbItemNo.Text      = itemno;
                lbQuantity.Text    = "0";
                lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "lblInputText1");
                lbNewLocation.Text = Globals.theLocation;
                tbInputData.Text   = "";
                Globals.step       = 0;

                lbDescription.Text = WareHouse.WSReturnItemDescription(itemno);
                if (lbDescription.Text.Equals(""))
                {
                    MessageBoxExample.MyMessageBox.ShowBox(string.Format("Varen {0} findes ikke", itemno));
                    tbInputData.Focus();
                    tbInputData.SelectAll();
                }
                lbUnitOfMesure.Text = WareHouse.WSReturnItemUnitOfMesure(itemno, 2);
                BinContentTool btool = new BinContentTool();
                lbStdBin.Text = btool.GetDefaultBin(Globals.theLocation, itemno);
            }
            catch (Exception ex)
            {
                MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
            }
            finally
            {
                WareHouse.Dispose();
                lbNewLocation.Text = Globals.theLocation;
                tbInputData.Text   = "";
            }
        }
Ejemplo n.º 3
0
        public void GetPidData(string Data)
        {
            #region Local variables
            string   lokation    = Globals.theLocation;
            string   placering   = "";
            string   varenr      = "";
            string   beskrivelse = "";
            decimal  antal       = 0;
            DateTime mhd         = DateTime.Now;
            string   uom         = "";
            string   vl          = "";
            bool     b_recount   = false;

            MyToolbox mt = new MyToolbox();
            #endregion

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

            ItemTool it = new ItemTool();

            this.pbIndicator.Image   = WindowsFormsApplication1.Properties.Resources.animatedCircle;
            this.pbIndicator.Visible = true;

            if (tbInputData.Text.Equals("#"))
            {
                if (Selector == 0)
                {
                    // Kald formen til optælling uden P-ID, hvis det er en holdbarhedsvare tilføjes data og et P-ID.
                    fmInventory inv = new fmInventory(tbInputData.Text);
                    inv.ShowDialog();
                    tbInputData.Text = "";
                }
                if (Selector == 1)
                {
                    // Bruges pt ikke
                    tbInputData.Text = "";
                }
            }
            else
            {
                try
                {
                    switch (it.TypeOfItem(ref Data, Globals.theLocation, ref placering, ref varenr, ref beskrivelse, ref antal, ref mhd, ref uom, ref vl, ref b_recount))
                    {
                    case 0:
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Error1"), Data));
                        tbInputData.Text = "";
                    }
                    break;

                    case 1:
                    {
                        if (Selector == 0)
                        {
                            fmPidInventory pi = new fmPidInventory(Data);
                            pi.ShowDialog();
                            tbInputData.Text = "";
                        }
                        if (Selector == 1)
                        {
                            // Kalde form til at afvikle flytning af varer med P-ID
                            fmPidItemTransfer pit = new fmPidItemTransfer(Data);
                            pit.ShowDialog();
                            tbInputData.Text = "";
                        }
                    }
                    break;

                    case 2:
                    {
                        #region GetBincontent
                        BinContentTool bct = new BinContentTool();
                        if (bct.GetItemBincontent(Globals.theLocation, "", Data.ToUpper(), ref antal, ref uom))
                        {
                            if (Selector == 0)
                            {
                                // Kalde form til at afvikle optælling af varer uden P-ID
                                fmInventory inv = new fmInventory(Data);
                                inv.ShowDialog();
                                tbInputData.Text = "";
                            }

                            if (Selector == 1)
                            {
                                // Kalde form til at afvikle flytning af varer uden P-ID
                                fmItemTransfer itf = new fmItemTransfer(Data);
                                itf.ShowDialog();
                                tbInputData.Text = "";
                            }
                        }
                        #endregion

/*
 *                              if (WareHouse.WSGetItemBinInformation(Globals.theWinlogon, Globals.theLocation, Data.ToUpper()) > 0)
 *                              {
 *                                  if (Selector == 0)
 *                                  {
 *                                      // Kalde form til at afvikle optælling af varer uden P-ID
 *                                      fmInventory inv = new fmInventory(Data);
 *                                      inv.ShowDialog();
 *                                      tbInputData.Text = "";
 *                                  }
 *
 *                                  if (Selector == 1)
 *                                  {
 *                                      // Kalde form til at afvikle flytning af varer uden P-ID
 *                                      fmItemTransfer itf = new fmItemTransfer(Data);
 *                                      itf.ShowDialog();
 *                                      tbInputData.Text = "";
 *                                  }
 *                              }
 */
                    }
                    break;

                    case 3:
                    {
                        if (WareHouse.WSGetBinContentInformation(Globals.theWinlogon, Globals.theLocation, Data.ToUpper()) > 0)
                        {
                            fmBinContent fm = new fmBinContent(1, Data.ToUpper());
                            fm.ShowDialog();
                            tbInputData.Text = "";
                        }
                    }
                    break;
                    }
                }
                catch (Exception ex)
                {
                    this.pbIndicator.Image   = null;
                    this.pbIndicator.Visible = false;

                    MessageBoxExample.MyMessageBox.ShowBox(ex.Message.ToString());
                    tbInputData.Text = "";
                }
                finally
                {
                    this.pbIndicator.Image   = null;
                    this.pbIndicator.Visible = false;

                    WareHouse.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        private void tbInputData_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (Globals.GlobalStep)
                {
                case 0:
                {
                    // Placeringsfunktionalitet.
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

                    try
                    {
                        if (!WareHouse.WSBinExists(Globals.theLocation, tbInputData.Text))
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message1"));
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                            break;
                        }

                        lbBin.Text = tbInputData.Text.ToUpper();

                        #region GetBincontent
                        decimal        antal = 0;
                        string         uom   = "";
                        BinContentTool bct   = new BinContentTool();
                        if (bct.GetItemBincontent(lbLocation.Text, lbBin.Text, lbItemNo.Text, ref antal, ref uom))
                        {
                            lbQuantity.Text     = antal.ToString("N2");
                            lbUnitOfMesure.Text = uom;
                        }
                        #endregion
                        if (antal == 0)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Error5"), lbItemNo.Text, lbBin.Text));
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                            break;
                        }
                        Globals.GlobalStep++;
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                        tbInputData.SelectAll();
                        break;
                    }
                    tbInputData.Text  = "";
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText2");
                }
                break;

                case 1:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

                    if (!WareHouse.WSBinExists(lbNewLocation.Text, tbInputData.Text))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message2"));
                        tbInputData.SelectAll();
                        break;
                    }

                    lbNewBinCode.Text = tbInputData.Text.ToUpper();
                    lblInputText.Text = lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText3");
                    tbInputData.Text  = lbQuantity.Text;

                    BinContentTool btool = new BinContentTool();

                    if (!btool.BinIsDefault(Globals.theLocation, lbNewBinCode.Text, lbItemNo.Text, "") && (lbStdBin.Text != lbNewBinCode.Text))
                    {
                        if (MessageBox.Show(string.Format("Skal standard placering skiftes fra {0} til {1}?", lbStdBin.Text, lbNewBinCode.Text), "Skift standard placering", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            if (MessageBox.Show(string.Format("Er du sikker på at du vil skiftes fra {0} til {1}?", lbStdBin.Text, lbNewBinCode.Text), "Advarsel! Skifter standard placering", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                            {
                                changedefaultbin = true;
                            }
                        }
                    }

                    tbInputData.SelectAll();
                    Globals.step++;
                }
                break;

                case 2:
                {
                    decimal d = 0;
                    // Angivelse af antal.
                    if (!decimal.TryParse(tbInputData.Text, out d))
                    {
                        break;
                    }
                    if (d < 0)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message6"));
                        tbInputData.SelectAll();
                        break;
                    }

                    if (d > decimal.Parse(lbQuantity.Text))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Error4"), lbQuantity.Text, lbUnitOfMesure.Text));
                        tbInputData.SelectAll();
                        break;
                    }

                    lbMoveQty.Text    = tbInputData.Text;
                    lbNewUom.Text     = lbUnitOfMesure.Text;
                    lblInputText.Text = lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText4");
                    tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "lblInputText5");
                    Globals.step++;
                }
                break;

                case 3:
                {
                    this.pbIndicator.Image   = WindowsFormsApplication1.Properties.Resources.animatedCircle;
                    this.pbIndicator.Visible = true;

                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    try
                    {
                        if (changedefaultbin)
                        {
                            WareHouse.WSSetDefaultBin(Globals.theLocation, lbStdBin.Text, lbItemNo.Text, lbUnitOfMesure.Text, false);
                        }

                        WareHouse.WSPostTransfer(Globals.theTransferTemplateName, Globals.theTransferBatchName, lbItemNo.Text.ToString(), lbUnitOfMesure.Text, Globals.theWinlogon, lbLocation.Text.ToString(), lbBin.Text.ToString(), "", lbNewLocation.Text.ToString(), lbNewBinCode.Text.ToString(), itemno.ToString(), decimal.Parse(lbMoveQty.Text.ToString()), false, DateTime.Parse(DateTime.Now.ToString()), DateTime.Now, 0);

                        if (changedefaultbin)
                        {
                            WareHouse.WSSetDefaultBin(Globals.theLocation, lbNewBinCode.Text, lbItemNo.Text, lbUnitOfMesure.Text, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.pbIndicator.Image   = null;
                        this.pbIndicator.Visible = false;

                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    this.Close();
                    Globals.GlobalStep = 0;
                }
                break;
                }
            }

            if ((e.KeyChar == (char)Keys.Escape) || (e.KeyChar == (char)Keys.Tab))
            {
                switch (Globals.step)
                {
                case 2:
                {
                    Globals.step--;
                    tbInputData.Text  = "";
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText1");;
                }
                break;

                case 1:
                {
                    this.Close();
                }
                break;

                case 0: this.Close();
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        private void tbInputData_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (Globals.GlobalStep)
                {
                case 0:
                {
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    try
                    {
                        tbInputData.Text = WareHouse.WSGetItemCrossRef(WareHouse.WSGetItemCrossRef(tbInputData.Text));

                        if (WareHouse.WSItemUsesTracking(tbInputData.Text))
                        {
                            g_PID        = WareHouse.WSReturnNewPID();
                            b_NewPID     = true;
                            b_confirmPid = true;

                            UseMhd = WareHouse.WSItemUsesMhdTracking(tbInputData.Text);
                        }
                        lbDescription.Text = WareHouse.WSReturnItemDescription(tbInputData.Text);
                        if (lbDescription.Text.Equals(""))
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message8"));
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                        }
                        lbUnitOfMesure.Text = WareHouse.WSReturnItemUnitOfMesure(tbInputData.Text, 2);
                        lbItemNo.Text       = tbInputData.Text;
                        CaptionBin();
                        Globals.GlobalStep++;
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                        tbInputData.Text = "";
                        tbInputData.Focus();
                    }
                }
                break;

                case 1:
                {
                    // Placeringsfunktionalitet.
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

                    lbLocation.Text = Globals.theLocation;

                    if (!WareHouse.WSBinExists(Globals.theLocation, tbInputData.Text.ToUpper()))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message4"));
                        tbInputData.Focus();
                        tbInputData.SelectAll();
                        break;
                    }
                    if (!WareHouse.WSInventoryAllowed(Globals.theLocation, tbInputData.Text.ToUpper()))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message10"));
                        tbInputData.Focus();
                        tbInputData.SelectAll();
                        break;
                    }


                    lbBin.Text = tbInputData.Text.ToUpper();

                    #region GetBincontent
                    decimal        antal = 0;
                    string         uom   = "";
                    BinContentTool bct   = new BinContentTool();
                    if (bct.GetItemBincontent(lbLocation.Text, lbBin.Text, lbItemNo.Text, ref antal, ref uom))
                    {
                        lbQuantity.Text     = antal.ToString("N2");
                        lbUnitOfMesure.Text = uom;
                    }
                    else
                    {
                        lbQuantity.Text = "0";
                    }
                    #endregion
                    bool UseMhd = false;
                    UseMhd = WareHouse.WSItemUsesMhdTracking(lbItemNo.Text);

                    if (UseMhd)
                    {
                        CaptionExpiredate();
                        Globals.GlobalStep = 3;
                    }
                    else
                    {
                        CaptionQuantity();
                        Globals.GlobalStep = 5;
                    }
                }

                break;

                case 2:
                {
                }
                break;

                case 3:
                {
                    // Mhd
                    bool     OK       = false;
                    DateTime TestDate = new DateTime(1, 1, 1);
                    try
                    {
                        TestDate = Convert.ToDateTime(tbInputData.Text);
                        if (TestDate.CompareTo(DateTime.Now) >= 1)
                        {
                            OK = true;
                        }
                        else
                        {
                            OK = false;
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Message5"), TestDate.ToShortDateString(), Environment.NewLine, Environment.NewLine, DateTime.Today.ToShortDateString()));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }

                    if (OK)
                    {
                        lbExpiredate.Text = tbInputData.Text;
                        tbInputData.Mask  = "";
                        tbInputData.Text  = "";
                        CaptionVendorlot();
                        Globals.GlobalStep++;
                    }
                    else
                    {
                        tbInputData.Text = "";
                    }
                }
                break;

                case 4:
                {
                    // Leverandørlot
                    Vendorlot();
                    CaptionQuantity();
                }
                break;

                case 5:
                {
                    // Antal
                    // Kontrol på, at der ikke tælles på en ikke tilladt placeringstype kode
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    if (!WareHouse.WSInventoryAllowed(Globals.theLocation, lbBin.Text))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message10"));
                        tbInputData.Focus();
                        tbInputData.SelectAll();
                        break;
                    }

                    decimal d = 0;
                    // Angivelse af antal.
                    if (!decimal.TryParse(tbInputData.Text, out d))
                    {
                        break;
                    }
                    if (d < 0)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message6"));
                        tbInputData.SelectAll();
                        break;
                    }

                    if (d > 1000000)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message9"));
                        tbInputData.SelectAll();
                        break;
                    }

                    lbPhysQty.Text = tbInputData.Text;
                    if (b_NewPID && b_confirmPid)
                    {
                        CaptionLot();
                        //Indsæt funktion til udskrivning af p-is label-
                        Globals.GlobalStep = 6;
                    }
                    else
                    {
                        CaptionPosting();
                        Globals.GlobalStep = 7;
                    }

                    if ((b_NewPID) && (decimal.Parse(lbPhysQty.Text) > 0))
                    {
                        WareHouse.WSPrintPidPrev(g_PID, Globals.theWinlogon, lbItemNo.Text, lbPhysQty.Text, lbExpiredate.Text, lbVendorLot.Text, lbUnitOfMesure.Text);
                    }
                    WareHouse.Dispose();
                }
                break;

                case 6:
                {
                    // Bekræft et evt P-ID
                    if (b_confirmPid)
                    {
                        if (g_PID != tbInputData.Text)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message2"));
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                            break;
                        }
                    }
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

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

                    try
                    {
                        if (!WareHouse.WSLotInfoExists(lbItemNo.Text, tbInputData.Text, lbVendorLot.Text))
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message2"));
                            tbInputData.Focus();
                            tbInputData.SelectAll();
                            break;
                        }
                        lot = tbInputData.Text;
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText9");
                        tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                        Globals.step++;
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                    }
                }
                break;

                case 7:
                {
                    // Bogføring
                    Posting();
                }
                break;
                }
            }
            #region ESC_KEY
            if ((e.KeyChar == (char)Keys.Escape) || (e.KeyChar == (char)Keys.Tab))
            {
                switch (Globals.step)
                {
                case 6:
                {
                    Globals.step--;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText8");
                    tbInputData.Text  = "";
                }
                break;

                case 5:
                {
                    if (!b_NewPID)
                    {
                        Globals.step       = 0;
                        lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "lblInputText1");
                        tbInputData.Text   = "";
                        b_NewPID           = false;
                        b_confirmPid       = false;
                        tbInputData.Text   = "";
                        lbLocation.Text    = "";
                        lbBin.Text         = "";
                        lbItemNo.Text      = "";
                        lbDescription.Text = "";
                        lbQuantity.Text    = "";
                        lbExpiredate.Text  = "";
                        lbPID.Text         = "";
                        lbVendorLot.Text   = "";
                    }
                    else
                    {
                        Globals.step--;
                        lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText7");
                        tbInputData.Text  = "";
                    }
                }
                break;

                case 4:
                {
                    Globals.step--;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText5");
                    tbInputData.Mask  = mt.ReadResFile(this.Name.ToString() + "DataMask");
                }
                break;

                case 3:
                {
                    Globals.step--;
                    tbInputData.Mask  = "";
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText4");
                }
                break;

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

                case 1:
                {
                    this.Close();
                }
                break;

                case 0: this.Close();
                    break;
                }
            }
            #endregion
        }
Ejemplo n.º 6
0
        private void tbInputData_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (Globals.GlobalStep)
                {
                case 0:
                    break;

                case 1:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

                    if (!WareHouse.WSBinExists(lbNewLocation.Text, tbInputData.Text))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Error2"));
                        tbInputData.SelectAll();
                        break;
                    }

                    BinContentTool btool = new BinContentTool();
                    ChangeStdBin = false;
                    if (!btool.BinIsDefault(Globals.theLocation, tbInputData.Text, "", "") && (lbStdBin.Text != tbInputData.Text))
                    {
                        if (MessageBox.Show(string.Format("Skal standard placering skiftes fra {0} til {1}?", lbStdBin.Text, lbNewBinCode.Text), "Skift standard placering", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            if (MessageBox.Show(string.Format("Er du sikker på at du vil skiftes fra {0} til {1}?", lbStdBin.Text, lbNewBinCode.Text), "Advarsel! Skifter standard placering", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                            {
                                ChangeStdBin = true;
                            }
                        }
                    }

                    lbNewBinCode.Text = tbInputData.Text;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText4");
                    tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "lblInputText5");
                    Globals.step++;
                }
                break;

                case 2:
                {
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;

                    this.pbIndicator.Image   = WindowsFormsApplication1.Properties.Resources.animatedCircle;
                    this.pbIndicator.Visible = true;

                    try
                    {
                        if (ChangeStdBin)
                        {
                            WareHouse.WSSetDefaultBin(Globals.theLocation, lbStdBin.Text, lbItemNo.Text, lbUnitOfMesure.Text, false);
                        }

                        WareHouse.WSPostTransfer(Globals.theTransferTemplateName, Globals.theTransferBatchName, lbItemNo.Text.ToString(), lbUnitOfMesure.Text, Globals.theWinlogon, lbLocation.Text.ToString(), lbBin.Text.ToString(), lot.ToString(), lbNewLocation.Text.ToString(), lbNewBinCode.Text.ToString(), lot.ToString(), decimal.Parse(lbQuantity.Text.ToString()), false, DateTime.Parse(lbExpiredate.Text.ToString()), DateTime.Now, 0);

                        if (ChangeStdBin)
                        {
                            WareHouse.WSSetDefaultBin(Globals.theLocation, lbNewBinCode.Text, lbItemNo.Text, lbUnitOfMesure.Text, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.pbIndicator.Image   = null;
                        this.pbIndicator.Visible = false;

                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        this.Close();
                    }
                }
                break;
                }
            }

            if ((e.KeyChar == (char)Keys.Escape) || (e.KeyChar == (char)Keys.Tab))
            {
                switch (Globals.step)
                {
                case 2:
                {
                    Globals.step--;
                    tbInputData.Text  = "";
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "lblInputText2");;
                }
                break;

                case 1:
                {
                    Globals.step = 0;
                    this.Close();
                }
                break;

                case 0:
                {
                    Globals.step = 0;
                    this.Close();
                }
                break;
                }
            }
        }
Ejemplo n.º 7
0
        private void tbInputData_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (Globals.GlobalStep)
                {
                case 0:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }

                    pickorder = tbInputData.Text;

                    if (GetWhseActivityHeader() > 0)
                    {
                        ExtractHeaderData();

                        if (GetWhseActivityLines() > 0)
                        {
                            WhaLineIndex = 0;

                            ExtractLineData();
                            Globals.step++;
                            tbInputData.Text  = "";
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText2");
                        }
                        else
                        {
                            tbInputData.Text = "";
                            MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message2"));
                        }
                    }
                    else
                    {
                        tbInputData.Text = "";
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message1"));
                    }
                }
                break;

                case 1:
                {
                    ItemTool it = new ItemTool();

                    if (it.ReturnItemNo(tbInputData.Text) == lbItemNo.Text)
                    {
                        string local_bin = "";
                        //string local_itemno = "";
                        //string local_uom = "";
                        //string local_vendor = "";
                        //string local_desc = "";
                        DateTime local_mhd      = DateTime.Now;
                        DateTime localRegDate   = DateTime.Now;
                        decimal  local_qty      = 0;
                        int      local_appentry = 0;

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

                        try
                        {
                            //if (WareHouse.WSReturnLotInfo(tbInputData.Text, WhaHeader.theLocation, ref local_bin, ref local_itemno, ref local_desc, ref local_qty, ref local_mhd, ref local_uom, ref local_vendor))
                            //{

                            //}
                            if (WareHouse.WSReturnMhdAndBinFromLot(tbInputData.Text, WhaLine.theItemNo, WhaHeader.theLocation, ref local_bin, ref local_mhd, ref local_qty, ref local_appentry, ref localRegDate))
                            {
                                WhaLine.theBin    = local_bin;
                                WhaLine.theLotNo  = tbInputData.Text;
                                lbQty.Text        = local_qty.ToString();
                                lbLotNo.Text      = tbInputData.Text;
                                lbBincode.Text    = local_bin;
                                lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");

                                if (local_qty <= decimal.Parse(lbQuantity.Text))
                                {
                                    tbInputData.Text = local_qty.ToString();
                                }
                                else
                                {
                                    tbInputData.Text = lbQuantity.Text;
                                }
                                tbInputData.SelectAll();
                                Globals.step++;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                        }
                    }
                    else
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(mt.ReadResFile(this.Name.ToString() + "Message3"));
                        tbInputData.Text = "";
                    }
                }
                break;

                case 2:
                {
                    // Antals funktion ved P-ID

                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }
                    btnNext.Enabled    = false;
                    btnPrevius.Enabled = false;
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    WhaLine = WarehouseActivityLineList.ElementAt(WhaLineIndex);
                    try
                    {
                        decimal d = 0;
                        if (!decimal.TryParse(tbInputData.Text, out d))
                        {
                            break;
                        }
                        lbQuantity.Text = WareHouse.WSReturnRemaningQtyPickorder(WhaLine.theNo, WhaLine.theLineNo).ToString(CultureInfo.GetCultureInfo(Globals.theLanguageCode).NumberFormat);
                        if (d >= decimal.Parse(tbInputData.Text))
                        {
                            WhaLine.theQtyToHandle = decimal.Parse(tbInputData.Text);
                            lbQty.Text             = tbInputData.Text;
                            WarehouseActivityLineList.Insert(WhaLineIndex, WhaLine);
                            WarehouseActivityLineList.RemoveAt(WhaLineIndex + 1);
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                            tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                            Globals.step      = 10;
                        }
                        else
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Message4"), lbQuantity.Text),
                                                                   mt.ReadResFile(this.Name.ToString() + "Message4Caption"));
                            tbInputData.SelectAll();
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                    }
                }
                break;

                case 3:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }
                    btnNext.Enabled    = false;
                    btnPrevius.Enabled = false;

                    WhaLine = WarehouseActivityLineList.ElementAt(WhaLineIndex);

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

                    if (Warehouse.WSGetItemCrossRef(tbInputData.Text.ToUpper()) != lbItemNo.Text)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox("Forkert Varenummer!");
                        tbInputData.SelectAll();
                        break;
                    }
                    Globals.GlobalStep++;

                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText6");
                    tbInputData.Text  = "";
                }
                break;

                case 4:
                {
                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }

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

                    if (!Warehouse.WSBinExists(Globals.theLocation, tbInputData.Text.ToUpper()))
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(string.Format("Placeringen {0} findes ikke", tbInputData.Text));
                        tbInputData.Text = "";
                        break;
                    }

                    BinContentTool bt    = new BinContentTool();
                    decimal        l_qty = 0;
                    string         l_uom = "";

                    if (bt.GetItemBincontent(Globals.theLocation, tbInputData.Text, lbItemNo.Text, ref l_qty, ref l_uom))
                    {
                        lbQty.Text     = l_qty.ToString("N2");
                        lbUnit.Text    = l_uom;
                        lbBincode.Text = tbInputData.Text.ToUpper();
                    }

                    if (l_qty == 0)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(string.Format("Placeringen {0} indeholder ikke varen: {1}", tbInputData.Text.ToUpper(), lbItemNo.Text));
                        tbInputData.Text = "";
                        break;
                    }

                    if (l_qty <= decimal.Parse(lbQuantity.Text))
                    {
                        tbInputData.Text = l_qty.ToString();
                    }
                    else
                    {
                        tbInputData.Text = lbQuantity.Text;
                    }

                    Globals.GlobalStep++;
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");
                    //tbInputData.Text = "";
                }
                break;

                case 5:
                {
                    // Antalsfunktion uden P-ID

                    if (tbInputData.Text.Equals(""))
                    {
                        break;
                    }

                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    try
                    {
                        decimal d = 0;
                        if (!decimal.TryParse(tbInputData.Text, out d))
                        {
                            break;
                        }
                        lbQuantity.Text = WareHouse.WSReturnRemaningQtyPickorder(WhaLine.theNo, WhaLine.theLineNo).ToString(CultureInfo.GetCultureInfo(Globals.theLanguageCode).NumberFormat);
                        if (d <= decimal.Parse(lbQuantity.Text))
                        {
                            WhaLine.theQtyToHandle = decimal.Parse(tbInputData.Text);
                            lbQty.Text             = tbInputData.Text;
                            WhaLine.theLotNo       = "";
                            WarehouseActivityLineList.Insert(WhaLineIndex, WhaLine);
                            WarehouseActivityLineList.RemoveAt(WhaLineIndex + 1);
                            lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText4");
                            tbInputData.Text  = mt.ReadResFile(this.Name.ToString() + "TextBox1");
                            Globals.step      = 10;
                        }
                        else
                        {
                            MessageBoxExample.MyMessageBox.ShowBox(string.Format(mt.ReadResFile(this.Name.ToString() + "Message4"), lbQuantity.Text),
                                                                   mt.ReadResFile(this.Name.ToString() + "Message4Caption"));
                            tbInputData.SelectAll();
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                    }
                }
                break;

                case 10:
                {
                    // CallFunction in Navision To post the Pick" and "Place" line
                    BalanceWarehouse WareHouse = new BalanceWarehouse();
                    WareHouse.UseDefaultCredentials = true;
                    //WhaLine = WarehouseActivityLineList.ElementAt(WhaLineIndex);

                    this.pbIndicator.Image   = WindowsFormsApplication1.Properties.Resources.animatedCircle;
                    this.pbIndicator.Visible = true;

                    try
                    {
                        if (lbBincode.Text != WhaLine.theBin)
                        {
                            WhaLine.theBin = lbBincode.Text;
                        }
                        WareHouse.WSPostPickOrder(WhaLine.theNo, WhaLine.theLineNo, WhaLine.theSourceLineNo, WhaLine.theItemNo, WhaLine.theQtyToHandle, WhaLine.theLotNo, WhaLine.theBin);
                    }
                    catch (Exception ex)
                    {
                        this.pbIndicator.Image   = null;
                        this.pbIndicator.Visible = false;

                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }

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

                    try
                    {
                        lbQuantity.Text = WareHouse.WSReturnRemaningQtyPickorder(WhaLine.theNo, WhaLine.theLineNo).ToString(CultureInfo.GetCultureInfo(Globals.theLanguageCode).NumberFormat);
                    }
                    catch (Exception ex)
                    {
                        this.pbIndicator.Image   = null;
                        this.pbIndicator.Visible = false;

                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }

                    try
                    {
                        //WareHouse.WSDeleteQtyToHandle(WhaLine.theNo.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                    finally
                    {
                        WareHouse.Dispose();
                    }

                    if (decimal.Parse(lbQuantity.Text) > 0)
                    {
                        if (UseTracking)
                        {
                            Globals.GlobalStep = 1;
                            lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText2");
                            tbInputData.Text   = "";
                        }
                        else
                        {
                            Globals.GlobalStep = 3;
                            lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText5");
                            tbInputData.Text   = "";
                        }
                        btnNext.Enabled    = true;
                        btnPrevius.Enabled = true;
                    }
                    else
                    {
                        // Funktionalitet til at finde næste pluklinje der skal plukkes eller afslutte hvis der ikke er flere.
                        WarehouseActivityLineList.RemoveAt(WhaLineIndex);
                        if (WhaLineIndex > 0)
                        {
                            WhaLineIndex--;
                        }
                        NoOfLines--;
                        lbLines.Text = string.Format("{0} af {1}", 1, NoOfLines.ToString());

                        if (WarehouseActivityLineList.Count() > 1)
                        {
                            ExtractLineData();
                            lbQty.Text = "";

                            if (WhaLine.theQtyOutstanding <= 0)
                            {
                                tbInputData.Enabled = false;
                            }
                            else
                            {
                                tbInputData.Enabled = true;
                            }

                            btnNext.Enabled    = true;
                            btnPrevius.Enabled = true;
                        }
                        if (WarehouseActivityLineList.Count() == 1)
                        {
                            ExtractLineData();
                            lbQty.Text = "";

                            if (WhaLine.theQtyOutstanding <= 0)
                            {
                                tbInputData.Enabled = false;
                            }
                            else
                            {
                                tbInputData.Enabled = true;
                            }
                        }
                        if ((WhaLineIndex == 0) && (WhaLineIndex == WarehouseActivityLineList.Count()))
                        {
                            fmWarehouseFright wf = new fmWarehouseFright(Warehouseshipmentno);
                            wf.ShowDialog();

                            Globals.step = 0;
                            this.Close();
                        }
                    }
                }
                break;
                }
            }

            if ((e.KeyChar == (char)Keys.Escape) || (e.KeyChar == (char)Keys.Tab))
            {
                switch (Globals.step)
                {
                case 10:
                {
                    if (UseTracking)
                    {
                        Globals.GlobalStep = 2;
                        lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");
                        tbInputData.Text   = "";
                    }
                    else
                    {
                        Globals.GlobalStep = 5;
                        lblInputText.Text  = mt.ReadResFile(this.Name.ToString() + "LabelInputText3");
                        tbInputData.Text   = "";
                    }
                }
                break;

                case 5:
                {
                    Globals.step--;
                    //lblInputText3
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText6");
                    tbInputData.Text  = "";
                }
                break;

                case 4:
                {
                    Globals.step--;
                    //lblInputText3
                    lblInputText.Text = mt.ReadResFile(this.Name.ToString() + "LabelInputText5");
                    tbInputData.Text  = "";
                }
                break;

                case 3:
                {
                    Globals.step = 0;
                    this.Close();
                }
                break;

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

                case 1:
                {
                    Globals.step = 0;
                    this.Close();
                }
                break;

                case 0:
                {
                    Globals.step = 0;
                    this.Close();
                }
                break;
                }
            }
        }