public FindEmployeeByPayIDDataSet FindEmployeeByPayID(int intPayID)
        {
            try
            {
                aFindEmployeebyPayIDDataSet      = new FindEmployeeByPayIDDataSet();
                aFindEmployeeByPayIDTableAdapter = new FindEmployeeByPayIDDataSetTableAdapters.FindEmployeeByPayIDTableAdapter();
                aFindEmployeeByPayIDTableAdapter.Fill(aFindEmployeebyPayIDDataSet.FindEmployeeByPayID, intPayID);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Employee Class // Find Employee By Pay ID " + Ex.Message);
            }

            return(aFindEmployeebyPayIDDataSet);
        }
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            //setting up local variables
            string   strValueForValidation;
            string   strErrorMessage    = "";
            bool     blnFatalError      = false;
            bool     blnThereIsAProblem = false;
            string   strPhoneNumber;
            string   strEmail;
            int      intPayID     = 0;
            DateTime datStartDate = DateTime.Now;
            DateTime datEndDate;
            string   strEndDate = "12/31/2999";
            int      intRecordsReturned;
            string   strEmployeeInformation;

            try
            {
                datEndDate            = Convert.ToDateTime(strEndDate);
                strValueForValidation = txtEmployeeID.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee ID Was Not Generated\n";
                }
                else
                {
                    MainWindow.gintEmployeeID = Convert.ToInt32(strValueForValidation);
                }
                MainWindow.gstrFirstName = txtFirstName.Text;
                if (MainWindow.gstrFirstName.Length < 3)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The First Name is not Long Enough\n";
                }
                MainWindow.gstrLastName = txtLastName.Text;
                if (MainWindow.gstrLastName.Length < 3)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Last Name is not Long Enough\n";
                }
                strPhoneNumber     = txtPhoneNumber.Text;
                blnThereIsAProblem = TheDataValidationClass.VerifyPhoneNumberFormat(strPhoneNumber);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Phone Number is not the Correct Format\n";
                }
                strEmail = txtEmail.Text;
                if (strEmail.Length > 0)
                {
                    blnThereIsAProblem = TheDataValidationClass.VerifyEmailAddress(strEmail);
                    if (blnThereIsAProblem == true)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "The Email Address is not the Correct Format\n";
                    }
                }
                strValueForValidation = txtPayID.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Pay ID is not an Integer\n";
                }
                else
                {
                    intPayID = Convert.ToInt32(strValueForValidation);

                    if (intPayID > 0)
                    {
                        TheFindEmployeeByPayIDDataSet = TheEmployeeClass.FindEmployeeByPayID(intPayID);

                        intRecordsReturned = TheFindEmployeeByPayIDDataSet.FindEmployeeByPayID.Rows.Count;

                        if (intRecordsReturned > 0)
                        {
                            blnFatalError    = true;
                            strErrorMessage += "The Pay ID is Already Assigned to an Employee\n";
                        }
                    }
                }
                if (cboSelectGroup.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee Group was not Selected\n";
                }
                if (cboHomeOffice.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Home Office was not Selected\n";
                }
                if (cboSelectType.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Type was not Selected\n";
                }
                if (cboSalaryType.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Salary Type was not Selected\n";
                }
                if (cboDepartment.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Department was not Selected\n";
                }
                if (cboManager.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Manager was not Selected\n";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                MainWindow.gblnKeepNewEmployee = true;

                MainWindow.TheVerifyEmployeeDataSet = TheEmployeeClass.VerifyEmployee(MainWindow.gstrFirstName, MainWindow.gstrLastName);

                intRecordsReturned = MainWindow.TheVerifyEmployeeDataSet.VerifyEmployee.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    ExistingEmployees ExistingEmployees = new ExistingEmployees();
                    ExistingEmployees.ShowDialog();
                }

                if (MainWindow.gblnKeepNewEmployee == false)
                {
                    TheMessagesClass.InformationMessage("Employee Currently In ERP, Please Edit Employee");
                    return;
                }

                blnFatalError =

                    blnFatalError = TheEmployeeClass.InsertEmployee(MainWindow.gintEmployeeID, MainWindow.gstrFirstName, MainWindow.gstrLastName, strPhoneNumber, true, gstrEmployeeGroup, MainWindow.gstrWarehouseName, gstrEmployeeType, strEmail, gstrSalaryType, gstrDepartment, gintManagerID, intPayID);

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

                blnFatalError = TheEmployeeClass.UpdateEmployeeStartDate(MainWindow.gintEmployeeID, datStartDate);

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

                blnFatalError = TheEmployeeClass.UpdateEmployeeEndDate(MainWindow.gintEmployeeID, datEndDate);

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

                strEmployeeInformation  = MainWindow.gstrFirstName + " ";
                strEmployeeInformation += MainWindow.gstrLastName;

                blnFatalError = TheEmployeeDateEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Created Employee " + strEmployeeInformation);

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

                TheMessagesClass.InformationMessage("Employee Has Been Added");

                ResetControls();

                EnableControls(false);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Add Employee // Process Button " + Ex.Message);

                TheSendEmailClass.SendEventLog(Ex.ToString());

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Exemple #3
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());
            }
        }
Exemple #4
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());
            }
        }