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 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 LoadMaterialDataSet() { //setting local variables //int intRecordsReturned; //bool blnItemNotFound = true; int intCounter; int intNumberOfRecords; int intReportCounter; bool blnItemFound; int intPartID; int intQuantity; int intWarehouseID; decimal decCost; decimal decTotalCost; try { TheProjectMaterialReportDataSet.projectmaterial.Rows.Clear(); gintReportCounter = 0; gintReportUpperLimit = 0; TheFindIssuedPartsByProjectIDDataSet = TheIssuePartsClass.FindIssuedPartsByProjectID(MainWindow.gintProjectID); intNumberOfRecords = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID.Rows.Count - 1; if (intNumberOfRecords > -1) { for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++) { blnItemFound = false; intPartID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartID; intQuantity = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].Quantity; if (gintReportCounter > 0) { for (intReportCounter = 0; intReportCounter <= gintReportUpperLimit; intReportCounter++) { if (intPartID == TheProjectMaterialReportDataSet.projectmaterial[intReportCounter].PartID) { TheProjectMaterialReportDataSet.projectmaterial[intReportCounter].Issued += intQuantity; blnItemFound = true; } } } if (blnItemFound == false) { ProjectMaterialReportDataSet.projectmaterialRow NewPartRow = TheProjectMaterialReportDataSet.projectmaterial.NewprojectmaterialRow(); NewPartRow.PartDescription = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartDescription; NewPartRow.Issued = intQuantity; NewPartRow.JDEPartNumber = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].JDEPartNumber; NewPartRow.PartID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartID; NewPartRow.PartNumber = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartNumber; NewPartRow.Cost = 0; intWarehouseID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].WarehouseID; TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intWarehouseID); NewPartRow.Warehouse = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].FirstName; TheProjectMaterialReportDataSet.projectmaterial.Rows.Add(NewPartRow); gintReportUpperLimit = gintReportCounter; gintReportCounter++; } } } gdecTotalCost = 0; intNumberOfRecords = TheProjectMaterialReportDataSet.projectmaterial.Rows.Count - 1; for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++) { intQuantity = TheProjectMaterialReportDataSet.projectmaterial[intCounter].Issued; intPartID = TheProjectMaterialReportDataSet.projectmaterial[intCounter].PartID; TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(intPartID); decCost = Convert.ToDecimal(TheFindPartByPartIDDataSet.FindPartByPartID[0].Price); decTotalCost = intQuantity * decCost; decTotalCost = Math.Round(decTotalCost, 2); TheProjectMaterialReportDataSet.projectmaterial[intCounter].Cost = decTotalCost; gdecTotalCost += decTotalCost; } txtProjectCost.Text = Convert.ToString(gdecTotalCost); dgrResults.ItemsSource = TheProjectMaterialReportDataSet.projectmaterial; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Inventory Reports // Project Report // Search Button " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void cboSelectWarehouse_SelectionChanged(object sender, SelectionChangedEventArgs e) { int intCounter; int intNumberOfRecords; int intWarehouseID; int intPartID; string strPartNumber; string strOldPartNumber = ""; string strJDEPartNumber; string strPartDescription; int intQuantity; int intSelectedIndex; int intRecordsReturned; string strCurrentCount = ""; decimal decPartCost; decimal decTotalCost; try { intSelectedIndex = cboSelectWarehouse.SelectedIndex - 1; TheWarehouseCountDataSet.warehousecount.Rows.Clear(); if (intSelectedIndex > -1) { intWarehouseID = TheFindPartsWarehouseDataSet.FindPartsWarehouses[intSelectedIndex].EmployeeID; TheFindWarehouseInventoryDataSet = TheInventoryClass.FindWarehouseInventory(intWarehouseID); intNumberOfRecords = TheFindWarehouseInventoryDataSet.FindWarehouseInventory.Rows.Count; for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { intPartID = TheFindWarehouseInventoryDataSet.FindWarehouseInventory[intCounter].PartID; strPartNumber = TheFindWarehouseInventoryDataSet.FindWarehouseInventory[intCounter].PartNumber; strJDEPartNumber = TheFindWarehouseInventoryDataSet.FindWarehouseInventory[intCounter].JDEPartNumber; strPartDescription = TheFindWarehouseInventoryDataSet.FindWarehouseInventory[intCounter].PartDescription; intQuantity = TheFindWarehouseInventoryDataSet.FindWarehouseInventory[intCounter].Quantity; TheFindPartByPartIDDataSet = ThePartNumberClass.FindPartByPartID(intPartID); decPartCost = Convert.ToDecimal(TheFindPartByPartIDDataSet.FindPartByPartID[0].Price); decPartCost = Math.Round(decPartCost, 2); decTotalCost = decPartCost * intQuantity; decTotalCost = Math.Round(decTotalCost, 2); TheFindMasterPartListPartByPartIDDataSet = ThePartNumberClass.FindMasterPartByPartID(intPartID); intRecordsReturned = TheFindMasterPartListPartByPartIDDataSet.FindMasterPartListPartByPartID.Rows.Count; if (intRecordsReturned > 0) { strOldPartNumber = TheFindMasterPartListPartByPartIDDataSet.FindMasterPartListPartByPartID[0].PartNumber; } else if (intRecordsReturned < 1) { strOldPartNumber = "NO PART FOUND"; } WarehouseCountDataSet.warehousecountRow NewPartRow = TheWarehouseCountDataSet.warehousecount.NewwarehousecountRow(); NewPartRow.Quantity = intQuantity; NewPartRow.JDEPartNumber = strJDEPartNumber; NewPartRow.OldPartNumber = strOldPartNumber; NewPartRow.PartDescription = strPartDescription; NewPartRow.PartID = intPartID; NewPartRow.PartNumber = strPartNumber; NewPartRow.CurrentQuantity = strCurrentCount; NewPartRow.PartCost = decPartCost; NewPartRow.TotalValue = decTotalCost; TheWarehouseCountDataSet.warehousecount.Rows.Add(NewPartRow); } dgrResult.ItemsSource = TheWarehouseCountDataSet.warehousecount; } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Warehouse Inventory Report // Select Warehouse Combo Box " + 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 btnFind_Click(object sender, RoutedEventArgs e) { //this will load up the controls and search for the part number string strPartNumber; int intRecordsReturned; bool blnFatalError = false; int intPartID = 0; bool blnItemFound = false; try { strPartNumber = txtEnterPartNumber.Text; if (strPartNumber == "") { TheMessagesClass.ErrorMessage("Part Number Not Entered"); return; } blnFatalError = TheDataValidationClass.VerifyIntegerData(strPartNumber); if (blnFatalError == false) { intPartID = Convert.ToInt32(strPartNumber); TheFindPartByPartIDataSet = ThePartNumberClass.FindPartByPartID(intPartID); intRecordsReturned = TheFindPartByPartIDataSet.FindPartByPartID.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; //loading the controls txtJDEPartNumber.Text = TheFindPartByPartIDataSet.FindPartByPartID[0].JDEPartNumber; txtPartDescription.Text = TheFindPartByPartIDataSet.FindPartByPartID[0].PartDescription; txtPartID.Text = Convert.ToString(intPartID); txtPartNumber.Text = TheFindPartByPartIDataSet.FindPartByPartID[0].PartNumber; blnItemFound = true; } } if (blnItemFound == false) { TheFindPartByJDEPartNumberDataSet = ThePartNumberClass.FindPartByJDEPartNumber(strPartNumber); intRecordsReturned = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber.Rows.Count; if (intRecordsReturned > 0) { txtJDEPartNumber.Text = strPartNumber; txtPartDescription.Text = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartDescription; txtPartID.Text = Convert.ToString(TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartID); txtPartNumber.Text = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartNumber; } else { TheFindPartByPartNumberDataSet = ThePartNumberClass.FindPartByPartNumber(strPartNumber); intRecordsReturned = TheFindPartByPartNumberDataSet.FindPartByPartNumber.Rows.Count; if (intRecordsReturned > 0) { txtJDEPartNumber.Text = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].JDEPartNumber; txtPartDescription.Text = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartDescription; txtPartID.Text = Convert.ToString(TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartID); txtPartNumber.Text = strPartNumber; } else { TheMessagesClass.ErrorMessage("Part Number Not Found"); return; } } } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Part Number Lookup // Find Button " + 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()); } }