Example #1
0
        private void mitSave_Click(object sender, RoutedEventArgs e)
        {
            string strAssignedProjectID;
            string strProjectName;
            bool   blnFatalError   = false;
            string strErrorMessage = "";
            int    intRecordsReturned;
            bool   blnDIDExists;
            bool   blnNameExists;

            try
            {
                //beginning data validation
                strAssignedProjectID = txtAssignedProjectID.Text;
                strProjectName       = txtProjectName.Text;
                blnDIDExists         = false;
                blnNameExists        = false;

                if (strAssignedProjectID == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Assigned Project ID Was Not Entered\n";
                }
                if (strProjectName == "")
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Project Name Was Not Entered\n";
                }
                else
                {
                    TheFindProjectByProjectNameDataSet = TheProjectClass.FindProjectByProjectName(strProjectName);

                    intRecordsReturned = TheFindProjectByProjectNameDataSet.FindProjectByProjectName.Rows.Count;

                    if (intRecordsReturned > 0)
                    {
                        blnNameExists = true;
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strAssignedProjectID);

                intRecordsReturned = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID.Rows.Count;

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


                if ((blnDIDExists == true) && (blnNameExists == true))
                {
                    TheMessagesClass.ErrorMessage("This Project Currently Exists");
                    return;
                }

                blnFatalError = TheProjectClass.InsertProject(strAssignedProjectID, strProjectName);
                if (blnFatalError == true)
                {
                    throw new Exception();
                }

                TheMessagesClass.InformationMessage("The Project Has Been Saved");
                txtAssignedProjectID.Text = "";
                txtProjectName.Text       = "";
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Add Project // Save Menu Item " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        private void expImportExcel_Expanded(object sender, RoutedEventArgs e)
        {
            //setting up local variables
            string   strValueForValidation = "";
            int      intEmployeeID         = 0;
            bool     blnFatalError         = false;
            bool     blnThereIsAProblem    = false;
            string   strErrorMessage       = "";
            int      intRecordsReturned;
            string   strAssignedProjectID = "";
            string   strCustomerProjectID = "";
            int      intProjectID         = 0;
            DateTime datTransactionDate   = DateTime.Now;
            int      intSecondProjectID   = 0;
            int      intColumnRange       = 0;
            int      intCounter;
            int      intNumberOfRecords;
            bool     blnDoNotImport;

            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            try
            {
                expImportExcel.IsExpanded = false;

                if (cboSelectDepartment.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Department Was Not Selected\n";
                }
                if (cboSelectOffice.SelectedIndex < 1)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Office Was Not Selected\n";
                }
                strValueForValidation = txtEmployeeID.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyIntegerData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "The Employee ID Was Not An Integer\n";
                }
                else
                {
                    intEmployeeID = Convert.ToInt32(strValueForValidation);

                    TheFindEmployeeByEmployeeIDDataSet = TheEmployeeClass.FindEmployeeByEmployeeID(intEmployeeID);

                    intRecordsReturned = TheFindEmployeeByEmployeeIDDataSet.FindEmployeeByEmployeeID.Rows.Count;

                    if (intRecordsReturned == 0)
                    {
                        blnFatalError    = true;
                        strErrorMessage += "Employee Was Not Found\n";
                    }
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    return;
                }

                TheImportProjectsDataSet.importprojects.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++)
                {
                    strCustomerProjectID = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                    strAssignedProjectID = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper();
                    intProjectID         = 0;
                    intSecondProjectID   = 0;
                    blnDoNotImport       = false;

                    TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strCustomerProjectID);

                    if (TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID.Rows.Count > 0)
                    {
                        intProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID;
                    }

                    TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strAssignedProjectID);

                    if (TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID.Rows.Count > 0)
                    {
                        intSecondProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID;
                    }

                    TheFindProjectMatrixByCustomerProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByCustomerProjectID(strCustomerProjectID);

                    if (TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID.Rows.Count > 0)
                    {
                        if (TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].AssignedProjectID == strAssignedProjectID)
                        {
                            blnDoNotImport = true;
                        }
                    }

                    if (intProjectID == 0)
                    {
                        if (intSecondProjectID != 0)
                        {
                            intProjectID = intSecondProjectID;
                        }
                    }

                    if ((intProjectID == 0) && intSecondProjectID == 0)
                    {
                        blnFatalError = TheProjectClass.InsertProject(strCustomerProjectID, strCustomerProjectID);

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

                        TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strCustomerProjectID);

                        intProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID;
                    }

                    ImportProjectsDataSet.importprojectsRow NewProjectRow = TheImportProjectsDataSet.importprojects.NewimportprojectsRow();

                    NewProjectRow.AssignedProjectID = strAssignedProjectID;
                    NewProjectRow.CustomerProjectID = strCustomerProjectID;
                    NewProjectRow.DepartmentID      = gintDepartmentID;
                    NewProjectRow.EmployeeID        = intEmployeeID;
                    NewProjectRow.ProjectID         = intProjectID;
                    NewProjectRow.SecondProjectID   = intSecondProjectID;
                    NewProjectRow.TransactionDate   = DateTime.Now;
                    NewProjectRow.WarehouseID       = gintOfficeID;
                    NewProjectRow.DoNotImport       = blnDoNotImport;

                    TheImportProjectsDataSet.importprojects.Rows.Add(NewProjectRow);
                }

                PleaseWait.Close();

                dgrProjects.ItemsSource = TheImportProjectsDataSet.importprojects;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Import Projects // Main Window // Import Excel Expander " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Example #3
0
        private void expProecess_Expanded(object sender, RoutedEventArgs e)
        {
            //setting local variables
            bool     blnFatalError      = false;
            bool     blnThereIsAProblem = false;
            string   strErrorMesssage   = "";
            string   strAddress;
            string   strCity;
            string   strState;
            string   strValueForValidation;
            DateTime datDateReceived = DateTime.Now;
            DateTime datECDDate      = DateTime.Now;
            string   strProjectNotes;
            string   strAssignedProjectID = "";
            string   strProjectName       = "";
            string   strCustomerProjectID = "";
            DateTime datTransactionDate   = DateTime.Now;
            int      intEmployeeID;

            try
            {
                strCustomerProjectID = txtCustomerProjectID.Text;
                strAssignedProjectID = txtAssignedProjectID.Text;
                intEmployeeID        = MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID;

                if (gblnProjectExists == false)
                {
                    if ((strAssignedProjectID.Length < 7) && (strAssignedProjectID.Length > 10))
                    {
                        blnFatalError     = true;
                        strErrorMesssage += "The Assigned Project ID is not the Correct Format\n";
                    }
                }
                if (gblnProjectMatrixExists == false)
                {
                    if (strCustomerProjectID.Length < 5)
                    {
                        blnFatalError     = true;
                        strErrorMesssage += "The Customer Project ID is not the Correct Format\n";
                    }
                    else if (gintDepartmentID == 1009)
                    {
                        if ((strCustomerProjectID.Length < 6) && (strCustomerProjectID.Length > 7))
                        {
                            blnFatalError     = true;
                            strErrorMesssage += "The Spectrum Project Length is not the Corret Length\n";
                        }
                    }
                    strProjectName = txtProjectName.Text;
                    if (strProjectName.Length < 10)
                    {
                        blnFatalError     = true;
                        strErrorMesssage += "The Project Name is to Short\n";
                    }
                }
                expProecess.IsExpanded = false;
                if (cboSelectDepartment.SelectedIndex < 1)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The Department was not Selected\n";
                }

                strAddress = txtAddress.Text;
                if (strAddress.Length < 3)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The Address Was Not Entered\n";
                }
                strCity = txtCity.Text;
                if (strCity.Length < 3)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The City is to Short\n";
                }
                strState = txtState.Text;
                if (strState.Length != 2)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The State is not the Correct Length\n";
                }
                if (cboSelectManager.SelectedIndex < 1)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The Manager Was Not Selected\n";
                }
                if (cboSelectOffice.SelectedIndex < 1)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The Office Was Not Selected\n";
                }
                strValueForValidation = txtDateReceived.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The Date Received is not a Date\n";
                }
                else
                {
                    datDateReceived    = Convert.ToDateTime(strValueForValidation);
                    blnThereIsAProblem = TheDataValidationClass.verifyDateRange(datDateReceived, DateTime.Now);
                    if (blnThereIsAProblem == true)
                    {
                        blnFatalError     = true;
                        strErrorMesssage += "The Date Received is after Today\n";
                    }
                }
                strValueForValidation = txtECDDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError     = true;
                    strErrorMesssage += "The ECD Date is not a Date\n";
                }
                else
                {
                    datECDDate = Convert.ToDateTime(strValueForValidation);

                    blnThereIsAProblem = TheDataValidationClass.verifyDateRange(DateTime.Now, datECDDate);

                    if (blnThereIsAProblem == true)
                    {
                        blnFatalError     = true;
                        strErrorMesssage += "The ECD Date is before today\n";
                    }
                }
                strProjectNotes = txtPRojectNotes.Text;
                if (strProjectNotes.Length < 1)
                {
                    strProjectNotes = "PROJECT CREATED";
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMesssage);
                    return;
                }

                if (gblnProjectExists == false)
                {
                    blnFatalError = TheProjectClass.InsertProject(strCustomerProjectID, strProjectName);

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

                    TheFindProjectByAssignedProjectIDDataSet = TheProjectClass.FindProjectByAssignedProjectID(strCustomerProjectID);

                    gintProjectID = TheFindProjectByAssignedProjectIDDataSet.FindProjectByAssignedProjectID[0].ProjectID;

                    blnFatalError = TheProductionProjectClass.InsertProdutionProject(gintProjectID, gintDepartmentID, strAddress, strCity, strState, gintManagerID, gintOfficeID, datDateReceived, datECDDate, gintStatusID, strProjectNotes);

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

                    blnFatalError = TheProductionProjectClass.InsertProductionProjectUpdate(gintProjectID, MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, DateTime.Now, strProjectNotes);

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

                    blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Add Project Number " + strAssignedProjectID + " Has Been Added");

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }
                if (gblnProjectMatrixExists == false)
                {
                    blnFatalError = TheProjectMatrixClass.InsertProjectMatrix(gintProjectID, strAssignedProjectID, strCustomerProjectID, datTransactionDate, intEmployeeID, gintOfficeID, gintDepartmentID);

                    if (blnFatalError == true)
                    {
                        throw new Exception();
                    }
                }
                if (gblnProjectExists == true)
                {
                    TheFindProductionProjectByAssignedProjectIDDataSet = TheProductionProjectClass.FindProductionProjectsByAssignedProjectID(strCustomerProjectID);

                    if (TheFindProductionProjectByAssignedProjectIDDataSet.FindProductionProjectByAssignedProjectID.Rows.Count < 1)
                    {
                        blnFatalError = TheProductionProjectClass.InsertProdutionProject(gintProjectID, gintDepartmentID, strAddress, strCity, strState, gintManagerID, gintOfficeID, datDateReceived, datECDDate, gintStatusID, strProjectNotes);

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

                        blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Add Project Number " + strAssignedProjectID + " Has Been Added");

                        if (blnFatalError == true)
                        {
                            throw new Exception();
                        }
                    }
                    else
                    {
                        TheFindProductionProjectByAssignedProjectIDDataSet = TheProductionProjectClass.FindProductionProjectsByAssignedProjectID(strAssignedProjectID);

                        if (TheFindProductionProjectByAssignedProjectIDDataSet.FindProductionProjectByAssignedProjectID.Rows.Count < 1)
                        {
                            blnFatalError = TheProductionProjectClass.InsertProdutionProject(gintProjectID, gintDepartmentID, strAddress, strCity, strState, gintManagerID, gintOfficeID, datDateReceived, datECDDate, gintStatusID, strProjectNotes);

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

                TheFindProjectMatrixByCustomerProjectIDDataSet = TheProjectMatrixClass.FindProjectMatrixByCustomerProjectID(strCustomerProjectID);

                MainWindow.gintProjectID = TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].ProjectID;

                if (TheFindProjectMatrixByCustomerProjectIDDataSet.FindProjectMatrixByCustomerProjectID[0].BusinessLineID == 1009)
                {
                    AddProductionProjectInfo AddProductionProjectInfo = new AddProductionProjectInfo();
                    AddProductionProjectInfo.ShowDialog();
                }

                blnFatalError = TheEmployeeDataEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Add Project Number " + strAssignedProjectID + " Has Been Added");

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

                AddProjectDocumentation();

                TheMessagesClass.InformationMessage("Project Has Been Entered");

                TheFindProductionProjectByProjectIDDataSet = TheProductionProjectClass.FindProductionProjectByProjectID(gintProjectID);

                MainWindow.gintTransactionID = TheFindProductionProjectByProjectIDDataSet.FindProductionProjectByProjectID[0].TransactionID;

                blnFatalError = TheProductionProjectClass.UpdateProductionProjectStatusDate(MainWindow.gintTransactionID, DateTime.Now);

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

                TheSendEmailClass.SendEventLog("New Blue Jay ERP // Add Project // Process Expander " + Ex.ToString());

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