private bool UpdateInventoryInfo(int intPartID, int intWarehouseID, int intQuantity) { bool blnFatalError = false; int intRecordsReturned; int intTransactionID; int intTotalQuantity; try { TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, intWarehouseID); intRecordsReturned = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsReturned == 0) { blnFatalError = TheInventoryClass.InsertInventoryPart(intPartID, intQuantity, intWarehouseID); if (blnFatalError == true) { TheMessagesClass.ErrorMessage("There Has Been A Problem, Contact ID"); return(blnFatalError); } } else if (intRecordsReturned == 1) { intTransactionID = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].TransactionID; intTotalQuantity = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity + intQuantity; blnFatalError = TheInventoryClass.UpdateInventoryPart(intTransactionID, intTotalQuantity); if (blnFatalError == true) { TheMessagesClass.ErrorMessage("There Has Been A Problem, Contact ID"); return(blnFatalError); } } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Process Patch Class // Update Inventory Info " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); blnFatalError = true; } return(blnFatalError); }
private void AddSaveRecord() { //setting local variables string strPartNumber; string strProject; int intPartID = 0; string strMSRNumber = "NOT REQUIRED"; string strValueForValidation; int intQuantity = 0; bool blnThereIsAProblem = false; bool blnFatalError = false; string strErrorMessage = ""; int intRecordsFound; bool blnProjectNotFound = false; bool blnPartNotFound = true; bool blnKeyWordNotFound; int intTotalQuantity; int intProjectID = 0; string strJDEPartNumber = ""; int intEmployeeID = 0; int intEnterEmployeeID = 0; try { if (btnAdd.Content.ToString() == "Add") { //loading controls txtDateEntryComplete.Text = "NO"; txtDate.Text = Convert.ToString(DateTime.Now); btnAdd.Content = "Save"; } else { if (MainWindow.gstrMenuSelection == "Issue") { if (cboSelectEmployee.SelectedIndex < 1) { blnFatalError = true; strErrorMessage += "Employee Was Not Selected\n"; } } //data validation strProject = txtProjectID.Text; if (strProject == "") { blnFatalError = true; strErrorMessage += "Project ID Was Not Entered\n"; } else { TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strProject); intRecordsFound = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID.Rows.Count; if (intRecordsFound == 0) { TheFindProjectByProjectNameDataSet = TheProjectClass.FindProjectByProjectName(strProject); intRecordsFound = TheFindProjectByProjectNameDataSet.FindProjectByProjectName.Rows.Count; if (intRecordsFound == 0) { blnThereIsAProblem = TheDataValidationClass.VerifyIntegerData(strProject); if (blnThereIsAProblem == true) { blnProjectNotFound = true; } else { TheFindProjectByProjectIDDataSet = TheProjectClass.FindProjectByProjectID(Convert.ToInt32(strProject)); intRecordsFound = TheFindProjectByProjectIDDataSet.FindProjectByProjectID.Rows.Count; if (intRecordsFound == 0) { blnProjectNotFound = true; } else { intProjectID = TheFindProjectByProjectIDDataSet.FindProjectByProjectID[0].ProjectID; strProject = TheFindProjectByProjectIDDataSet.FindProjectByProjectID[0].AssignedProjectID; } } } else { strProject = TheFindProjectByProjectNameDataSet.FindProjectByProjectName[0].AssignedProjectID; intProjectID = TheFindProjectByProjectNameDataSet.FindProjectByProjectName[0].ProjectID; } } else { intProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID; } if (blnProjectNotFound == true) { blnFatalError = true; strErrorMessage += "Project Was Not Found\n"; } } if (MainWindow.gstrMenuSelection == "Receive") { strMSRNumber = txtMSRPONumber.Text; if (strMSRNumber == "") { blnFatalError = true; strErrorMessage += "MSR or PO Number Was Not Entered\n"; } else if (strMSRNumber == "NO MSR NUMBER PROVIDED") { blnFatalError = true; strErrorMessage += "NO MSR NUMBER PROVIDED Cannot Be Entered\n"; } } strPartNumber = txtPartNumber.Text; if (strPartNumber == "") { blnFatalError = true; strErrorMessage += "Part Number Was Not Entered\n"; } else { blnPartNotFound = true; blnThereIsAProblem = TheDataValidationClass.VerifyIntegerData(strPartNumber); if (blnThereIsAProblem == false) { intPartID = Convert.ToInt32(strPartNumber); TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(intPartID); intRecordsFound = TheFindPartByPartIDDataSet.FindPartByPartID.Rows.Count; if (intRecordsFound == 1) { blnPartNotFound = false; strPartNumber = TheFindPartByPartIDDataSet.FindPartByPartID[0].PartNumber; strJDEPartNumber = TheFindPartByPartIDDataSet.FindPartByPartID[0].JDEPartNumber; } } if (blnPartNotFound == true) { TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber); intRecordsFound = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count; if (intRecordsFound == 1) { blnPartNotFound = false; intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID; strJDEPartNumber = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].JDEPartNumber; } if (blnPartNotFound == true) { TheFindPartByJDEPartNumber = ThePartNumberClass.FindPartByJDEPartNumber(strPartNumber); intRecordsFound = TheFindPartByJDEPartNumber.FindPartByJDEPartNumber.Rows.Count; if (intRecordsFound == 1) { blnPartNotFound = false; intPartID = TheFindPartByJDEPartNumber.FindPartByJDEPartNumber[0].PartID; strPartNumber = TheFindPartByJDEPartNumber.FindPartByJDEPartNumber[0].PartNumber; strJDEPartNumber = TheFindPartByJDEPartNumber.FindPartByJDEPartNumber[0].JDEPartNumber; } } } if (MainWindow.gstrWarehouseName != "TRAINING") { //checking to see if non charter number blnKeyWordNotFound = TheKeyWordClass.FindKeyWord("JH", MainWindow.gstrWarehouseName); if (blnKeyWordNotFound == true) { if (strJDEPartNumber == "NOT REQUIRED") { blnFatalError = true; strErrorMessage += "Using Non Charter Part Number for Charter Warehouse\n"; } if (strJDEPartNumber == "NOT PROVIDED") { blnFatalError = true; strErrorMessage += "Using Non Charter Part Number for Charter Warehouse\n"; } } } if (blnPartNotFound == true) { blnFatalError = true; strErrorMessage += "Part Number Not Found\n"; } } //validating the Quantity strValueForValidation = txtQuantity.Text; blnThereIsAProblem = TheDataValidationClass.VerifyIntegerData(strValueForValidation); if (blnThereIsAProblem == true) { blnFatalError = true; strErrorMessage += "The Quantity Entered is not an Integer\n"; } else { intQuantity = Convert.ToInt32(strValueForValidation); } if (blnFatalError == true) { TheMessagesClass.ErrorMessage(strErrorMessage); return; } //checking quantity for issuing if (MainWindow.gstrMenuSelection == "Issue") { TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, MainWindow.gintWarehouseID); intRecordsFound = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsFound == 0) { intTotalQuantity = 0; } else { intTotalQuantity = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity; } intTotalQuantity = CalculateWIPCount(intPartID, MainWindow.gintWarehouseID, intTotalQuantity); if (intQuantity > intTotalQuantity) { TheMessagesClass.ErrorMessage("The Quantity Issued is greater than the Quantity On The Shelf"); return; } } if (MainWindow.gstrMenuSelection == "Issue") { intEmployeeID = gintSelectedEmployeeID; intEnterEmployeeID = MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID; } else { intEmployeeID = MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID; } blnFatalError = TheInventoryWIPClass.InsertDataEntryWIP(MainWindow.gintSessionID, intPartID, strPartNumber, intProjectID, strProject, strMSRNumber, MainWindow.gintWarehouseID, intQuantity, intEmployeeID, MainWindow.gstrMenuSelection.ToUpper()); if (blnFatalError == true) { TheMessagesClass.ErrorMessage("There Has Been A Problem. Contact IT"); return; } ClearControls(); } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Enter Inventory \\ Enter Material \\ Add Button During Save " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { string strPartNumber; bool blnIsNotInteger = false; int intRecordsReturned; bool blnItemFound = false; strPartNumber = txtEnterPartNumber.Text; if (strPartNumber == "") { TheMessagesClass.ErrorMessage("Part Number Was Not Added"); return; } blnIsNotInteger = TheDataValidationClass.VerifyIntegerData(strPartNumber); if (blnIsNotInteger == false) { MainWindow.gintPartID = Convert.ToInt32(strPartNumber); TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(MainWindow.gintPartID); intRecordsReturned = TheFindPartByPartIDDataSet.FindPartByPartID.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; } } if (blnItemFound == false) { TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber); intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; MainWindow.gintPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID; } if (blnItemFound == false) { TheFindPartByJDEPartNumberDataSet = ThePartNumberClass.FindPartByJDEPartNumber(strPartNumber); intRecordsReturned = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; MainWindow.gintPartID = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartID; } } } if (blnItemFound == false) { TheMessagesClass.ErrorMessage("Part Information Does Not Exist"); return; } blnItemFound = false; TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(MainWindow.gintPartID, MainWindow.gintWarehouseID); intRecordsReturned = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsReturned == 0) { TheMessagesClass.ErrorMessage("No Information for this Part, You Cannoot Change The Count"); return; } else { txtCurrentCount.Text = Convert.ToString(TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity); gintTransactionID = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].TransactionID; } btnUpdate.IsEnabled = true; }
private void btnFind_Click(object sender, RoutedEventArgs e) { //setting local variables string strValueForValidation; string strErrorMessage = ""; bool blnThereIsAProblem = false; bool blnFatalError = false; int intSelectedIndex; int intRecordsReturned; string strPartDescription; try { intSelectedIndex = cboSendingWarehouse.SelectedIndex; if (intSelectedIndex < 1) { blnFatalError = true; strErrorMessage += "Sending Warehouse Not Selected\n"; } MainWindow.gstrPartNumber = txtEnterPartNumber.Text; if (MainWindow.gstrPartNumber == "") { blnFatalError = true; strErrorMessage += "Part Number Was Not Entered\n"; } strValueForValidation = txtEnterQuantity.Text; blnThereIsAProblem = TheDataValidationClass.VerifyIntegerData(strValueForValidation); if (blnThereIsAProblem == true) { blnFatalError = true; strErrorMessage += "Quantity is not an Integer\n"; } else { gintQuantity = Convert.ToInt32(strValueForValidation); } if (blnFatalError == true) { TheMessagesClass.ErrorMessage(strErrorMessage); return; } TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(MainWindow.gstrPartNumber); intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count; if (intRecordsReturned == 0) { TheFindPartByJDEPartNumberDataSet = ThePartNumberClass.FindPartByJDEPartNumber(MainWindow.gstrPartNumber); intRecordsReturned = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber.Rows.Count; if (intRecordsReturned == 0) { TheMessagesClass.InformationMessage("Part Number Was Not Found"); return; } else { MainWindow.gintPartID = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartID; strPartDescription = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartDescription; } } else { MainWindow.gintPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID; strPartDescription = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartDescription; } TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(MainWindow.gintPartID, gintSendingWarehouseID); intRecordsReturned = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsReturned == 0) { TheMessagesClass.InformationMessage("The Part in this Warehouse Does Not Exist"); return; } else if (gintQuantity > TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity) { TheMessagesClass.ErrorMessage("Quantity Transfered Cannot Be Greater that Warehouse Quantity"); return; } else { txtPartDescription.Text = strPartDescription; gintSendingTransactionID = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].TransactionID; gintSendingQuantity = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity; } cboReceivingWarehouse.IsEnabled = true; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Transfer Inventory // Find Button " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void btnVoidTransactions_Click(object sender, RoutedEventArgs e) { int intCounter; int intNumberOfRecords; int intPartID; int intWarehouseID; int intTransactionID; int intQuantity; int intWarehouseQuantity; int intWarehouseTransactionID; bool blnFatalError = false; string strTransactionNotes; try { intNumberOfRecords = TheMaterialIssuedDataSet.materialissued.Rows.Count; if (txtTransactionNotes.Text.Length < 25) { TheMessagesClass.ErrorMessage("The Notes is not Long Enough"); return; } strTransactionNotes = MainWindow.gstrAssignedProjectID + " " + txtTransactionNotes.Text; if (intNumberOfRecords > 0) { for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { if (TheMaterialIssuedDataSet.materialissued[intCounter].VoidTransaction == true) { intPartID = TheMaterialIssuedDataSet.materialissued[intCounter].PartID; intWarehouseID = TheMaterialIssuedDataSet.materialissued[intCounter].WarehouseID; intQuantity = TheMaterialIssuedDataSet.materialissued[intCounter].Quantity; intTransactionID = TheMaterialIssuedDataSet.materialissued[intCounter].TransactionID; TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, intWarehouseID); intWarehouseQuantity = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity; intWarehouseTransactionID = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].TransactionID; intWarehouseQuantity = intWarehouseQuantity - intQuantity; blnFatalError = TheInventoryClass.UpdateInventoryPart(intWarehouseTransactionID, intWarehouseQuantity); if (blnFatalError == true) { throw new Exception(); } blnFatalError = TheIssuedPartsClass.UpdateIssuedParts(intTransactionID, 0); if (blnFatalError == true) { throw new Exception(); } } } blnFatalError = TheEmployeeDateEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, strTransactionNotes); if (blnFatalError == true) { throw new Exception(); } TheEventLogClass.InsertEventLogEntry(DateTime.Now, strTransactionNotes); TheMessagesClass.InformationMessage("The Transactions Have Been Voided"); ResetControls(); } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Void Inventory Transaction // Void Transactions Button " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void expImportExcel_Expanded(object sender, RoutedEventArgs e) { Excel.Application xlDropOrder; Excel.Workbook xlDropBook; Excel.Worksheet xlDropSheet; Excel.Range range; int intColumnRange = 0; int intCounter; int intNumberOfRecords; string strPartNumber; string strJDEPartNumber; int intPartID = 0; string strPartDescription; int intQuantity = 0; int intRecordsReturned; bool blnItemFound; bool blnItemInTable; bool blnFatalError = false; int intSecondCounter; string strOldPartNumber = ""; try { expImportExcel.IsExpanded = false; blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Create Spectrum Report // Import Spectrum Count"); if (blnFatalError == true) { throw new Exception(); } if (cboSelectWarehouse.SelectedIndex < 1) { TheMessagesClass.ErrorMessage("The Warehouse Was Not Selected"); return; } TheSpectrumCountDataSet.spectrumcount.Rows.Clear(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".xlsx"; // Default file extension dlg.Filter = "Excel (.xlsx)|*.xlsx"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; } PleaseWait PleaseWait = new PleaseWait(); PleaseWait.Show(); xlDropOrder = new Excel.Application(); xlDropBook = xlDropOrder.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlDropSheet = (Excel.Worksheet)xlDropOrder.Worksheets.get_Item(1); range = xlDropSheet.UsedRange; intNumberOfRecords = range.Rows.Count; intColumnRange = range.Columns.Count; gintCounter = 0; gintNumberOfRecords = 0; for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++) { blnItemFound = false; strPartNumber = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper(); strJDEPartNumber = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper(); strPartDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper(); TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber); intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count; if (intRecordsReturned > 0) { intPartID = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID; strJDEPartNumber = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].JDEPartNumber; blnItemFound = true; } else if (intRecordsReturned < 1) { TheFindPartByJDEPartNUmberDataSet = ThePartNumberClass.FindPartByJDEPartNumber(strJDEPartNumber); intRecordsReturned = TheFindPartByJDEPartNUmberDataSet.FindPartByJDEPartNumber.Rows.Count; if (intRecordsReturned > 0) { strPartNumber = TheFindPartByJDEPartNUmberDataSet.FindPartByJDEPartNumber[0].PartNumber; intPartID = TheFindPartByJDEPartNUmberDataSet.FindPartByJDEPartNumber[0].PartID; blnItemFound = true; } else if (intRecordsReturned < 1) { if (strPartNumber == "NONE") { SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = 0; NewPartCount.JDEPartNumber = strPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intCounter * -1; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = "UNKNOWN"; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } } } if (blnItemFound == true) { TheFindWarehouseInventoryByPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, MainWindow.gintWarehouseID); intRecordsReturned = TheFindWarehouseInventoryByPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsReturned > 0) { blnItemInTable = false; if (gintCounter > 0) { for (intSecondCounter = 0; intSecondCounter <= gintNumberOfRecords; intSecondCounter++) { if (intPartID == TheSpectrumCountDataSet.spectrumcount[intSecondCounter].PartID) { blnItemInTable = true; } } } if (blnItemInTable == false) { intQuantity = TheFindWarehouseInventoryByPartDataSet.FindWarehouseInventoryPart[0].Quantity; TheFindMasterPartByPartIDDataSet = ThePartNumberClass.FindMasterPartByPartID(intPartID); intRecordsReturned = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID.Rows.Count; if (intRecordsReturned > 0) { strOldPartNumber = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID[0].PartNumber; } else { strOldPartNumber = "NOT FOUND"; } SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = intQuantity; NewPartCount.JDEPartNumber = strJDEPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intPartID; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = strOldPartNumber; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } } else if (intRecordsReturned < 1) { if (strPartDescription.Contains("CABLE RG6") == true) { SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = 0; NewPartCount.JDEPartNumber = strJDEPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intPartID; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = strOldPartNumber; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } else if (strPartDescription.Contains("CABLE RG11") == true) { SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = 0; NewPartCount.JDEPartNumber = strJDEPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intPartID; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = strOldPartNumber; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } else if (strPartDescription.Contains("CABLE 875") == true) { SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = 0; NewPartCount.JDEPartNumber = strJDEPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intPartID; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = strOldPartNumber; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } else if (strPartDescription.Contains("CABLE 625") == true) { SpectrumCountDataSet.spectrumcountRow NewPartCount = TheSpectrumCountDataSet.spectrumcount.NewspectrumcountRow(); NewPartCount.ERPQuantity = 0; NewPartCount.JDEPartNumber = strJDEPartNumber; NewPartCount.PartDescription = strPartDescription; NewPartCount.PartID = intPartID; NewPartCount.PartNumber = strPartNumber; NewPartCount.OldPartNumber = strOldPartNumber; TheSpectrumCountDataSet.spectrumcount.Rows.Add(NewPartCount); } } } } dgrResult.ItemsSource = TheSpectrumCountDataSet.spectrumcount; PleaseWait.Close(); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Create Spectrum Report // Import Excel Expander " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
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()); } }
private void BtnImportExcel_Click(object sender, RoutedEventArgs e) { Excel.Application xlDropOrder; Excel.Workbook xlDropBook; Excel.Worksheet xlDropSheet; Excel.Range range; string strPartID; int intPartID; string strQuantity; int intQuantity; int intColumnRange = 0; int intCounter; int intNumberOfRecords; int intRecordsReturned; string strPartNumber; string strJDEPartNumber; string strPartDescription; string strJDEPartNumberFromSpreadSheet; int intCurrentQuantity; try { TheImportInventoryDataSet.importinventory.Rows.Clear(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".xlsx"; // Default file extension dlg.Filter = "Excel (.xlsx)|*.xlsx"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; } PleaseWait PleaseWait = new PleaseWait(); PleaseWait.Show(); xlDropOrder = new Excel.Application(); xlDropBook = xlDropOrder.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlDropSheet = (Excel.Worksheet)xlDropOrder.Worksheets.get_Item(1); range = xlDropSheet.UsedRange; intNumberOfRecords = range.Rows.Count + 1; intColumnRange = range.Columns.Count; for (intCounter = 1; intCounter < intNumberOfRecords; intCounter++) { strPartID = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2); intPartID = Convert.ToInt32(strPartID); strQuantity = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2); intQuantity = Convert.ToInt32(strQuantity); strJDEPartNumberFromSpreadSheet = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2); TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(intPartID); intRecordsReturned = TheFindPartByPartIDDataSet.FindPartByPartID.Rows.Count; if (intRecordsReturned == 0) { TheMessagesClass.ErrorMessage("Part ID " + strPartID + " Was Not Found"); return; } strPartNumber = TheFindPartByPartIDDataSet.FindPartByPartID[0].PartNumber; strJDEPartNumber = TheFindPartByPartIDDataSet.FindPartByPartID[0].JDEPartNumber; strPartDescription = TheFindPartByPartIDDataSet.FindPartByPartID[0].PartDescription; if (strJDEPartNumber != strJDEPartNumberFromSpreadSheet) { TheMessagesClass.ErrorMessage("JDE Part Numbers " + strJDEPartNumber + "and " + strJDEPartNumberFromSpreadSheet + " Do Not Match"); return; } TheFindWarehouseInventoryPartDataSet = TheInventoryClass.FindWarehouseInventoryPart(intPartID, gintWarehouseID); intRecordsReturned = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart.Rows.Count; if (intRecordsReturned == 0) { intCurrentQuantity = 0; } else { intCurrentQuantity = TheFindWarehouseInventoryPartDataSet.FindWarehouseInventoryPart[0].Quantity; } ImportInventoryDataSet.importinventoryRow NewPartRow = TheImportInventoryDataSet.importinventory.NewimportinventoryRow(); NewPartRow.CurrentQuantity = intCurrentQuantity; NewPartRow.NewQuantity = intQuantity; NewPartRow.JDEPartNumber = strJDEPartNumber; NewPartRow.PartDescription = strPartDescription; NewPartRow.PartID = intPartID; NewPartRow.PartNumber = strPartNumber; TheImportInventoryDataSet.importinventory.Rows.Add(NewPartRow); } PleaseWait.Close(); dgrResults.ItemsSource = TheImportInventoryDataSet.importinventory; btnProcess.IsEnabled = true; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Import MasPro Inventory // Import Excel Button " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }