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 btnSearch_Click(object sender, RoutedEventArgs e) { //setting up data string strAssignedProjectID = ""; string strCustomerProjectID = ""; int intRecordsReturned; int intProjectID = 0; int intNumberOfRecords; int intCounter; try { strCustomerProjectID = txtProjectNumber.Text; if (strCustomerProjectID.Length < 4) { TheMessagesClass.ErrorMessage("The Project ID is not Long Enough"); return; } TheMaterialIssuedDataSet.materialissued.Rows.Clear(); //getting the data TheFindProjectMatrixByCustomerProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByCustomerProjectID(strCustomerProjectID); intRecordsReturned = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID.Rows.Count; if (intRecordsReturned < 1) { strAssignedProjectID = strCustomerProjectID; TheFindProjectMatrixByAssignedProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByAssignedProjectID(strAssignedProjectID); intRecordsReturned = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID.Rows.Count; if (intRecordsReturned < 1) { TheMessagesClass.ErrorMessage("Project Was Not Found"); return; } else if (intRecordsReturned > 0) { intProjectID = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID[0].ProjectID; strCustomerProjectID = TheFindProjectMatrixByAssignedProjectIDDataSet.FindProjectMatrixByAssignedProjectID[0].CustomerAssignedID; } } else if (intRecordsReturned > 0) { intProjectID = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].ProjectID; strAssignedProjectID = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].CustomerAssignedID; } TheFindIssuedPartsByProjectIDDataSet = TheIssuedPartsClass.FindIssuedPartsByProjectID(intProjectID); intNumberOfRecords = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID.Rows.Count; if (intNumberOfRecords > 0) { for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { MaterialIssuedDataSet.materialissuedRow NewTransactionRow = TheMaterialIssuedDataSet.materialissued.NewmaterialissuedRow(); NewTransactionRow.AssignedProjectID = strAssignedProjectID; NewTransactionRow.CustomerProjectID = strCustomerProjectID; NewTransactionRow.PartID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartID; NewTransactionRow.PartNumber = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].PartNumber; NewTransactionRow.Quantity = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].Quantity; NewTransactionRow.TransactionDate = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].TransactionDate; NewTransactionRow.TransactionID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].TransactionID; NewTransactionRow.VoidTransaction = false; NewTransactionRow.WarehouseID = TheFindIssuedPartsByProjectIDDataSet.FindIssuedPartsByProjectID[intCounter].WarehouseID; TheMaterialIssuedDataSet.materialissued.Rows.Add(NewTransactionRow); } MainWindow.gintProjectID = intProjectID; MainWindow.gstrAssignedProjectID = strAssignedProjectID; } dgrTransactions.ItemsSource = TheMaterialIssuedDataSet.materialissued; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Void Inventory Transaction // Search Button " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }