Exemplo n.º 1
0
        private void expExportToExcel_Expanded(object sender, RoutedEventArgs e)
        {
            bool blnFatalError = false;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                blnFatalError = ExportUsedTools();

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

                blnFatalError = ExportedNotUsedTools();

                if (blnFatalError == true)
                {
                    throw new Exception();
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Create WASP Tool Report // Export To Excel Tool Expander " + Ex.Message);

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

            PleaseWait.Close();
        }
        private void ResetControls()
        {
            //setting local variables
            int    intCounter;
            int    intNumberOfRecords;
            string strCustomerAssignedID;
            int    intSecondCounter;
            int    intSecondNumberOfRecords;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheDuplicateProjectsDataSet.duplicateprojects.Rows.Clear();

                //loading up the first data set
                TheFindDuplicateProjectMatrixDataSet = TheProjectMatrixClass.FindDuplicateProjectMatrix();

                intNumberOfRecords = TheFindDuplicateProjectMatrixDataSet.FindDuplicateProjectMatrix.Rows.Count - 1;

                if (intNumberOfRecords > -1)
                {
                    for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                    {
                        strCustomerAssignedID = TheFindDuplicateProjectMatrixDataSet.FindDuplicateProjectMatrix[intCounter].CustomerAssignedID;

                        TheFindProjectMatrixByCustomerAssignedIDShortDataSet = TheProjectMatrixClass.FindProjectMatrixByCustomerAssignedIDShort(strCustomerAssignedID);

                        intSecondNumberOfRecords = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort.Rows.Count - 1;

                        for (intSecondCounter = 0; intSecondCounter <= intSecondNumberOfRecords; intSecondCounter++)
                        {
                            DuplicateProjectsDataSet.duplicateprojectsRow NewProjectEntry = TheDuplicateProjectsDataSet.duplicateprojects.NewduplicateprojectsRow();

                            NewProjectEntry.AssignedOffice    = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].AssignedOffice;
                            NewProjectEntry.AssignedProjectID = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].AssignedProjectID;
                            NewProjectEntry.CustomerProjectID = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].CustomerAssignedID;
                            NewProjectEntry.ProjectID         = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].ProjectID;
                            NewProjectEntry.RemoveProject     = false;
                            NewProjectEntry.TransactionDate   = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].TransactionDate;
                            NewProjectEntry.TransactionID     = TheFindProjectMatrixByCustomerAssignedIDShortDataSet.FindProjectMatrixByCustomerAssignedIDShort[intSecondCounter].TransactionID;

                            TheDuplicateProjectsDataSet.duplicateprojects.Rows.Add(NewProjectEntry);
                        }
                    }
                }

                dgrDuplicateProjects.ItemsSource = TheDuplicateProjectsDataSet.duplicateprojects;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Remove Duplicate Project Matrix // Reset Controls " + Ex.Message);

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

            PleaseWait.Close();
        }
        private void expProcessImport_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            DateTime datEventDate;
            int      intVehicleID;
            bool     blnInSide;
            int      intEmployeeID;
            string   strDriver;
            int      intRecordsReturned;
            bool     blnFatalError;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                intNumberOfRecords = TheImportGEOFenceDataSet.importgeofence.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    intVehicleID  = TheImportGEOFenceDataSet.importgeofence[intCounter].VehicleID;
                    datEventDate  = TheImportGEOFenceDataSet.importgeofence[intCounter].EventTime;
                    blnInSide     = TheImportGEOFenceDataSet.importgeofence[intCounter].InSide;
                    intEmployeeID = TheImportGEOFenceDataSet.importgeofence[intCounter].EmployeeID;
                    strDriver     = TheImportGEOFenceDataSet.importgeofence[intCounter].Driver;

                    if (intVehicleID > -1)
                    {
                        TheFindGEOFenceTransactionExactDateDataSet = TheGEOFenceClass.FindGEOFenceTransaction(datEventDate, intVehicleID);

                        intRecordsReturned = TheFindGEOFenceTransactionExactDateDataSet.FindGEOFenceTransactionByExactDate.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            blnFatalError = TheGEOFenceClass.InsertGEOFenceImportEntry(datEventDate, intVehicleID, blnInSide, intEmployeeID, strDriver);

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

                TheMessagesClass.InformationMessage("The Records Have Been Inserted");
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import GEO Fence Report // Process Import " + Ex.Message);

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

            PleaseWait.Close();
        }
        private void expProcessImport_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            int      intAssetID;
            string   strAssetDescription;
            string   strAssetType;
            string   strSite;
            string   strLocation;
            string   strSerialNumber;
            string   strManufacturer;
            string   strModel;
            int      intWarehouseID;
            DateTime datTransactionDate;
            bool     blnFatalError = false;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                intNumberOfRecords = TheImportWASPITAssetsDataSet.importassets.Rows.Count;

                for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                {
                    intAssetID          = TheImportWASPITAssetsDataSet.importassets[intCounter].AssetID;
                    strAssetType        = TheImportWASPITAssetsDataSet.importassets[intCounter].AssetType;
                    strAssetDescription = TheImportWASPITAssetsDataSet.importassets[intCounter].AssetDescription;
                    strSite             = TheImportWASPITAssetsDataSet.importassets[intCounter].Site;
                    strLocation         = TheImportWASPITAssetsDataSet.importassets[intCounter].Location;
                    strSerialNumber     = TheImportWASPITAssetsDataSet.importassets[intCounter].SerialNumber;
                    strManufacturer     = TheImportWASPITAssetsDataSet.importassets[intCounter].Manufacturer;
                    strModel            = TheImportWASPITAssetsDataSet.importassets[intCounter].Model;
                    datTransactionDate  = DateTime.Now;
                    intWarehouseID      = TheImportWASPITAssetsDataSet.importassets[intCounter].WarehouseID;

                    blnFatalError = TheAssetClass.InsertWaspAssets(intAssetID, strAssetDescription, strSerialNumber, strAssetType, strSite, strLocation, intWarehouseID, datTransactionDate, strSerialNumber, strManufacturer, strModel);

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Wasp IT Assets // Proces Import Expander " + Ex.Message);

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

            PleaseWait.Close();
        }
Exemplo n.º 5
0
        private void expProcessImport_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            int      intPhoneID;
            int      intEmployeeID;
            DateTime datTransactionDate;
            string   strTransactionNumber;
            string   strMessageDirection;
            string   strMessageType;
            bool     blnFatalError = false;

            try
            {
                expProcessImport.IsExpanded = false;

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                intNumberOfRecords = TheImportCellMessagesDataSet.importcellmessages.Rows.Count;

                if (intNumberOfRecords > -1)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        intPhoneID           = TheImportCellMessagesDataSet.importcellmessages[intCounter].PhoneID;
                        intEmployeeID        = TheImportCellMessagesDataSet.importcellmessages[intCounter].EmployeeID;
                        datTransactionDate   = TheImportCellMessagesDataSet.importcellmessages[intCounter].TransactionDate;
                        strTransactionNumber = TheImportCellMessagesDataSet.importcellmessages[intCounter].TransactionNumber;
                        strMessageDirection  = TheImportCellMessagesDataSet.importcellmessages[intCounter].MessageDirection;
                        strMessageType       = TheImportCellMessagesDataSet.importcellmessages[intCounter].MessageType;

                        blnFatalError = TheCellPhoneCallsClass.InsertCellPhoneMessages(intPhoneID, intEmployeeID, datTransactionDate, strTransactionNumber, strMessageDirection, strMessageType);

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

                PleaseWait.Close();

                TheMessagesClass.InformationMessage("Data Has Been Imported");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Cell Messages // Process Import " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void expExportToExcel_Expanded(object sender, RoutedEventArgs e)
        {
            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            expExportToExcel.IsExpanded = false;

            ExportCompanyFootages();

            ExportTotalFootages();

            PleaseWait.Close();
        }
        private void expCreateReport_Expanded(object sender, RoutedEventArgs e)
        {
            //setting local variables
            DateTime datStartDate;
            DateTime datEndDate;
            DateTime datTransactionDate;
            DateTime datLimitingDate;
            int      intCounter;
            int      intNumberOfRecords;
            int      intRecordReturned;
            int      intVehicleID;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheVehicleUsageDataSet.vehicleusage.Rows.Clear();
                expCreateReport.IsExpanded = false;

                TheFindActiveVehicleMainSortedDataSet = TheVehicleMainClass.FindActiveVehicleMainSorted();

                intNumberOfRecords = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    VehicleUsageDataSet.vehicleusageRow NewVehicleRow = TheVehicleUsageDataSet.vehicleusage.NewvehicleusageRow();

                    NewVehicleRow.VehicleID      = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].VehicleID;
                    NewVehicleRow.VehicleNumber  = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].VehicleNumber;
                    NewVehicleRow.AssignedOffice = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].AssignedOffice;
                    NewVehicleRow.TimesInYard    = 0;
                    NewVehicleRow.TimesUnknown   = 0;
                    NewVehicleRow.TimesDriven    = 0;

                    TheVehicleUsageDataSet.vehicleusage.Rows.Add(NewVehicleRow);
                }

                datEndDate   = DateTime.Now;
                datEndDate   = TheDateSearchClass.RemoveTime(datEndDate);
                datStartDate = TheDateSearchClass.SubtractingDays(datEndDate, 120);

                datTransactionDate = datStartDate;
                datLimitingDate    = TheDateSearchClass.AddingDays(datTransactionDate, 1);
                intNumberOfRecords = TheVehicleUsageDataSet.vehicleusage.Rows.Count - 1;

                while (datLimitingDate <= datEndDate)
                {
                    if (datTransactionDate.DayOfWeek != DayOfWeek.Saturday)
                    {
                        if (datTransactionDate.DayOfWeek != DayOfWeek.Sunday)
                        {
                            for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                            {
                                intVehicleID = TheVehicleUsageDataSet.vehicleusage[intCounter].VehicleID;

                                TheFindGEOFenceByVehicleIDDataSet = TheGEOFenceClass.FindGEOFenceByVehicleID(intVehicleID, datTransactionDate, datLimitingDate);

                                intRecordReturned = TheFindGEOFenceByVehicleIDDataSet.FindGEOFenceByVehicleID.Rows.Count;

                                if (intRecordReturned > 0)
                                {
                                    TheVehicleUsageDataSet.vehicleusage[intCounter].TimesDriven++;
                                }
                                else
                                {
                                    TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet = TheInspectionsClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(intVehicleID, datTransactionDate, datLimitingDate);

                                    intRecordReturned = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count;

                                    if (intRecordReturned > 0)
                                    {
                                        TheVehicleUsageDataSet.vehicleusage[intCounter].TimesDriven++;
                                    }
                                    else
                                    {
                                        TheFindVehicleInYardByVehicleIDAndDateRangeDataSet = TheVehicleInYardClass.FindVehiclesInYardByVehicleIDAndDateRange(intVehicleID, datTransactionDate, datLimitingDate);

                                        intRecordReturned = TheFindVehicleInYardByVehicleIDAndDateRangeDataSet.FindVehiclesInYardByVehicleIDAndDateRange.Rows.Count;

                                        if (intRecordReturned > 0)
                                        {
                                            TheVehicleUsageDataSet.vehicleusage[intCounter].TimesInYard++;
                                        }
                                        else
                                        {
                                            TheVehicleUsageDataSet.vehicleusage[intCounter].TimesUnknown++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    datTransactionDate = TheDateSearchClass.AddingDays(datTransactionDate, 1);
                    datLimitingDate    = TheDateSearchClass.AddingDays(datLimitingDate, 1);
                }

                dgrResults.ItemsSource = TheVehicleUsageDataSet.vehicleusage;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Vehicle Usage Report // Create Report Expander " + Ex.Message);

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

            PleaseWait.Close();
        }
Exemplo n.º 8
0
        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  strValueForValidation;
            int     intQuantity;
            string  strItemNumber;
            string  strItemDescription;
            decimal decCost;
            decimal decTotalCost;
            bool    blnItemFound;
            string  strSite = "";
            int     intInventoryCounter;
            string  strNewQuantity;
            int     intCommaIndex;
            int     intWarehouseCounter;

            try
            {
                expImportExcel.IsExpanded = false;
                TheInventoryValuationDataSet.inventoryvaluation.Rows.Clear();
                TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation.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;
                gintInventoryNumberOfRecords = 0;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strItemNumber = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2);
                    blnItemFound  = false;

                    if (strItemNumber == "Site")
                    {
                        strSite = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2);
                    }
                    else if (strItemNumber == null)
                    {
                    }
                    else if (strSite.Contains("BLUE JAY") == true)
                    {
                        if (strItemNumber.Contains("Location") == false)
                        {
                            if (strItemNumber != "Item Number")
                            {
                                strItemDescription    = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2);
                                strValueForValidation = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2);
                                if (strValueForValidation.Contains(",") == true)
                                {
                                    intCommaIndex = strValueForValidation.IndexOf(",");

                                    strNewQuantity  = strValueForValidation.Substring(0, intCommaIndex);
                                    strNewQuantity += strValueForValidation.Substring(intCommaIndex + 1);

                                    strValueForValidation = strNewQuantity;
                                }
                                intQuantity           = Convert.ToInt32(strValueForValidation);
                                strValueForValidation = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2);
                                decCost = Convert.ToDecimal(strValueForValidation);
                                strValueForValidation = Convert.ToString((range.Cells[intCounter, 12] as Excel.Range).Value2);
                                decTotalCost          = Convert.ToDecimal(strValueForValidation);

                                if (gintInventoryNumberOfRecords > 0)
                                {
                                    for (intInventoryCounter = 0; intInventoryCounter < gintInventoryNumberOfRecords; intInventoryCounter++)
                                    {
                                        if (strSite == TheInventoryValuationDataSet.inventoryvaluation[intInventoryCounter].Warehouse)
                                        {
                                            if (strItemNumber == TheInventoryValuationDataSet.inventoryvaluation[intInventoryCounter].ItemNumber)
                                            {
                                                TheInventoryValuationDataSet.inventoryvaluation[intInventoryCounter].Quantity  += intQuantity;
                                                TheInventoryValuationDataSet.inventoryvaluation[intInventoryCounter].TotalCost += decTotalCost;
                                                blnItemFound = true;
                                            }
                                        }
                                    }
                                }

                                if (blnItemFound == false)
                                {
                                    InventoryValuationDataSet.inventoryvaluationRow NewInventoryRow = TheInventoryValuationDataSet.inventoryvaluation.NewinventoryvaluationRow();

                                    NewInventoryRow.Cost            = decCost;
                                    NewInventoryRow.ItemDescription = strItemDescription;
                                    NewInventoryRow.ItemNumber      = strItemNumber;
                                    NewInventoryRow.Quantity        = intQuantity;
                                    NewInventoryRow.TotalCost       = decTotalCost;
                                    NewInventoryRow.Warehouse       = strSite;

                                    TheInventoryValuationDataSet.inventoryvaluation.Rows.Add(NewInventoryRow);
                                    gintInventoryNumberOfRecords++;
                                }
                            }
                        }
                    }
                }

                intNumberOfRecords           = TheInventoryValuationDataSet.inventoryvaluation.Rows.Count;
                gintWarehouseNumberOfRecords = 0;

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        blnItemFound = false;
                        strSite      = TheInventoryValuationDataSet.inventoryvaluation[intCounter].Warehouse;
                        decTotalCost = TheInventoryValuationDataSet.inventoryvaluation[intCounter].TotalCost;

                        if (gintWarehouseNumberOfRecords > 0)
                        {
                            for (intWarehouseCounter = 0; intWarehouseCounter < gintWarehouseNumberOfRecords; intWarehouseCounter++)
                            {
                                if (strSite == TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation[intWarehouseCounter].Warehouse)
                                {
                                    blnItemFound = true;
                                    TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation[intWarehouseCounter].TotalValuation += decTotalCost;
                                }
                            }
                        }

                        if (blnItemFound == false)
                        {
                            WarehouseInventoryValuationDataSet.warehouseinventoryvaluationRow NewWarehouseRow = TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation.NewwarehouseinventoryvaluationRow();

                            NewWarehouseRow.TotalValuation = decTotalCost;
                            NewWarehouseRow.Warehouse      = strSite;

                            TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation.Rows.Add(NewWarehouseRow);
                            gintWarehouseNumberOfRecords++;
                        }
                    }
                }

                dgrInventory.ItemsSource = TheWarehouseInventoryValuationDataSet.warehouseinventoryvaluation;
                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Prepare Asset Report // Import Excel Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void UpdateGrid()
        {
            int      intCounter;
            int      intNumberOfRecords;
            DateTime datTransactionDate;
            int      intWorkTaskID;
            decimal  decTotalCount;
            decimal  decTaskCount = 0;
            decimal  decPercentage;
            int      intGreaterThan;
            int      intRecordsReturned;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheProductionTasksForSheetsDataSet.productiontasks.Rows.Clear();

                datTransactionDate = DateTime.Now;

                datTransactionDate = TheDateSearchClass.SubtractingDays(datTransactionDate, 90);

                TheFindWorkTaskIDTotalCountByDateDataSet = TheWorkTaskClass.FindWorkTaskIDTotalCountByDate(datTransactionDate);

                TheFindWorkTaskDepartmentByLOBDepartmentDataSet = TheWorkTaskClass.FindWorkTaskDepartmentByLOBDepartment(gintBusinessLineID, gintDepartmentID);

                decTotalCount = Convert.ToDecimal(TheFindWorkTaskIDTotalCountByDateDataSet.FindWorkTaskIDTotalCountByDate[0].TotalCount);

                intNumberOfRecords = TheFindWorkTaskDepartmentByLOBDepartmentDataSet.FindWorkTaskDepartmentByLOBDepartment.Rows.Count;

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        intWorkTaskID = TheFindWorkTaskDepartmentByLOBDepartmentDataSet.FindWorkTaskDepartmentByLOBDepartment[intCounter].WorkTaskID;

                        TheFindWorkTaskUsageByDateTaskDataSet = TheWorkTaskClass.FindWorkTaskUsageByDateTask(datTransactionDate, intWorkTaskID);

                        intRecordsReturned = TheFindWorkTaskUsageByDateTaskDataSet.FindWorkTaskUsageByDateTask.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            decTaskCount = 0;
                        }
                        else if (intRecordsReturned > 0)
                        {
                            decTaskCount = Convert.ToDecimal(TheFindWorkTaskUsageByDateTaskDataSet.FindWorkTaskUsageByDateTask[0].TotalCount);
                        }

                        decPercentage = decTaskCount / decTotalCount;

                        ProductionTasksForSheetsDataSet.productiontasksRow NewProductionCode = TheProductionTasksForSheetsDataSet.productiontasks.NewproductiontasksRow();

                        NewProductionCode.WorkTask = TheFindWorkTaskDepartmentByLOBDepartmentDataSet.FindWorkTaskDepartmentByLOBDepartment[intCounter].WorkTask;

                        intGreaterThan = decimal.Compare(decPercentage, Convert.ToDecimal(.001));

                        if (intGreaterThan < 0)
                        {
                            NewProductionCode.UseCode = false;
                        }
                        else if (intGreaterThan > -1)
                        {
                            NewProductionCode.UseCode = true;
                        }

                        TheProductionTasksForSheetsDataSet.productiontasks.Rows.Add(NewProductionCode);
                    }
                }

                dgrProductionCodes.ItemsSource = TheProductionTasksForSheetsDataSet.productiontasks;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Create Production Sheet // Update Grid " + Ex.Message);

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

            PleaseWait.Close();
        }
        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;
            int    intAssetID;
            string strAssetID;
            string strAssetDescription;
            string strAssetType;
            string strSite;
            string strLocation;
            string strSerialNumber;
            string strManufacturer;
            string strModel;
            int    intRecordsReturned;
            bool   blnItemFound;
            int    intWarehouseID;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                expImportExcel.IsExpanded = false;
                TheImportWASPITAssetsDataSet.importassets.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;
                }

                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;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnItemFound        = false;
                    strAssetID          = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    intAssetID          = Convert.ToInt32(strAssetID);
                    strAssetDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    strAssetType        = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                    strSite             = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper();
                    strLocation         = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2).ToUpper();
                    strSerialNumber     = Convert.ToString((range.Cells[intCounter, 13] as Excel.Range).Value2).ToUpper();
                    strManufacturer     = Convert.ToString((range.Cells[intCounter, 15] as Excel.Range).Value2).ToUpper();
                    strModel            = Convert.ToString((range.Cells[intCounter, 16] as Excel.Range).Value2).ToUpper();

                    if (strSite == "GROVEPORT")
                    {
                        strSite = "CBUS-GROVEPORT";
                    }

                    TheFindWarehouseByWarehouseNameDataSet = TheEmployeeClass.FindWarehouseByWarehouseName(strSite);

                    intWarehouseID = TheFindWarehouseByWarehouseNameDataSet.FindWarehouseByWarehouseName[0].EmployeeID;

                    TheFindWASPAssetByAssetIDDataSet = TheAssetClass.FindWaspAssetByAssetID(intAssetID);

                    intRecordsReturned = TheFindWASPAssetByAssetIDDataSet.FindWaspAssetByAssetID.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnItemFound = true;
                    }
                    else if (intRecordsReturned < 1)
                    {
                        TheFindWaspAssetsBySerialNumberDataSet = TheAssetClass.FindWaspAssetsBySerialNumber(strSerialNumber);

                        intRecordsReturned = TheFindWaspAssetsBySerialNumberDataSet.FindWaspAssetsBySerialNumber.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            blnItemFound = true;
                        }
                    }

                    if (blnItemFound == false)
                    {
                        ImportWASPITAssetsDataSet.importassetsRow NewAssetRow = TheImportWASPITAssetsDataSet.importassets.NewimportassetsRow();

                        NewAssetRow.AssetDescription = strAssetDescription;
                        NewAssetRow.AssetID          = intAssetID;
                        NewAssetRow.AssetType        = strAssetType;
                        NewAssetRow.Location         = strLocation;
                        NewAssetRow.Manufacturer     = strManufacturer;
                        NewAssetRow.Model            = strModel;
                        NewAssetRow.SerialNumber     = strSerialNumber;
                        NewAssetRow.Site             = strSite;
                        NewAssetRow.WarehouseID      = intWarehouseID;

                        TheImportWASPITAssetsDataSet.importassets.Rows.Add(NewAssetRow);
                    }
                }

                dgrITAssets.ItemsSource = TheImportWASPITAssetsDataSet.importassets;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Wasp IT Assets // Import Excel  " + Ex.Message);

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

            PleaseWait.Close();
        }
Exemplo n.º 11
0
        private void expFindMessages_Expanded(object sender, RoutedEventArgs e)
        {
            //setting up local variables
            bool     blnFatalError      = false;
            bool     blnThereIsAProblem = false;
            string   strErrorMessage    = "";
            string   strValueForValidation;
            int      intCounter;
            int      intNumberOfRecords;
            string   strLastFour;
            string   strRespondent;
            DateTime datTransactionDate;
            string   strPhoneNumber;
            string   strTransactionNumber;
            string   strMessageDirection;
            string   strMessageType;
            int      intRecordsReturned;
            bool     blnItemFound;

            try
            {
                expFindMessages.IsExpanded = false;

                if (cboReportType.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Report Type Was Not Selected\n";
                }
                strValueForValidation = txtStartDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Start Date Is Not a Date\n";
                }
                else
                {
                    gdatStartDate = Convert.ToDateTime(strValueForValidation);
                }
                strValueForValidation = txtEndDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The End Date Is Not a Date\n";
                }
                else
                {
                    gdatEndDate = Convert.ToDateTime(strValueForValidation);
                }
                if (cboReportType.SelectedIndex == 1)
                {
                    if (gstrTransactionNumber.Length != 4)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Number Of Digits is not Correct\n";
                    }
                }
                else if (cboReportType.SelectedIndex == 2)
                {
                    if (cboSelectEmployee.SelectedIndex < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Employee Was Not Selected\n";
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }
                else
                {
                    blnFatalError = TheDataValidationClass.verifyDateRange(gdatStartDate, gdatEndDate);

                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage("The Start Date is after the End Date");
                        return;
                    }
                }

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();


                TheMessagesForEmployeeDataSet.messagesforemployee.Rows.Clear();

                if (cboReportType.SelectedIndex == 1)
                {
                    TheFindCellPhoneMessagesForNumberDataSet = TheCellPhoneCallsClass.FindCellPhoneMessagesForNumber(gstrTransactionNumber, gdatStartDate, gdatEndDate);

                    intNumberOfRecords = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber.Rows.Count;

                    if (intNumberOfRecords > 0)
                    {
                        for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                        {
                            blnItemFound  = false;
                            strRespondent = "UNKNOWN";

                            datTransactionDate   = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].TransactionDate;
                            gstrFullName         = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].FirstName + " ";
                            gstrFullName        += TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].LastName;
                            strPhoneNumber       = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].PhoneNumber;
                            strTransactionNumber = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].TransactionNumber;
                            strLastFour          = strTransactionNumber.Substring(8, 4);
                            strMessageDirection  = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].MessageDirection;
                            strMessageType       = TheFindCellPhoneMessagesForNumberDataSet.FindCellPhoneMessagesForNumber[intCounter].MessageType;

                            TheFindCellPhoneByLastForDataSet = ThePhonesClass.FindCellPhoneByLastFour(strLastFour);

                            intRecordsReturned = TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                strRespondent  = TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour[0].FirstName + " ";
                                strRespondent += TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour[0].LastName;
                                blnItemFound   = true;
                            }
                            if (blnItemFound == false)
                            {
                                TheFindEmployeeBylastFourPhoneDigitsDataSet = TheEmployeeClass.FindEmployeeByLastFourPhoneDigits(strLastFour);

                                intRecordsReturned = TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits.Rows.Count;

                                if (intRecordsReturned > 0)
                                {
                                    if (strTransactionNumber == TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].PhoneNumber)
                                    {
                                        strRespondent  = TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].FirstName + " ";
                                        strRespondent += TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].LastName;
                                    }
                                }
                            }

                            MessagesForEmployeeDataSet.messagesforemployeeRow NewMessageRow = TheMessagesForEmployeeDataSet.messagesforemployee.NewmessagesforemployeeRow();

                            NewMessageRow.Employee          = gstrFullName;
                            NewMessageRow.MessageDirection  = strMessageDirection;
                            NewMessageRow.MessageType       = strMessageType;
                            NewMessageRow.PhoneNumber       = strPhoneNumber;
                            NewMessageRow.Respondent        = strRespondent;
                            NewMessageRow.TransactionDate   = datTransactionDate;
                            NewMessageRow.TransactionNumber = strTransactionNumber;

                            TheMessagesForEmployeeDataSet.messagesforemployee.Rows.Add(NewMessageRow);
                        }
                    }
                }
                else if (cboReportType.SelectedIndex == 2)
                {
                    TheFindCellPhoneMesagesForEmployeeDataSet = TheCellPhoneCallsClass.FindCellPhoneMessagesForEmployee(gintEmployeeID, gdatStartDate, gdatEndDate);

                    intNumberOfRecords = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee.Rows.Count;

                    if (intNumberOfRecords > 0)
                    {
                        for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                        {
                            blnItemFound         = false;
                            strRespondent        = "UNKNOWN";
                            datTransactionDate   = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee[intCounter].TransactionDate;
                            strPhoneNumber       = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee[intCounter].PhoneNumber;
                            strTransactionNumber = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee[intCounter].TransactionNumber;
                            strLastFour          = strTransactionNumber.Substring(8, 4);
                            strMessageDirection  = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee[intCounter].MessageDirection;
                            strMessageType       = TheFindCellPhoneMesagesForEmployeeDataSet.FindCellPhoneMessagesForEmployee[intCounter].MessageType;

                            TheFindCellPhoneByLastForDataSet = ThePhonesClass.FindCellPhoneByLastFour(strLastFour);

                            intRecordsReturned = TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                strRespondent  = TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour[0].FirstName + " ";
                                strRespondent += TheFindCellPhoneByLastForDataSet.FindCellPhoneByLastFour[0].LastName;
                                blnItemFound   = true;
                            }
                            if (blnItemFound == false)
                            {
                                TheFindEmployeeBylastFourPhoneDigitsDataSet = TheEmployeeClass.FindEmployeeByLastFourPhoneDigits(strLastFour);

                                intRecordsReturned = TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits.Rows.Count;

                                if (intRecordsReturned > 0)
                                {
                                    if (strTransactionNumber == TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].PhoneNumber)
                                    {
                                        strRespondent  = TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].FirstName + " ";
                                        strRespondent += TheFindEmployeeBylastFourPhoneDigitsDataSet.FindEmployeeByLastFourPhoneDigits[0].LastName;
                                    }
                                }
                            }

                            MessagesForEmployeeDataSet.messagesforemployeeRow NewMessageRow = TheMessagesForEmployeeDataSet.messagesforemployee.NewmessagesforemployeeRow();

                            NewMessageRow.Employee          = gstrFullName;
                            NewMessageRow.MessageDirection  = strMessageDirection;
                            NewMessageRow.MessageType       = strMessageType;
                            NewMessageRow.PhoneNumber       = strPhoneNumber;
                            NewMessageRow.Respondent        = strRespondent;
                            NewMessageRow.TransactionDate   = datTransactionDate;
                            NewMessageRow.TransactionNumber = strTransactionNumber;

                            TheMessagesForEmployeeDataSet.messagesforemployee.Rows.Add(NewMessageRow);
                        }
                    }
                }

                dgrCellMessages.ItemsSource = TheMessagesForEmployeeDataSet.messagesforemployee;

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Cell Message Search // Find Messages Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void ResetControls()
        {
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID;
            int      intProjectID;
            DateTime datTransactionDate;
            bool     blnFatalError = false;
            int      intRecordsReturned;
            int      intManagerID;
            string   strManagerName;
            int      intSecondCounter;
            decimal  decReportHours;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheEmployeeDriveTimeDataSet.employeedrivetime.Rows.Clear();

                TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet = TheEmployeeProjectAssignmentClass.FindEmployeeProjectAssignmentDriveTimeHours();

                intNumberOfRecords = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours.Rows.Count;

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        intEmployeeID      = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].EmployeeID;
                        intProjectID       = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].ProjectID;
                        datTransactionDate = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].TransactionDate;

                        TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intEmployeeID);

                        intManagerID = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].ManagerID;

                        TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intManagerID);

                        strManagerName  = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].FirstName + " ";
                        strManagerName += TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].LastName;

                        TheFindEmployeeProjectAssignmentForComparisonDataSet = TheEmployeeProjectAssignmentClass.FindEmployeeProjectAssignmentForComparison(intEmployeeID, intProjectID, datTransactionDate);

                        intRecordsReturned = TheFindEmployeeProjectAssignmentForComparisonDataSet.FindEmployeeProjectAssignmentforComparison.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            EmployeeDriveTimeDataSet.employeedrivetimeRow NewEmployeeRow = TheEmployeeDriveTimeDataSet.employeedrivetime.NewemployeedrivetimeRow();

                            NewEmployeeRow.BlueJayProjectID  = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].AssignedProjectID;
                            NewEmployeeRow.CustomerProjectID = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].CustomerAssignedID;
                            NewEmployeeRow.FirstName         = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].FirstName;
                            NewEmployeeRow.LastName          = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].LastName;
                            NewEmployeeRow.Manager           = strManagerName;
                            NewEmployeeRow.ProjectName       = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].ProjectName;
                            NewEmployeeRow.TotalHours        = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].TotalHours;
                            NewEmployeeRow.TransactionDate   = datTransactionDate;

                            TheEmployeeDriveTimeDataSet.employeedrivetime.Rows.Add(NewEmployeeRow);
                        }
                        else if (intRecordsReturned > 0)
                        {
                            decReportHours = 0;

                            for (intSecondCounter = 0; intSecondCounter < intRecordsReturned; intSecondCounter++)
                            {
                                decReportHours += TheFindEmployeeProjectAssignmentForComparisonDataSet.FindEmployeeProjectAssignmentforComparison[intSecondCounter].TotalHours;
                            }

                            if (decReportHours == 0)
                            {
                                EmployeeDriveTimeDataSet.employeedrivetimeRow NewEmployeeRow = TheEmployeeDriveTimeDataSet.employeedrivetime.NewemployeedrivetimeRow();

                                NewEmployeeRow.BlueJayProjectID  = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].AssignedProjectID;
                                NewEmployeeRow.CustomerProjectID = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].CustomerAssignedID;
                                NewEmployeeRow.FirstName         = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].FirstName;
                                NewEmployeeRow.LastName          = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].LastName;
                                NewEmployeeRow.Manager           = strManagerName;
                                NewEmployeeRow.ProjectName       = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].ProjectName;
                                NewEmployeeRow.TotalHours        = TheFindEmployeeProjectAssignmentDriveTimeHoursDataSet.FindEmployeeProjectAssignmentDriveTimeHours[intCounter].TotalHours;
                                NewEmployeeRow.TransactionDate   = datTransactionDate;

                                TheEmployeeDriveTimeDataSet.employeedrivetime.Rows.Add(NewEmployeeRow);
                            }
                        }
                    }
                }

                dgrResults.ItemsSource = TheEmployeeDriveTimeDataSet.employeedrivetime;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Drive Time Analysis " + Ex.Message);

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

            PleaseWait.Close();
        }
Exemplo n.º 13
0
        private void GenerateReport()
        {
            //setting up the data
            string   strErrorMessage = "";
            bool     blnFatalError   = false;
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID = -1;
            decimal  decTotalHours = 0;
            decimal  decMultiplier = 1;
            decimal  decTotalCost  = 0;
            decimal  decReportedHours;
            decimal  decPayRate;
            decimal  decDifference;
            int      intProjectCounter;
            bool     blnItemFound;
            int      intProjectID;
            bool     blnMonday;
            DateTime datTransactionDate;

            try
            {
                TheCompleteProjectProductivityDataSet.completeprojectproductivity.Rows.Clear();
                TheEmployeeProductivityDataSet.employeeproductivity.Rows.Clear();

                if (gblnStartDateSelected == false)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Start Date was not Selected\n";
                }
                else
                {
                    if (gdatStartDate.DayOfWeek != DayOfWeek.Monday)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Start Date is not a Monday\n";
                    }
                }
                if (gblnEndDateSelected == false)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The End Date Was Not Selected\n";
                }
                else
                {
                    if (gdatEndDate.DayOfWeek != DayOfWeek.Sunday)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The End Date is not a Sunday\n";
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessageClass.ErrorMessage(strErrorMessage);
                    return;
                }

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                TheFindAllEmployeesProductionOverAWeekDataSet = TheEmployeeProjectAssignmentClass.FindAllEmployeeProductionOverAWeek(gdatStartDate, gdatEndDate);

                intNumberOfRecords = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek.Rows.Count - 1;
                blnMonday          = false;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    decPayRate         = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].PayRate;
                    decReportedHours   = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TotalHours;
                    datTransactionDate = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TransactionDate;

                    if ((datTransactionDate.DayOfWeek == DayOfWeek.Monday) && (blnMonday == false))
                    {
                        decTotalHours = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TotalHours;
                        intEmployeeID = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].EmployeeID;
                        blnMonday     = true;
                        decMultiplier = 1;
                    }
                    else if (intEmployeeID != TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].EmployeeID)
                    {
                        decTotalHours = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TotalHours;
                        intEmployeeID = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].EmployeeID;
                        decMultiplier = 1;
                    }
                    else if (intEmployeeID == TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].EmployeeID)
                    {
                        decTotalHours += TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TotalHours;

                        if (datTransactionDate.DayOfWeek != DayOfWeek.Monday)
                        {
                            blnMonday = false;
                        }
                    }

                    if (decMultiplier == 1)
                    {
                        if (decTotalHours <= 40)
                        {
                            decTotalCost = decPayRate * decReportedHours;
                        }
                        if (decTotalHours > 40)
                        {
                            decDifference = decTotalHours - 40;
                            decMultiplier = Convert.ToDecimal(1.5);
                            decTotalCost  = ((decReportedHours - decDifference) * decPayRate) + (decDifference * decPayRate * decMultiplier);
                        }
                    }
                    if (decMultiplier == Convert.ToDecimal(1.5))
                    {
                        decTotalCost = decReportedHours * decPayRate * decMultiplier;
                    }

                    EmployeeProductivityDataSet.employeeproductivityRow NewProductivityRow = TheEmployeeProductivityDataSet.employeeproductivity.NewemployeeproductivityRow();

                    NewProductivityRow.AssignedProjectID = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].AssignedProjectID;
                    NewProductivityRow.CalculatedHours   = decTotalHours;
                    NewProductivityRow.EmployeeID        = intEmployeeID;
                    NewProductivityRow.FirstName         = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].FirstName;
                    NewProductivityRow.LastName          = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].LastName;
                    NewProductivityRow.Multiplier        = decMultiplier;
                    NewProductivityRow.PayRate           = decPayRate;
                    NewProductivityRow.ProjectID         = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].ProjectID;
                    NewProductivityRow.ProjectName       = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].ProjectName;
                    NewProductivityRow.TotalCost         = decTotalCost;
                    NewProductivityRow.TotalHours        = decReportedHours;
                    NewProductivityRow.TransactionDate   = TheFindAllEmployeesProductionOverAWeekDataSet.FindAllEmployeeProductionOverAWeek[intCounter].TransactionDate;

                    TheEmployeeProductivityDataSet.employeeproductivity.Rows.Add(NewProductivityRow);
                }

                TheFindAllDesignEmployeeProductivityOverAWeekDataSet = TheDesignProductivityClass.FindAllDesignEmployeeProductivityOverAWeek(gdatStartDate, gdatEndDate);

                intNumberOfRecords = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek.Rows.Count - 1;
                blnMonday          = false;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    decPayRate         = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].PayRate;
                    decReportedHours   = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TotalHours;
                    datTransactionDate = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TransactionDate;

                    if ((datTransactionDate.DayOfWeek == DayOfWeek.Monday) && (blnMonday == false))
                    {
                        decTotalHours = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TotalHours;
                        intEmployeeID = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].EmployeeID;
                        blnMonday     = true;
                        decMultiplier = 1;
                    }
                    else if (intEmployeeID != TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].EmployeeID)
                    {
                        decTotalHours = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TotalHours;
                        intEmployeeID = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].EmployeeID;
                        decMultiplier = 1;
                    }
                    else if (intEmployeeID == TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].EmployeeID)
                    {
                        decTotalHours += TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TotalHours;

                        if (datTransactionDate.DayOfWeek != DayOfWeek.Monday)
                        {
                            blnMonday = false;
                        }
                    }

                    if (decMultiplier == 1)
                    {
                        if (decTotalHours <= 40)
                        {
                            decTotalCost = decPayRate * decReportedHours;
                        }
                        if (decTotalHours > 40)
                        {
                            decDifference = decTotalHours - 40;
                            decMultiplier = Convert.ToDecimal(1.5);
                            decTotalCost  = ((decReportedHours - decDifference) * decPayRate) + (decDifference * decPayRate * decMultiplier);
                        }
                    }
                    if (decMultiplier == Convert.ToDecimal(1.5))
                    {
                        decTotalCost = decReportedHours * decPayRate * decMultiplier;
                    }

                    EmployeeProductivityDataSet.employeeproductivityRow NewProductivityRow = TheEmployeeProductivityDataSet.employeeproductivity.NewemployeeproductivityRow();

                    NewProductivityRow.AssignedProjectID = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].AssignedProjectID;
                    NewProductivityRow.CalculatedHours   = decTotalHours;
                    NewProductivityRow.EmployeeID        = intEmployeeID;
                    NewProductivityRow.FirstName         = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].FirstName;
                    NewProductivityRow.LastName          = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].LastName;
                    NewProductivityRow.Multiplier        = decMultiplier;
                    NewProductivityRow.PayRate           = decPayRate;
                    NewProductivityRow.ProjectID         = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].ProjectID;
                    NewProductivityRow.ProjectName       = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].ProjectName;
                    NewProductivityRow.TotalCost         = decTotalCost;
                    NewProductivityRow.TotalHours        = decReportedHours;
                    NewProductivityRow.TransactionDate   = TheFindAllDesignEmployeeProductivityOverAWeekDataSet.FindAllDesignEmployeeProductivityOverAWeek[intCounter].TransactionDate;

                    TheEmployeeProductivityDataSet.employeeproductivity.Rows.Add(NewProductivityRow);
                }

                intNumberOfRecords         = TheEmployeeProductivityDataSet.employeeproductivity.Rows.Count - 1;
                gintProjectCounter         = 0;
                gintProjectNumberOfRecords = 0;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnItemFound  = false;
                    intProjectID  = TheEmployeeProductivityDataSet.employeeproductivity[intCounter].ProjectID;
                    decTotalHours = TheEmployeeProductivityDataSet.employeeproductivity[intCounter].TotalHours;
                    decTotalCost  = TheEmployeeProductivityDataSet.employeeproductivity[intCounter].TotalCost;

                    if (gintProjectCounter > 0)
                    {
                        for (intProjectCounter = 0; intProjectCounter <= gintProjectNumberOfRecords; intProjectCounter++)
                        {
                            if (intProjectID == TheCompleteProjectProductivityDataSet.completeprojectproductivity[intProjectCounter].ProjectID)
                            {
                                TheCompleteProjectProductivityDataSet.completeprojectproductivity[intProjectCounter].TotalHours += decTotalHours;
                                TheCompleteProjectProductivityDataSet.completeprojectproductivity[intProjectCounter].TotalCosts += decTotalCost;
                                blnItemFound = true;
                            }
                        }
                    }

                    if (blnItemFound == false)
                    {
                        CompleteProjectProductivityDataSet.completeprojectproductivityRow NewProjectRow = TheCompleteProjectProductivityDataSet.completeprojectproductivity.NewcompleteprojectproductivityRow();

                        decTotalCost = Math.Round(decTotalCost, 2);

                        NewProjectRow.AssignedProjectID = TheEmployeeProductivityDataSet.employeeproductivity[intCounter].AssignedProjectID;
                        NewProjectRow.ProjectID         = intProjectID;
                        NewProjectRow.ProjectName       = TheEmployeeProductivityDataSet.employeeproductivity[intCounter].ProjectName;
                        NewProjectRow.TotalCosts        = decTotalCost;
                        NewProjectRow.TotalHours        = decTotalHours;

                        TheCompleteProjectProductivityDataSet.completeprojectproductivity.Rows.Add(NewProjectRow);
                        gintProjectNumberOfRecords = gintProjectCounter;
                        gintProjectCounter++;
                    }
                }

                dgrResults.ItemsSource = TheCompleteProjectProductivityDataSet.completeprojectproductivity;

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Projects Productivity Costing // Process Button " + Ex.Message);

                TheMessageClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 14
0
        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   strValueForValidation;
            int      intEmployeeID       = 0;
            int      intPayID            = 0;
            DateTime datCreatedDateTime  = DateTime.Now;
            DateTime datPunchedDateTime  = DateTime.Now;
            DateTime datActualDateTime   = DateTime.Now;
            string   strPayGroup         = "";
            string   strPunchMode        = "";
            string   strPunchType        = "";
            string   strPunchSouce       = "";
            string   strPunchIPAddress   = "";
            DateTime datLastUpdate       = DateTime.Now;
            bool     blnFailedValidation = false;
            int      intRecordsReturned;
            double   douProcessDate;
            string   strFirstName = "";
            string   strLastName  = "";
            string   strPunchUser;

            try
            {
                expImportExcel.IsExpanded = false;
                TheImportAholaPunchesDataSet.importaholapunches.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;

                for (intCounter = 2; intCounter < intNumberOfRecords; intCounter++)
                {
                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();

                    blnFailedValidation = TheDataValidationClass.VerifyIntegerData(strValueForValidation);

                    if (blnFailedValidation == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        intPayID = Convert.ToInt32(strValueForValidation);

                        TheFindEmployeeByPayIDDataSet = TheEmployeeClass.FindEmployeeByPayID(intPayID);

                        intRecordsReturned = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            throw new Exception();
                        }
                        else
                        {
                            intEmployeeID = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].EmployeeID;
                            strFirstName  = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].FirstName;
                            strLastName   = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].LastName;
                        }
                    }

                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 8] as Excel.Range).Value2).ToUpper();

                    blnFailedValidation = TheDataValidationClass.VerifyDoubleData(strValueForValidation);

                    if (blnFailedValidation == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        douProcessDate = Convert.ToDouble(strValueForValidation);

                        datActualDateTime = DateTime.FromOADate(douProcessDate);
                    }

                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2).ToUpper();

                    blnFailedValidation = TheDataValidationClass.VerifyDoubleData(strValueForValidation);

                    if (blnFailedValidation == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        douProcessDate = Convert.ToDouble(strValueForValidation);

                        datPunchedDateTime = DateTime.FromOADate(douProcessDate);
                    }

                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 10] as Excel.Range).Value2).ToUpper();

                    blnFailedValidation = TheDataValidationClass.VerifyDateData(strValueForValidation);

                    if (blnFailedValidation == true)
                    {
                        datCreatedDateTime = DateTime.Now;
                    }
                    else
                    {
                        datCreatedDateTime = Convert.ToDateTime(strValueForValidation);
                    }

                    strPayGroup       = Convert.ToString((range.Cells[intCounter, 14] as Excel.Range).Value2).ToUpper();
                    strPunchMode      = Convert.ToString((range.Cells[intCounter, 15] as Excel.Range).Value2).ToUpper();
                    strPunchType      = Convert.ToString((range.Cells[intCounter, 16] as Excel.Range).Value2).ToUpper();
                    strPunchSouce     = Convert.ToString((range.Cells[intCounter, 17] as Excel.Range).Value2).ToUpper();
                    strPunchIPAddress = Convert.ToString((range.Cells[intCounter, 20] as Excel.Range).Value2).ToUpper();
                    strPunchUser      = Convert.ToString((range.Cells[intCounter, 27] as Excel.Range).Value2).ToUpper();

                    strPunchUser = "";

                    //strValueForValidation = Convert.ToString((range.Cells[intCounter, 28] as Excel.Range).Value2).ToUpper();

                    strValueForValidation = Convert.ToString(DateTime.Now);

                    blnFailedValidation = TheDataValidationClass.VerifyDateData(strValueForValidation);

                    if (blnFailedValidation == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        datLastUpdate = Convert.ToDateTime(strValueForValidation);
                    }


                    ImportAholaPunchesDataSet.importaholapunchesRow NewPunchRow = TheImportAholaPunchesDataSet.importaholapunches.NewimportaholapunchesRow();

                    NewPunchRow.ActualDateTime  = datActualDateTime;
                    NewPunchRow.CreatedDateTime = datCreatedDateTime;
                    NewPunchRow.EmployeeID      = intEmployeeID;
                    NewPunchRow.FirstName       = strFirstName;
                    NewPunchRow.LastName        = strLastName;
                    NewPunchRow.LastUpdate      = datLastUpdate;
                    NewPunchRow.PayGroup        = strPayGroup;
                    NewPunchRow.PayID           = intPayID;
                    NewPunchRow.PunchDateTime   = datPunchedDateTime;
                    NewPunchRow.PunchIPAddress  = strPunchIPAddress;
                    NewPunchRow.PunchMode       = strPunchMode;
                    NewPunchRow.PunchSource     = strPunchSouce;
                    NewPunchRow.PunchType       = strPunchType;
                    NewPunchRow.PunchUser       = strPunchUser;

                    TheImportAholaPunchesDataSet.importaholapunches.Rows.Add(NewPunchRow);
                }

                dgrResults.ItemsSource = TheImportAholaPunchesDataSet.importaholapunches;
                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Import Employee Punches // Import Excel  " + Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Punches // Import Excel  " + 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   strIsInside;
            string   strDriver;
            string   strVehicleNumber;
            string   strEventDate;
            double   douEventDate;
            DateTime datEventDate;
            bool     blnIsInSide = false;
            int      intVehicleCounter;
            int      intVehicleNumberOfRecords;
            int      intEmployeeCounter;
            int      intEmployeeNumberOfRecords;
            string   strAssignedOffice = "";
            int      intSubstringLength;
            string   strFullName;
            int      intVehicleID = 0;
            DateTime datStartDate = DateTime.Now;
            DateTime datEndDate   = DateTime.Now;

            try
            {
                TheImportGEOFenceDataSet.importgeofence.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;

                for (intCounter = 5; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strEventDate     = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strIsInside      = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2).ToUpper();
                    strDriver        = Convert.ToString((range.Cells[intCounter, 10] as Excel.Range).Value2).ToUpper();
                    strVehicleNumber = Convert.ToString((range.Cells[intCounter, 11] as Excel.Range).Value2).ToUpper();

                    douEventDate = Convert.ToDouble(strEventDate);
                    datEventDate = DateTime.FromOADate(douEventDate);

                    if (strIsInside == "YES")
                    {
                        blnIsInSide = true;
                    }
                    else
                    {
                        blnIsInSide = false;
                    }

                    ImportGEOFencedDataSet.importgeofenceRow NewGEOFenceTransaction = TheImportGEOFenceDataSet.importgeofence.NewimportgeofenceRow();

                    NewGEOFenceTransaction.Driver        = strDriver;
                    NewGEOFenceTransaction.EmployeeID    = -1;
                    NewGEOFenceTransaction.EventTime     = datEventDate;
                    NewGEOFenceTransaction.VehicleID     = -1;
                    NewGEOFenceTransaction.VehicleNumber = strVehicleNumber;
                    NewGEOFenceTransaction.InSide        = blnIsInSide;

                    TheImportGEOFenceDataSet.importgeofence.Rows.Add(NewGEOFenceTransaction);
                }

                dgrResults.ItemsSource = TheImportGEOFenceDataSet.importgeofence;

                TheMessagesClass.InformationMessage("Click OK to Continue");

                intNumberOfRecords        = TheImportGEOFenceDataSet.importgeofence.Rows.Count - 1;
                intVehicleNumberOfRecords = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    for (intVehicleCounter = 0; intVehicleCounter <= intVehicleNumberOfRecords; intVehicleCounter++)
                    {
                        strVehicleNumber = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intVehicleCounter].VehicleNumber;

                        if (TheImportGEOFenceDataSet.importgeofence[intCounter].VehicleNumber.Contains(strVehicleNumber) == true)
                        {
                            TheImportGEOFenceDataSet.importgeofence[intCounter].VehicleID     = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intVehicleCounter].VehicleID;
                            TheImportGEOFenceDataSet.importgeofence[intCounter].VehicleNumber = strVehicleNumber;
                            strAssignedOffice = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intVehicleCounter].AssignedOffice;
                            intVehicleID      = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intVehicleCounter].VehicleID;
                            datStartDate      = TheDateSearchClass.RemoveTime(TheImportGEOFenceDataSet.importgeofence[intCounter].EventTime);
                            datEndDate        = TheDateSearchClass.AddingDays(datStartDate, 1);
                        }
                    }

                    strDriver = TheImportGEOFenceDataSet.importgeofence[intCounter].Driver;

                    if (strDriver == "NO DRIVER CHECKED IN")
                    {
                        intEmployeeNumberOfRecords = TheFindWarehouseDataSet.FindWarehouses.Rows.Count - 1;

                        for (intEmployeeCounter = 0; intEmployeeCounter <= intEmployeeNumberOfRecords; intEmployeeCounter++)
                        {
                            if (strAssignedOffice == TheFindWarehouseDataSet.FindWarehouses[intEmployeeCounter].FirstName)
                            {
                                TheImportGEOFenceDataSet.importgeofence[intCounter].EmployeeID = TheFindWarehouseDataSet.FindWarehouses[intEmployeeCounter].EmployeeID;
                            }
                        }
                    }
                    else
                    {
                        TheFindEmployeeByLastDataSet = TheEmployeeClass.FindEmployeesByLastNameKeyWord(strDriver);

                        intEmployeeNumberOfRecords = TheFindEmployeeByLastDataSet.FindEmployeeByLastName.Rows.Count - 1;

                        if (intEmployeeNumberOfRecords == 0)
                        {
                            TheImportGEOFenceDataSet.importgeofence[intCounter].EmployeeID = TheFindEmployeeByLastDataSet.FindEmployeeByLastName[0].EmployeeID;
                        }
                        else
                        {
                            TheFindDailyVehicleInspectionByVehicleIDandDateRangeDataSet = TheInspectionsClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(intVehicleID, datStartDate, datEndDate);

                            intEmployeeNumberOfRecords = TheFindDailyVehicleInspectionByVehicleIDandDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count;

                            if (intEmployeeNumberOfRecords > 0)
                            {
                                TheImportGEOFenceDataSet.importgeofence[intCounter].EmployeeID = TheFindDailyVehicleInspectionByVehicleIDandDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[0].EmployeeID;
                            }
                            else
                            {
                                intEmployeeNumberOfRecords = TheFindWarehouseDataSet.FindWarehouses.Rows.Count - 1;

                                for (intEmployeeCounter = 0; intEmployeeCounter <= intEmployeeNumberOfRecords; intEmployeeCounter++)
                                {
                                    if (strAssignedOffice == TheFindWarehouseDataSet.FindWarehouses[intEmployeeCounter].FirstName)
                                    {
                                        TheImportGEOFenceDataSet.importgeofence[intCounter].EmployeeID = TheFindWarehouseDataSet.FindWarehouses[intEmployeeCounter].EmployeeID;
                                    }
                                }
                            }
                        }
                    }
                }

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import GEO Fence Report // Import Excel  " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 16
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string   strValueForValidation;
            bool     blnFatalError = false;
            DateTime datStartDate  = DateTime.Now;
            DateTime datTodaysDate = DateTime.Now;
            string   strKeyword;
            int      intRecordsReturned;

            try
            {
                TheFindServerLogAccessByEmployeeIDDataSet = TheEventLogClass.FindServerLogAccessByEmployeeID(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID);

                intRecordsReturned = TheFindServerLogAccessByEmployeeIDDataSet.FindServerLogAccessByEmmployeeID.Rows.Count;

                if (intRecordsReturned < 0)
                {
                    TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Server Audit Log // THERE HAS BEEN AN ATTEMPT TO ACCESS THROUGH ERP");

                    TheMessagesClass.ErrorMessage("ACCESS DENIED, IT HAS BEEN NOTIFIED");
                    throw new Exception();
                }

                blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Server Audit Log");

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

                //beginning data validation
                strValueForValidation = txtStartDate.Text;
                blnFatalError         = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("The Start Date is not a Date");
                    return;
                }
                else
                {
                    datStartDate = Convert.ToDateTime(strValueForValidation);

                    blnFatalError = TheDataValidationClass.verifyDateRange(datStartDate, datTodaysDate);

                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage("The Start Date is after Todays Date");
                        return;
                    }
                }
                strKeyword = txtKeyword.Text;
                if (strKeyword.Length < 3)
                {
                    TheMessagesClass.ErrorMessage("The Search Term is not Long Enough");
                    return;
                }

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                TheFindServerEventLogByNoteKeywordDataSet = TheEventLogClass.FindServerEventLogByNoteKeyword(strKeyword, datStartDate, datTodaysDate);

                string strTestVarialbe = TheFindServerEventLogByNoteKeywordDataSet.FindServerLogByNoteKeyword[0].EventNotes;

                dgrResults.ItemsSource = TheFindServerEventLogByNoteKeywordDataSet.FindServerLogByNoteKeyword;

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Server Audit Log // Search Button " + Ex.Message);

                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Server Audit Log // Search Button " + Ex.ToString());

                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  strValueForValidation;
            int     intAssetTag;
            string  strAssetDescription;
            string  strSerialNumber;
            string  strCategoryName;
            decimal decAssetCost = 0;
            bool    blnNotNumeric;
            int     intQuantity = 0;
            int     intAssetCounter;
            bool    blnItemFound;
            string  strLocation = "";
            int     intCharacterIndex;

            try
            {
                expImportExcel.IsExpanded = false;
                TheAssetsForReportingDataSet.assetsforreport.Rows.Clear();
                TheAssetCategoryCostDataSet.assetcategorycost.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;
                gintAssetNumberOfRecords = 0;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2);

                    if (strValueForValidation != null)
                    {
                        blnNotNumeric = TheDataValidationClass.VerifyIntegerData(strValueForValidation);

                        if (blnNotNumeric == false)
                        {
                            blnItemFound        = false;
                            intAssetTag         = Convert.ToInt32(strValueForValidation);
                            strAssetDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2);
                            strSerialNumber     = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2);
                            if (strSerialNumber == null)
                            {
                                strSerialNumber = "";
                            }
                            strCategoryName = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2);
                            if (strCategoryName == null)
                            {
                                strCategoryName = "UNKNOWN";
                            }
                            strValueForValidation = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2);
                            blnNotNumeric         = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                            if (blnNotNumeric == false)
                            {
                                decAssetCost = Convert.ToDecimal(strValueForValidation);
                            }
                            else
                            {
                                decAssetCost = 0;
                            }
                            strValueForValidation = Convert.ToString((range.Cells[intCounter, 8] as Excel.Range).Value2);
                            blnNotNumeric         = TheDataValidationClass.VerifyIntegerRange(strValueForValidation);
                            if (blnNotNumeric == false)
                            {
                                intQuantity = Convert.ToInt32(strValueForValidation);
                            }
                            else
                            {
                                intQuantity = 0;
                            }

                            AssetsForReportDataSet.assetsforreportRow NewAssetRow = TheAssetsForReportingDataSet.assetsforreport.NewassetsforreportRow();

                            NewAssetRow.AssetCategory   = strCategoryName;
                            NewAssetRow.AssetCost       = decAssetCost;
                            NewAssetRow.AssetDecription = strAssetDescription;
                            NewAssetRow.AssetTag        = intAssetTag;
                            NewAssetRow.SerialNumber    = strSerialNumber;
                            NewAssetRow.Quantity        = intQuantity;
                            NewAssetRow.Location        = strLocation;

                            TheAssetsForReportingDataSet.assetsforreport.Rows.Add(NewAssetRow);

                            if (gintAssetNumberOfRecords > 0)
                            {
                                for (intAssetCounter = 0; intAssetCounter < gintAssetNumberOfRecords; intAssetCounter++)
                                {
                                    if (strCategoryName == TheAssetCategoryCostDataSet.assetcategorycost[intAssetCounter].AssetCategory)
                                    {
                                        TheAssetCategoryCostDataSet.assetcategorycost[intAssetCounter].CategoryCosts += decAssetCost;
                                        blnItemFound = true;
                                    }
                                }
                            }

                            if (blnItemFound == false)
                            {
                                AssetCategoryCostDataSet.assetcategorycostRow NewCategoryCost = TheAssetCategoryCostDataSet.assetcategorycost.NewassetcategorycostRow();

                                NewCategoryCost.AssetCategory = strCategoryName;
                                NewCategoryCost.CategoryCosts = decAssetCost;

                                TheAssetCategoryCostDataSet.assetcategorycost.Rows.Add(NewCategoryCost);
                                gintAssetNumberOfRecords++;
                            }
                        }
                        else if (strValueForValidation.Contains("Location"))
                        {
                            if (strValueForValidation.Contains("Location Prefix") == false)
                            {
                                strLocation = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2);

                                if (strLocation != null)
                                {
                                    intCharacterIndex = strLocation.IndexOf(':');

                                    strLocation = strLocation.Substring(0, intCharacterIndex);
                                }
                            }
                        }
                    }
                }

                PleaseWait.Close();
                dgrAssets.ItemsSource = TheAssetsForReportingDataSet.assetsforreport;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Prepare Asset Report // Import Excel Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 18
0
        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   strTowMotorNumber;
            string   strTowMotorYear;
            int      intTowMotorYear;
            string   strTowMotorMake;
            string   strTowMotorModel;
            string   strTowMotorHours;
            decimal  decTowMotorHours;
            string   strWarehouse;
            int      intWarehouseID = 0;
            string   strOilChangeDate;
            DateTime datOilChangeDate;
            bool     blnActive = true;
            int      intWarehouseCounter;
            int      intWarehouseNumberOfRecords;
            string   strSerialNumber;
            string   strWeight;
            int      intWeight;
            string   strCapacity;
            int      intCapacity;

            try
            {
                TheImportTowMotorDataSet.importtowmotors.Rows.Clear();
                TheFindWarehousesDataSet    = TheEmployeeClass.FindWarehouses();
                intWarehouseNumberOfRecords = TheFindWarehousesDataSet.FindWarehouses.Rows.Count - 1;

                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;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strTowMotorNumber = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strTowMotorYear   = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    intTowMotorYear   = Convert.ToInt32(strTowMotorYear);
                    strTowMotorMake   = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                    strTowMotorModel  = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();
                    strSerialNumber   = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper();
                    strTowMotorHours  = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2).ToUpper();
                    decTowMotorHours  = Convert.ToDecimal(strTowMotorHours);
                    strWarehouse      = Convert.ToString((range.Cells[intCounter, 7] as Excel.Range).Value2).ToUpper();
                    strWeight         = Convert.ToString((range.Cells[intCounter, 8] as Excel.Range).Value2).ToUpper();
                    intWeight         = Convert.ToInt32(strWeight);
                    strCapacity       = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2).ToUpper();
                    intCapacity       = Convert.ToInt32(strCapacity);

                    for (intWarehouseCounter = 0; intWarehouseCounter <= intWarehouseNumberOfRecords; intWarehouseCounter++)
                    {
                        if (strWarehouse == TheFindWarehousesDataSet.FindWarehouses[intWarehouseCounter].FirstName)
                        {
                            intWarehouseID = TheFindWarehousesDataSet.FindWarehouses[intWarehouseCounter].EmployeeID;
                        }
                    }

                    strOilChangeDate = Convert.ToString((range.Cells[intCounter, 8] as Excel.Range).Value2).ToUpper();
                    DateTime.TryParse(strOilChangeDate, out datOilChangeDate);

                    ImportTowMotorDataSet.importtowmotorsRow NewTowMotorRow = TheImportTowMotorDataSet.importtowmotors.NewimporttowmotorsRow();

                    NewTowMotorRow.TowMotorNumber   = strTowMotorNumber;
                    NewTowMotorRow.TowMotorYear     = intTowMotorYear;
                    NewTowMotorRow.TowMotorMake     = strTowMotorMake;
                    NewTowMotorRow.TowMotorModel    = strTowMotorModel;
                    NewTowMotorRow.TowMotorHours    = decTowMotorHours;
                    NewTowMotorRow.WarehouseID      = intWarehouseID;
                    NewTowMotorRow.OilChangeDate    = DateTime.Now;
                    NewTowMotorRow.TowMotorActive   = blnActive;
                    NewTowMotorRow.TowMotorSerialNo = strSerialNumber;
                    NewTowMotorRow.TowMotorWeight   = intWeight;
                    NewTowMotorRow.TowMotorCapacity = intCapacity;

                    TheImportTowMotorDataSet.importtowmotors.Rows.Add(NewTowMotorRow);
                }

                dgrTowMotors.ItemsSource = TheImportTowMotorDataSet.importtowmotors;

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Tow Motors // Import Excel  " + 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 strPartLocation;
            string strJDEPartNumber;
            int    intPartID;
            string strOldPartNumber;
            string strPartDescription;
            int    intRecordsReturned;

            try
            {
                TheImportInventoryLocationdDataSet.importinventorylocations.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;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strPartNumber   = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strPartLocation = 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;
                        strPartDescription = TheFindPartByPartNumberDataSet.FindPartByPartNumber[0].PartDescription;

                        TheFindMasterPartByPartIDDataSet = ThePartNumberClass.FindMasterPartByPartID(intPartID);

                        intRecordsReturned = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID.Rows.Count;

                        strOldPartNumber = "NONE FOUND";

                        if (intRecordsReturned > 0)
                        {
                            strOldPartNumber = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID[0].PartNumber;
                        }

                        ImportInventoryLocationsDataSet.importinventorylocationsRow NewPartRow = TheImportInventoryLocationdDataSet.importinventorylocations.NewimportinventorylocationsRow();

                        NewPartRow.JDEPartNumber   = strJDEPartNumber;
                        NewPartRow.Location        = strPartLocation;
                        NewPartRow.OldPartNumber   = strOldPartNumber;
                        NewPartRow.PartDescription = strPartDescription;
                        NewPartRow.PartID          = intPartID;
                        NewPartRow.PartNumber      = strPartNumber;
                        NewPartRow.ToBeImported    = true;

                        TheImportInventoryLocationdDataSet.importinventorylocations.Rows.Add(NewPartRow);
                    }
                    else if (intRecordsReturned < 1)
                    {
                        strJDEPartNumber = strPartNumber;

                        TheFindPartByJDEPartNumberDataSet = ThePartNumberClass.FindPartByJDEPartNumber(strJDEPartNumber);

                        intRecordsReturned = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            intPartID          = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartID;
                            strPartNumber      = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartNumber;
                            strPartDescription = TheFindPartByJDEPartNumberDataSet.FindPartByJDEPartNumber[0].PartDescription;

                            TheFindMasterPartByPartIDDataSet = ThePartNumberClass.FindMasterPartByPartID(intPartID);

                            intRecordsReturned = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID.Rows.Count;

                            strOldPartNumber = "NONE FOUND";

                            if (intRecordsReturned > 0)
                            {
                                strOldPartNumber = TheFindMasterPartByPartIDDataSet.FindMasterPartListPartByPartID[0].PartNumber;
                            }

                            ImportInventoryLocationsDataSet.importinventorylocationsRow NewPartRow = TheImportInventoryLocationdDataSet.importinventorylocations.NewimportinventorylocationsRow();

                            NewPartRow.JDEPartNumber   = strJDEPartNumber;
                            NewPartRow.Location        = strPartLocation;
                            NewPartRow.OldPartNumber   = strOldPartNumber;
                            NewPartRow.PartDescription = strPartDescription;
                            NewPartRow.PartID          = intPartID;
                            NewPartRow.PartNumber      = strPartNumber;
                            NewPartRow.ToBeImported    = true;

                            TheImportInventoryLocationdDataSet.importinventorylocations.Rows.Add(NewPartRow);
                        }
                    }
                }

                PleaseWait.Close();

                dgrImportedInformation.ItemsSource = TheImportInventoryLocationdDataSet.importinventorylocations;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Inventory Locations // Import Excel  " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 20
0
        private void btnImportExcel_Click(object sender, RoutedEventArgs e)
        {
            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            int    intColumnRange = 0;
            int    intCounter;
            int    intNumberOfRecords;
            int    intRecordsReturned;
            int    intAssetID;
            string strAssetDescription;
            string strLocation;
            string strSerialNumber;
            string strAssetType;
            string strBJCNumber;
            bool   blnFatalError   = false;
            string strErrorMessage = "";
            bool   blnItemFound;
            int    intTransactionID;
            string strModel;
            string strManufacturer;

            try
            {
                TheImportWaspToolAssetsDataSet.importassets.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();

                strLocation = txtEnterLocation.Text;
                if (strLocation.Length < 2)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Location is not long Enough\n";
                }
                else
                {
                    TheFindWaspAssetLocationByLocationDataSet = TheAssetClass.FindWaspAssetLocationByLocation(strLocation);

                    intRecordsReturned = TheFindWaspAssetLocationByLocationDataSet.FindWaspAssetLocationByLocation.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "There is no Such Location\n";
                    }
                }
                if (cboSelectLocation.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Site Has Not Been Selected\n";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                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;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    TheWaspAssetIDDataSet = TheAssetClass.GetWaspAssetIDInfo();

                    intAssetID       = TheWaspAssetIDDataSet.waspassetid[0].CreatedAssetID;
                    intTransactionID = TheWaspAssetIDDataSet.waspassetid[0].TransactionID;

                    blnFatalError = TheAssetClass.UpdateWaspAssetID(intTransactionID, intAssetID + 1);

                    blnItemFound = false;
                    strAssetType = "UNKNOWN";

                    if (((range.Cells[intCounter, 2] as Excel.Range).Value2) == null)
                    {
                        intCounter = intNumberOfRecords;
                        break;
                    }
                    else
                    {
                        strAssetDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();

                        if (((range.Cells[intCounter, 3] as Excel.Range).Value2) == null)
                        {
                            strSerialNumber = " ";
                        }
                        else
                        {
                            strSerialNumber = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                        }
                        if (((range.Cells[intCounter, 4] as Excel.Range).Value2) == null)
                        {
                            strBJCNumber = " ";
                        }
                        else
                        {
                            strBJCNumber = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();
                        }

                        if (strSerialNumber.Length > 2)
                        {
                            TheFindWaspAssetBySerialNumberDataSet = TheAssetClass.FindWaspAssetsBySerialNumber(strSerialNumber);

                            intRecordsReturned = TheFindWaspAssetBySerialNumberDataSet.FindWaspAssetsBySerialNumber.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                blnItemFound = true;
                            }
                        }
                        if (strBJCNumber.Length > 2)
                        {
                            TheFindWaspAssetByBJCAssetIDDataSet = TheAssetClass.FindWaspAssetByBJCAssetID(strBJCNumber);

                            intRecordsReturned = TheFindWaspAssetByBJCAssetIDDataSet.FindWaspAssetByBJCAssetID.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                blnItemFound = true;
                            }
                        }
                    }

                    if (blnItemFound == false)
                    {
                        if (strBJCNumber.Length > 2)
                        {
                            TheFindActiveToolByToolIDDataSet = TheToolClass.FindActiveToolByToolID(strBJCNumber);

                            intRecordsReturned = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                strAssetType        = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolCategory;
                                strAssetDescription = TheFindActiveToolByToolIDDataSet.FindActiveToolByToolID[0].ToolDescription;
                            }
                        }

                        ImportWaspToolAssetsDataSet.importassetsRow NewAssetRow = TheImportWaspToolAssetsDataSet.importassets.NewimportassetsRow();

                        NewAssetRow.AssetDescription = strAssetDescription;
                        NewAssetRow.AssetID          = intAssetID;
                        NewAssetRow.AssetType        = strAssetType;
                        NewAssetRow.Location         = strLocation;
                        NewAssetRow.Manufacturer     = "UNKNOWN";
                        NewAssetRow.Model            = "UNKNOWN";
                        NewAssetRow.SerialNumber     = strSerialNumber;
                        NewAssetRow.Site             = gstrSite;
                        NewAssetRow.WarehouseID      = MainWindow.gintWarehouseID;
                        NewAssetRow.BJCAssetID       = strBJCNumber;

                        TheImportWaspToolAssetsDataSet.importassets.Rows.Add(NewAssetRow);
                    }
                }

                intNumberOfRecords = TheImportWaspToolAssetsDataSet.importassets.Rows.Count;

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        strAssetDescription = TheImportWaspToolAssetsDataSet.importassets[intCounter].AssetDescription;
                        strAssetType        = TheImportWaspToolAssetsDataSet.importassets[intCounter].AssetType;
                        intAssetID          = TheImportWaspToolAssetsDataSet.importassets[intCounter].AssetID;
                        strBJCNumber        = TheImportWaspToolAssetsDataSet.importassets[intCounter].BJCAssetID;
                        strLocation         = TheImportWaspToolAssetsDataSet.importassets[intCounter].Location;
                        strManufacturer     = TheImportWaspToolAssetsDataSet.importassets[intCounter].Manufacturer;
                        strModel            = TheImportWaspToolAssetsDataSet.importassets[intCounter].Model;
                        strSerialNumber     = TheImportWaspToolAssetsDataSet.importassets[intCounter].SerialNumber;

                        blnFatalError = TheAssetClass.InsertWaspAssets(intAssetID, strAssetDescription, strBJCNumber, strAssetType, gstrSite, strLocation, MainWindow.gintWarehouseID, DateTime.Now, strSerialNumber, strManufacturer, strModel);

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

                PleaseWait.Close();

                dgrAssets.ItemsSource = TheImportWaspToolAssetsDataSet.importassets;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Vehicle Assets // Import Excel  " + 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 strWorkTask;
            int    intRecordsReturned;

            try
            {
                expImportExcel.IsExpanded = false;
                TheImportNonProductionTasksDataSet.importnonproductiontasks.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;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strWorkTask = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();

                    TheFindNonProductionTaskByWorkTaskDataSet = TheNonProductionProductivityClass.FindNOnProductionTaskByWorkTask(strWorkTask);

                    intRecordsReturned = TheFindNonProductionTaskByWorkTaskDataSet.FindNonProductionTaskByWorkTask.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        ImportNonProductionTasksDataSet.importnonproductiontasksRow NewTaskRow = TheImportNonProductionTasksDataSet.importnonproductiontasks.NewimportnonproductiontasksRow();

                        NewTaskRow.WorkTask = strWorkTask;

                        TheImportNonProductionTasksDataSet.importnonproductiontasks.Rows.Add(NewTaskRow);
                    }
                }

                PleaseWait.Close();

                dgrWorkTasks.ItemsSource = TheImportNonProductionTasksDataSet.importnonproductiontasks;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Non-Production Tasks // Import Excel  " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 22
0
        private void expProcessData_Expanded(object sender, RoutedEventArgs e)
        {
            int      intNumberOfRecords;
            int      intCounter;
            int      intPayID;
            int      intEmployeeID;
            DateTime datActualDateTime;
            DateTime datPunchDateTime;
            DateTime datCreatedDateTime;
            string   strPayGroup;
            string   strPunchMode;
            string   strPunchType;
            string   strPunchUser;
            string   strPunchIPAddress;
            DateTime datLastUpdate;
            bool     blnFatalError = false;
            int      intRecordsReturned;
            string   strPunchSource;

            try
            {
                expProcessData.IsExpanded = false;
                intNumberOfRecords        = TheImportAholaPunchesDataSet.importaholapunches.Rows.Count;

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        intPayID           = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PayID;
                        intEmployeeID      = TheImportAholaPunchesDataSet.importaholapunches[intCounter].EmployeeID;
                        datActualDateTime  = TheImportAholaPunchesDataSet.importaholapunches[intCounter].ActualDateTime;
                        datPunchDateTime   = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchDateTime;
                        datCreatedDateTime = TheImportAholaPunchesDataSet.importaholapunches[intCounter].CreatedDateTime;
                        strPayGroup        = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PayGroup;
                        strPunchMode       = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchMode;
                        strPunchType       = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchType;
                        strPunchSource     = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchSource;
                        strPunchUser       = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchUser;
                        strPunchIPAddress  = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchIPAddress;
                        datLastUpdate      = TheImportAholaPunchesDataSet.importaholapunches[intCounter].LastUpdate;

                        TheFindAholaClockPunchesForVerificationDataSet = TheEmployeePunchedHoursClass.FindAholaClockPunchesForVerification(intPayID, datActualDateTime, datPunchDateTime, datCreatedDateTime, strPunchIPAddress);

                        intRecordsReturned = TheFindAholaClockPunchesForVerificationDataSet.FindAholaClockPunchesForVerification.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            blnFatalError = TheEmployeePunchedHoursClass.InsertAholaClockPunches(intEmployeeID, intPayID, datActualDateTime, datPunchDateTime, datCreatedDateTime, strPayGroup, strPunchMode, strPunchType, strPunchSource, strPunchUser, strPunchIPAddress, datLastUpdate);

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

                PleaseWait.Close();
                TheMessagesClass.InformationMessage("All Records Have Been Inserted");

                expCalculateHours.IsEnabled = true;
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Import Employee Punches // Process Data Expander " + Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Punches // Process Data Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 23
0
        private void expExportToExcel_Expanded(object sender, RoutedEventArgs e)
        {
            int intRowCounter;
            int intRowNumberOfRecords;
            int intColumnCounter;
            int intColumnNumberOfRecords;

            // Creating a Excel object.
            Microsoft.Office.Interop.Excel._Application excel     = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook    workbook  = excel.Workbooks.Add(Type.Missing);
            Microsoft.Office.Interop.Excel._Worksheet   worksheet = null;

            try
            {
                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                expExportToExcel.IsExpanded = false;

                worksheet = workbook.ActiveSheet;

                worksheet.Name = "OpenOrders";

                int cellRowIndex    = 1;
                int cellColumnIndex = 1;
                intRowNumberOfRecords    = TheCompleteProjectProductivityDataSet.completeprojectproductivity.Rows.Count;
                intColumnNumberOfRecords = TheCompleteProjectProductivityDataSet.completeprojectproductivity.Columns.Count;

                for (intColumnCounter = 0; intColumnCounter < intColumnNumberOfRecords; intColumnCounter++)
                {
                    worksheet.Cells[cellRowIndex, cellColumnIndex] = TheCompleteProjectProductivityDataSet.completeprojectproductivity.Columns[intColumnCounter].ColumnName;

                    cellColumnIndex++;
                }

                cellRowIndex++;
                cellColumnIndex = 1;

                //Loop through each row and read value from each column.
                for (intRowCounter = 0; intRowCounter < intRowNumberOfRecords; intRowCounter++)
                {
                    for (intColumnCounter = 0; intColumnCounter < intColumnNumberOfRecords; intColumnCounter++)
                    {
                        worksheet.Cells[cellRowIndex, cellColumnIndex] = TheCompleteProjectProductivityDataSet.completeprojectproductivity.Rows[intRowCounter][intColumnCounter].ToString();

                        cellColumnIndex++;
                    }
                    cellColumnIndex = 1;
                    cellRowIndex++;
                }

                PleaseWait.Close();

                //Getting the location and file name of the excel to save from user.
                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.Filter      = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
                saveDialog.FilterIndex = 1;

                saveDialog.ShowDialog();

                workbook.SaveAs(saveDialog.FileName);
                MessageBox.Show("Export Successful");
            }
            catch (System.Exception ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP //Projects Productivity Costing // Export To Excel " + ex.Message);

                MessageBox.Show(ex.ToString());
            }
            finally
            {
                excel.Quit();
                workbook = null;
                excel    = null;
            }
        }
Exemplo n.º 24
0
        private void expCalculateHours_Expanded(object sender, RoutedEventArgs e)
        {
            //setting up the variables
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID = 0;
            string   strFirstName  = "";
            string   strLastName   = "";
            DateTime datStartDate;
            DateTime datEndDate = DateTime.Now;
            string   strPunchType;
            string   strPunchSource;
            decimal  decDailyHours = 0;
            TimeSpan tspTotalHours;
            int      intSecondCounter;
            bool     blnRecordFound;
            int      intPayID;

            try
            {
                expCalculateHours.IsExpanded = false;
                TheCalculatedHoursDataSet.calculatedhours.Rows.Clear();
                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();
                gintPunchRecords = 0;

                intNumberOfRecords = TheImportAholaPunchesDataSet.importaholapunches.Rows.Count;

                if (intNumberOfRecords > 0)
                {
                    for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                    {
                        blnRecordFound = false;
                        intEmployeeID  = TheImportAholaPunchesDataSet.importaholapunches[intCounter].EmployeeID;
                        strFirstName   = TheImportAholaPunchesDataSet.importaholapunches[intCounter].FirstName;
                        strLastName    = TheImportAholaPunchesDataSet.importaholapunches[intCounter].LastName;
                        datStartDate   = TheImportAholaPunchesDataSet.importaholapunches[intCounter].ActualDateTime;
                        intPayID       = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PayID;


                        if (TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchMode == "OUT")
                        {
                            datEndDate = TheImportAholaPunchesDataSet.importaholapunches[intCounter].ActualDateTime;
                        }

                        else
                        {
                            if (intCounter + 1 < intNumberOfRecords)
                            {
                                if (intEmployeeID == TheImportAholaPunchesDataSet.importaholapunches[intCounter + 1].EmployeeID)
                                {
                                    datEndDate = TheImportAholaPunchesDataSet.importaholapunches[intCounter + 1].ActualDateTime;

                                    intCounter++;
                                }
                                else if (intEmployeeID == TheImportAholaPunchesDataSet.importaholapunches[intCounter - 1].EmployeeID)
                                {
                                    //datStartDate = TheImportAholaPunchesDataSet.importaholapunches[intCounter - 1].ActualDateTime;
                                }
                            }
                            else
                            {
                                datEndDate = datStartDate;
                            }
                        }

                        if (TheImportAholaPunchesDataSet.importaholapunches[intCounter - 1].PunchMode == "IN")
                        {
                            datEndDate   = TheImportAholaPunchesDataSet.importaholapunches[intCounter].ActualDateTime;
                            datStartDate = TheImportAholaPunchesDataSet.importaholapunches[intCounter - 1].ActualDateTime;
                        }


                        tspTotalHours = datEndDate - datStartDate;

                        decDailyHours = Convert.ToDecimal(tspTotalHours.TotalHours);

                        if (decDailyHours < 0)
                        {
                            tspTotalHours = datStartDate - datEndDate;

                            decDailyHours = Convert.ToDecimal(tspTotalHours.TotalHours);
                        }

                        decDailyHours = Math.Round(decDailyHours, 3);

                        strPunchSource = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchSource;
                        strPunchType   = TheImportAholaPunchesDataSet.importaholapunches[intCounter].PunchType;


                        if (gintPunchRecords > 0)
                        {
                            for (intSecondCounter = 0; intSecondCounter < gintPunchRecords; intSecondCounter++)
                            {
                                if (intEmployeeID == TheCalculatedHoursDataSet.calculatedhours[intSecondCounter].EmployeeID)
                                {
                                    if (datStartDate.Hour == 0)
                                    {
                                    }
                                    else if (datStartDate == TheCalculatedHoursDataSet.calculatedhours[intSecondCounter].StartTime)
                                    {
                                        blnRecordFound = true;
                                    }
                                    else if (datStartDate == TheCalculatedHoursDataSet.calculatedhours[intSecondCounter].EndTime)
                                    {
                                        if (TheImportAholaPunchesDataSet.importaholapunches[intCounter - 1].PunchMode != "IN")
                                        {
                                            blnRecordFound = true;
                                        }
                                    }
                                }
                            }
                        }


                        if (blnRecordFound == false)
                        {
                            CalculatedHoursDataSet.calculatedhoursRow NewPunchRow = TheCalculatedHoursDataSet.calculatedhours.NewcalculatedhoursRow();

                            NewPunchRow.DailyHours = decDailyHours;
                            NewPunchRow.EmployeeID = intEmployeeID;
                            NewPunchRow.EndTime    = datEndDate;
                            NewPunchRow.FirstName  = strFirstName;
                            NewPunchRow.LastName   = strLastName;
                            NewPunchRow.StartTime  = datStartDate;
                            NewPunchRow.PayID      = intPayID;

                            TheCalculatedHoursDataSet.calculatedhours.Rows.Add(NewPunchRow);
                            gintPunchRecords++;
                        }
                    }
                }

                dgrResults.ItemsSource    = TheCalculatedHoursDataSet.calculatedhours;
                expProcessHours.IsEnabled = true;

                PleaseWait.Close();

                TheMessagesClass.InformationMessage("Hours Have Been Calculated");
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Import Employee Punches // Calculate Hours Expander " + Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Punches // Calculate Hours Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 25
0
        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;
            int    intWorkTaskID = 0;
            string strWorkTask   = "";
            string strWorkTaskID = "";
            string strBusinessLine;
            string strBusinessLineID;
            int    intBusinessLineID;
            string strDepartment;
            int    intDepartmentID;
            int    intDepartmentID2 = 0;
            string strDepartment2   = "";
            bool   blnAll           = false;
            int    intRecordsReturned;


            try
            {
                expImportExcel.IsExpanded = false;
                TheProductionCodesForImportDataSet.productioncodes.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;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnAll          = false;
                    strWorkTaskID   = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strWorkTask     = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    intWorkTaskID   = Convert.ToInt32(strWorkTaskID);
                    strBusinessLine = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                    strDepartment   = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();

                    TheFindWorkTaskByTaskKeyWordDataSet = TheWorkTaskClass.FindWorkTaskByTaskKeyword(strWorkTask);

                    intRecordsReturned = TheFindWorkTaskByTaskKeyWordDataSet.FindWorkTaskByTaskKeyword.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        intWorkTaskID = TheFindWorkTaskByTaskKeyWordDataSet.FindWorkTaskByTaskKeyword[0].WorkTaskID;
                    }

                    TheFindDepartmentByNameDataSet = TheDepartmentClass.FindDepartmentByName(strBusinessLine);

                    intBusinessLineID = TheFindDepartmentByNameDataSet.FindDepartmentByName[0].DepartmentID;

                    if (strDepartment == "ALL")
                    {
                        strDepartment  = "AERIAL";
                        strDepartment2 = "UNDERGROUND";
                        blnAll         = true;
                    }

                    TheFindDepartmentByNameDataSet = TheDepartmentClass.FindDepartmentByName(strDepartment);

                    intDepartmentID = TheFindDepartmentByNameDataSet.FindDepartmentByName[0].DepartmentID;

                    TheFindWorkTaskByTaskIDDataSet = TheWorkTaskClass.FindWorkTaskByWorkTaskID(intWorkTaskID);

                    ProductionCodesForImportDataSet.productioncodesRow NewProductionCode = TheProductionCodesForImportDataSet.productioncodes.NewproductioncodesRow();

                    NewProductionCode.BusinessLine   = strBusinessLine;
                    NewProductionCode.BusinessLineID = intBusinessLineID;
                    NewProductionCode.Department     = strDepartment;
                    NewProductionCode.DepartmentID   = intDepartmentID;
                    NewProductionCode.WorkTask       = strWorkTask;
                    NewProductionCode.WorkTaskID     = intWorkTaskID;

                    TheProductionCodesForImportDataSet.productioncodes.Rows.Add(NewProductionCode);

                    if (blnAll == true)
                    {
                        TheFindDepartmentByNameDataSet = TheDepartmentClass.FindDepartmentByName(strDepartment2);

                        intDepartmentID2 = TheFindDepartmentByNameDataSet.FindDepartmentByName[0].DepartmentID;

                        ProductionCodesForImportDataSet.productioncodesRow NewProductionCode2 = TheProductionCodesForImportDataSet.productioncodes.NewproductioncodesRow();

                        NewProductionCode2.BusinessLine   = strBusinessLine;
                        NewProductionCode2.BusinessLineID = intBusinessLineID;
                        NewProductionCode2.Department     = strDepartment2;
                        NewProductionCode2.DepartmentID   = intDepartmentID2;
                        NewProductionCode2.WorkTask       = strWorkTask;
                        NewProductionCode2.WorkTaskID     = intWorkTaskID;

                        TheProductionCodesForImportDataSet.productioncodes.Rows.Add(NewProductionCode2);
                    }
                }

                dgrProductionCodes.ItemsSource = TheProductionCodesForImportDataSet.productioncodes;

                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Codes for Sheets // Import Excel  " + Ex.Message);

                TheMessageClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 26
0
        private void expInsertRecords_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID;
            int      intPayID;;
            DateTime datStartDate;
            DateTime datEndDate;
            DateTime datPayDate;
            decimal  decDailyHours;;
            decimal  decTotalHours;
            bool     blnFatalError = false;
            int      intRecordsReturned;

            try
            {
                expInsertRecords.IsExpanded = false;

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                intNumberOfRecords = TheCalculatedHoursDataSet.calculatedhours.Rows.Count;

                for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                {
                    intEmployeeID = TheCalculatedHoursDataSet.calculatedhours[intCounter].EmployeeID;
                    datStartDate  = TheCalculatedHoursDataSet.calculatedhours[intCounter].StartTime;
                    datEndDate    = TheCalculatedHoursDataSet.calculatedhours[intCounter].EndTime;
                    decDailyHours = TheCalculatedHoursDataSet.calculatedhours[intCounter].DailyHours;

                    TheFindAholaEmployeePunchForVerificationDataSet = TheEmployeePunchedHoursClass.FindAholaEmployeePunchForVerification(intEmployeeID, datStartDate, datEndDate, decDailyHours);

                    intRecordsReturned = TheFindAholaEmployeePunchForVerificationDataSet.FindAholaEmployeePunchForVerification.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError = TheEmployeePunchedHoursClass.InsertIntoAholaEmployeePunch(intEmployeeID, datStartDate, datEndDate, decDailyHours);

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

                intNumberOfRecords = TheEmployeeHoursDataSet.employeehours.Rows.Count;

                for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                {
                    intEmployeeID = TheEmployeeHoursDataSet.employeehours[intCounter].EmployeeID;
                    intPayID      = TheEmployeeHoursDataSet.employeehours[intCounter].PayID;
                    datPayDate    = TheEmployeeHoursDataSet.employeehours[intCounter].TransactionDate;
                    decTotalHours = TheEmployeeHoursDataSet.employeehours[intCounter].PunchedHours;

                    TheFindEmployeePunchedHoursForValidationDataSet = TheEmployeePunchedHoursClass.FindEmployeePunchedHoursForValidation(datPayDate, intEmployeeID, intEmployeeID);

                    intRecordsReturned = TheFindEmployeePunchedHoursForValidationDataSet.FindEmployeePunchedHoursForValidation.Rows.Count;

                    if (intRecordsReturned < 1)
                    {
                        blnFatalError = TheEmployeePunchedHoursClass.InsertEmployeePunchedHours(datPayDate, intEmployeeID, intPayID, decTotalHours);

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

                PleaseWait.Close();

                TheMessagesClass.InformationMessage("All Records Have Been Inserted");

                ResetControls();
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Import Employee Punches // Insert Records " + Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Punches // Insert Records " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 27
0
        private void expImportCalls_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   strCallType;
            string   strExtension;
            int      intExtension;
            string   strDialedDigits;
            string   strStartTime;
            DateTime datStartTime;
            string   strCallDuration;
            int      intPhoneID;
            int      intEmployeeID;
            string   strFirstName;
            string   strLastName;
            int      intRecordsReturned;
            double   douDate;
            bool     blnIsNotNumeric;
            double   douTime;

            try
            {
                expImportCalls.IsExpanded = false;
                TheImportedPhoneCallsDataSet.importedphonecalls.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;

                for (intCounter = 1; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strCallType     = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strExtension    = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    strDialedDigits = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();
                    strStartTime    = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper();
                    strCallDuration = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2).ToUpper();

                    blnIsNotNumeric = TheDataValidationClass.VerifyIntegerData(strExtension);

                    if (blnIsNotNumeric == false)
                    {
                        intExtension = Convert.ToInt32(strExtension);

                        TheFindPhoneForImportDataSet = ThePhonesClass.FindPhoneForImport(intExtension);

                        intRecordsReturned = TheFindPhoneForImportDataSet.FindPhoneForImport.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            intPhoneID    = TheFindPhoneForImportDataSet.FindPhoneForImport[0].TransactionID;
                            intEmployeeID = TheFindPhoneForImportDataSet.FindPhoneForImport[0].EmployeeID;

                            TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intEmployeeID);

                            strFirstName = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].FirstName;
                            strLastName  = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID[0].LastName;

                            douDate = Convert.ToDouble(strStartTime);

                            datStartTime = DateTime.FromOADate(douDate);

                            douTime = Convert.ToDouble(strCallDuration);

                            TimeSpan tspInterval = TimeSpan.FromDays(douTime);

                            strCallDuration = tspInterval.ToString();

                            ImportedPhoneCallsDataSet.importedphonecallsRow NewCallRow = TheImportedPhoneCallsDataSet.importedphonecalls.NewimportedphonecallsRow();

                            NewCallRow.CallDuration   = strCallDuration;
                            NewCallRow.CallType       = strCallType;
                            NewCallRow.DialedDigits   = strDialedDigits;
                            NewCallRow.PhoneExtension = intExtension;
                            NewCallRow.EmployeeID     = intEmployeeID;
                            NewCallRow.FirstName      = strFirstName;
                            NewCallRow.LastName       = strLastName;
                            NewCallRow.PhoneID        = intPhoneID;
                            NewCallRow.StartTime      = datStartTime;

                            TheImportedPhoneCallsDataSet.importedphonecalls.Rows.Add(NewCallRow);
                        }
                    }
                }

                dgrPhoneCalls.ItemsSource = TheImportedPhoneCallsDataSet.importedphonecalls;
                PleaseWait.Close();
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Phone Calls // Import Excel  " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 28
0
        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;
            int     intPayID = 0;
            decimal decHours = 0;
            string  strValueForValidation;
            string  strEmployeeName;
            bool    blnNextRecord;
            bool    blnFatalError;

            try
            {
                expImportExcel.IsExpanded = false;
                TheImportHoursDataSet.employees.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;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    blnNextRecord   = true;
                    strEmployeeName = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2);
                    if (strEmployeeName == "")
                    {
                        blnNextRecord = false;
                    }
                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2);
                    blnFatalError         = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                    if (blnFatalError == true)
                    {
                        blnNextRecord = false;
                    }
                    else
                    {
                        intPayID = Convert.ToInt32(strValueForValidation);
                    }
                    strValueForValidation = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2);
                    blnFatalError         = TheDataValidationClass.VerifyDoubleData(strValueForValidation);
                    if (blnFatalError == true)
                    {
                        blnNextRecord = false;
                    }
                    else
                    {
                        decHours = Convert.ToDecimal(strValueForValidation);
                    }

                    if (blnNextRecord == true)
                    {
                        TheFindEmployeeByPayIDDataSet = TheEmployeeClass.FindEmployeeByPayID(intPayID);

                        ImportHoursDataSet.employeesRow NewEmployeeRow = TheImportHoursDataSet.employees.NewemployeesRow();

                        NewEmployeeRow.EmployeeID = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].EmployeeID;
                        NewEmployeeRow.FirstName  = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].FirstName;
                        NewEmployeeRow.LastName   = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID[0].LastName;
                        NewEmployeeRow.PayID      = intPayID;
                        NewEmployeeRow.Hours      = decHours;

                        TheImportHoursDataSet.employees.Rows.Add(NewEmployeeRow);
                    }
                }

                PleaseWait.Close();
                dgrResults.ItemsSource = TheImportHoursDataSet.employees;

                blnFatalError = TheEmployeeDateEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Import Employee Hours // Import Excel Menu Item ");

                if (blnFatalError == true)
                {
                    throw new Exception();
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Hours // Import Excel Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 29
0
        private void expProcessHours_Expanded(object sender, RoutedEventArgs e)
        {
            int      intCounter;
            int      intNumberOfRecords;
            int      intEmployeeID;
            DateTime datStartDate;
            DateTime datEndDate;
            decimal  decDailyHours;
            DateTime datPayDate = DateTime.Now;
            string   strValueForValidation;
            bool     blnFatalError = false;
            int      intPayID;
            int      intSecondCounter;
            bool     blnItemFound;
            string   strLastName;
            string   strFirstName;

            try
            {
                expProcessHours.IsExpanded = false;
                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                TheEmployeeHoursDataSet.employeehours.Rows.Clear();

                strValueForValidation = txtPayDate.Text;
                blnFatalError         = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("The Date is not a Date");
                    return;
                }
                else
                {
                    datPayDate = Convert.ToDateTime(strValueForValidation);

                    blnFatalError = TheDataValidationClass.verifyDateRange(datPayDate, DateTime.Now);

                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage("The Date Entered is greater than Today");
                        return;
                    }
                }

                intNumberOfRecords = TheCalculatedHoursDataSet.calculatedhours.Rows.Count;
                gintPunchRecords   = 0;

                for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++)
                {
                    blnItemFound  = false;
                    intEmployeeID = TheCalculatedHoursDataSet.calculatedhours[intCounter].EmployeeID;
                    intPayID      = TheCalculatedHoursDataSet.calculatedhours[intCounter].PayID;
                    datStartDate  = TheCalculatedHoursDataSet.calculatedhours[intCounter].StartTime;
                    datEndDate    = TheCalculatedHoursDataSet.calculatedhours[intCounter].EndTime;
                    decDailyHours = TheCalculatedHoursDataSet.calculatedhours[intCounter].DailyHours;
                    strFirstName  = TheCalculatedHoursDataSet.calculatedhours[intCounter].FirstName;
                    strLastName   = TheCalculatedHoursDataSet.calculatedhours[intCounter].LastName;

                    if (gintPunchRecords > 0)
                    {
                        for (intSecondCounter = 0; intSecondCounter < gintPunchRecords; intSecondCounter++)
                        {
                            if (intEmployeeID == TheEmployeeHoursDataSet.employeehours[intSecondCounter].EmployeeID)
                            {
                                TheEmployeeHoursDataSet.employeehours[intSecondCounter].PunchedHours += decDailyHours;
                                blnItemFound = true;
                            }
                        }
                    }

                    if (blnItemFound == false)
                    {
                        EmployeeHoursDataSet.employeehoursRow NewEmployeeRow = TheEmployeeHoursDataSet.employeehours.NewemployeehoursRow();

                        NewEmployeeRow.EmployeeID      = intEmployeeID;
                        NewEmployeeRow.PayID           = intPayID;
                        NewEmployeeRow.PunchedHours    = decDailyHours;
                        NewEmployeeRow.TransactionDate = datPayDate;
                        NewEmployeeRow.FirstName       = strFirstName;
                        NewEmployeeRow.LastName        = strLastName;

                        TheEmployeeHoursDataSet.employeehours.Rows.Add(NewEmployeeRow);
                        gintPunchRecords++;
                    }
                }

                PleaseWait.Close();

                expInsertRecords.IsEnabled = true;

                dgrResults.ItemsSource = TheEmployeeHoursDataSet.employeehours;
            }
            catch (Exception Ex)
            {
                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Import Employee Punches // Process Hours Expander " + Ex.ToString());

                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Employee Punches // Process Hours Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemplo n.º 30
0
        private void cboSelectLocation_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            int    intColumnRange = 0;
            int    intCounter;
            int    intNumberOfRecords;
            int    intRecordsReturned;
            int    intAssetID;
            string strAssetDescription;
            string strSerialNumber;
            string strAssetType;
            string strBJCNumber;
            bool   blnFatalError   = false;
            string strErrorMessage = "";
            bool   blnItemFound;
            int    intTransactionID;
            string strModel;
            string strManufacturer;
            int    intSelectedIndex;

            try
            {
                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                intSelectedIndex = cboSelectLocation.SelectedIndex - 1;

                if (intSelectedIndex > -1)
                {
                    TheMonitorsDataSet.monitors.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;
                    }

                    MainWindow.gstrAssetLocation = TheFindSortedWaspAssetLocationsBySiteDataSet.FindSortedWaspAssetLoctionsBySite[intSelectedIndex].AssetLocation;

                    if (cboSelectLocation.SelectedIndex < 1)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Site Has Not Been Selected\n";
                    }
                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage(strErrorMessage);
                        return;
                    }

                    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;

                    for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                    {
                        TheWaspAssetIDDataSet = TheAssetClass.GetWaspAssetIDInfo();

                        intAssetID       = TheWaspAssetIDDataSet.waspassetid[0].CreatedAssetID;
                        intTransactionID = TheWaspAssetIDDataSet.waspassetid[0].TransactionID;

                        blnFatalError = TheAssetClass.UpdateWaspAssetID(intTransactionID, intAssetID + 1);

                        blnItemFound = false;
                        strAssetType = "UNKNOWN";

                        if (((range.Cells[intCounter, 1] as Excel.Range).Value2) == null)
                        {
                            intCounter = intNumberOfRecords;
                            break;
                        }
                        else
                        {
                            strAssetDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                            strManufacturer     = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                            strModel            = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();
                            strSerialNumber     = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper();
                            strBJCNumber        = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2).ToUpper();
                            strAssetType        = Convert.ToString((range.Cells[intCounter, 7] as Excel.Range).Value2).ToUpper();


                            TheFindWaspAssetByBJCAssetIDDataSet = TheAssetClass.FindWaspAssetByBJCAssetID(strBJCNumber);

                            intRecordsReturned = TheFindWaspAssetByBJCAssetIDDataSet.FindWaspAssetByBJCAssetID.Rows.Count;

                            if (intRecordsReturned > 0)
                            {
                                blnItemFound = true;
                            }
                        }

                        if (blnItemFound == false)
                        {
                            MonitorsDataSet.monitorsRow NewMonitorRow = TheMonitorsDataSet.monitors.NewmonitorsRow();

                            NewMonitorRow.AssetID      = intAssetID;
                            NewMonitorRow.AssetType    = strAssetType;
                            NewMonitorRow.BJCAssetID   = strBJCNumber;
                            NewMonitorRow.Item         = strAssetDescription;
                            NewMonitorRow.Location     = MainWindow.gstrAssetLocation;
                            NewMonitorRow.Manufacturer = strManufacturer;
                            NewMonitorRow.Model        = strModel;
                            NewMonitorRow.SerialNumber = strSerialNumber;
                            NewMonitorRow.Site         = gstrSite;
                            NewMonitorRow.WarehouseID  = MainWindow.gintWarehouseID;

                            TheMonitorsDataSet.monitors.Rows.Add(NewMonitorRow);
                        }
                    }
                }

                PleaseWait.Close();

                dgrAssets.ItemsSource = TheMonitorsDataSet.monitors;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Vehicle Assets // Import Excel  " + Ex.Message);

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