Ejemplo n.º 1
0
        public FindInventoryLocationByPartIDDataSet FindInventoryLocationByPartID(int intPartID, int intWarehouseID)
        {
            try
            {
                aFindInventoryLocationByPartIDDataSet      = new FindInventoryLocationByPartIDDataSet();
                aFindInventoryLocationByPartIDTableAdapter = new FindInventoryLocationByPartIDDataSetTableAdapters.FindInventoryLocationByPartIDTableAdapter();
                aFindInventoryLocationByPartIDTableAdapter.Fill(aFindInventoryLocationByPartIDDataSet.FindInventoryLocationByPartID, intPartID, intWarehouseID);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Find Inventory Location By Part ID " + Ex.Message);
            }

            return(aFindInventoryLocationByPartIDDataSet);
        }
Ejemplo n.º 2
0
        private void expUpdateCounts_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            bool     blnFatalError = false;
            int      intPartID;
            int      intOldCount;
            int      intNewCount;
            string   strLocation;
            string   strPartNumber;
            string   strPartDescription;
            int      intRecordsReturned;
            string   strJDEPartNumber;
            int      intTransactionID;
            int      intSecondCounter;
            int      intSecondNumberOfRecords;
            bool     blnItemFound;
            DateTime datStartDate = DateTime.Now;
            DateTime datEndDate;

            try
            {
                blnFatalError = TheInventoryClass.ClearWarehouseInventory(MainWindow.gintWarehouseID);

                if (blnFatalError == true)
                {
                    throw new Exception();
                }

                datStartDate = TheDateSearchClass.RemoveTime(datStartDate);
                datEndDate   = TheDateSearchClass.AddingDays(datStartDate, 1);

                blnFatalError = TheInventoryImportClass.RemoveInventoryImport(MainWindow.gintWarehouseID, datStartDate, datEndDate);

                if (blnFatalError == true)
                {
                    throw new Exception();
                }

                intNumberOfRecords = TheImportInventoryDataSet.importinventory.Rows.Count;

                for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                {
                    intPartID          = TheImportInventoryDataSet.importinventory[intCounter].PartID;
                    intOldCount        = TheImportInventoryDataSet.importinventory[intCounter].OldCount;
                    intNewCount        = TheImportInventoryDataSet.importinventory[intCounter].CurrentCount;
                    strLocation        = TheImportInventoryDataSet.importinventory[intCounter].Location;
                    strPartNumber      = TheImportInventoryDataSet.importinventory[intCounter].PartNumber;
                    strPartDescription = TheImportInventoryDataSet.importinventory[intCounter].PartDescription;
                    strJDEPartNumber   = TheImportInventoryDataSet.importinventory[intCounter].JDEPartNumber;

                    if (intPartID < 1)
                    {
                        TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                        intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                        }
                        else if (intRecordsReturned < 1)
                        {
                            intPartID = intCounter * -1;

                            blnFatalError = ThePartNumberClass.InsertPartIntoPartNumbers(intPartID, strPartNumber, strJDEPartNumber, strPartDescription, 0);

                            if (blnFatalError == true)
                            {
                                throw new Exception();
                            }

                            TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                            intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                        }
                    }
                    else if (intPartID > 0)
                    {
                        TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(intPartID);

                        intRecordsReturned = TheFindPartByPartIDDataSet.FindPartByPartID.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            if (strPartNumber != TheFindPartByPartIDDataSet.FindPartByPartID[0].PartNumber)
                            {
                                TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                                intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count;

                                if (intRecordsReturned > 0)
                                {
                                    intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                                }
                                else if (intRecordsReturned < 1)
                                {
                                    intPartID = intCounter * -1;

                                    blnFatalError = ThePartNumberClass.InsertPartIntoPartNumbers(intPartID, strPartNumber, strJDEPartNumber, strPartDescription, 0);

                                    if (blnFatalError == true)
                                    {
                                        throw new Exception();
                                    }

                                    TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                                    intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                                }
                            }
                        }
                        else if (intRecordsReturned < 1)
                        {
                            TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                            intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                            }
                            else if (intRecordsReturned < 1)
                            {
                                intPartID = intCounter * -1;

                                blnFatalError = ThePartNumberClass.InsertPartIntoPartNumbers(intPartID, strPartNumber, strJDEPartNumber, strPartDescription, 0);

                                if (blnFatalError == true)
                                {
                                    throw new Exception();
                                }

                                TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber);

                                intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID;
                            }
                        }
                    }

                    TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, MainWindow.gintWarehouseID);

                    intRecordsReturned = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError = TheInventoryClass.InsertInventoryPart(intPartID, intNewCount, MainWindow.gintWarehouseID);

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }
                    else if (intRecordsReturned > 0)
                    {
                        intTransactionID = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].TransactionID;

                        blnFatalError = TheInventoryClass.UpdateInventoryPart(intTransactionID, intNewCount);

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }

                    //inserting inventory location
                    TheFindInventoryLocationByPartIDDataSet = TheMaterialSheetsClass.FindInventoryLocationByPartID(intPartID, MainWindow.gintWarehouseID);

                    intSecondNumberOfRecords = TheFindInventoryLocationByPartIDDataSet.FindInventoryLocationByPartID.Rows.Count;
                    blnItemFound             = false;

                    if (intSecondNumberOfRecords > 0)
                    {
                        for (intSecondCounter = 0; intSecondCounter < intSecondNumberOfRecords; intSecondCounter++)
                        {
                            if (strLocation == TheFindInventoryLocationByPartIDDataSet.FindInventoryLocationByPartID[intSecondCounter].PartLocation)
                            {
                                blnItemFound = true;
                            }
                        }
                    }

                    if (blnItemFound == false)
                    {
                        blnFatalError = TheMaterialSheetsClass.InsertInventoryLocation(intPartID, MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, DateTime.Now, strLocation, MainWindow.gintWarehouseID);

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }

                    //adding to inventory sheet
                    blnFatalError = TheInventoryImportClass.InsertInventoryImport(MainWindow.gintWarehouseID, intPartID, strLocation, intOldCount, intNewCount, DateTime.Now);

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }

                TheMessagesClass.InformationMessage("All Parts Added");
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Inventory // Update Counts Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }