Exemplo n.º 1
0
        }     //  end onRegionSelectedIndexChanged

        private void onAdditional(object sender, EventArgs e)
        {
            if (regionList.SelectedItem.ToString() == "10")
            {
                //  get correct password before continuing
                PasswordProtect pp = new PasswordProtect();
                pp.ShowDialog();
                if (pp.passwordResponse != "OK")
                {
                    Close();
                    return;
                }   //  endif

                string currentSale    = " ";
                string currentSaleNum = " ";
                if (templateFlag != 1)
                {
                    List <SaleDO> sList = bslyr.getSale();
                    currentSale    = sList[0].Name;
                    currentSaleNum = sList[0].SaleNumber;
                }   //  endif
                List <LogMatrixDO> checkMatrix = new List <LogMatrixDO>();
                try
                {
                    // is it empty?
                    checkMatrix = bslyr.getLogMatrix("R008");
                    if (checkMatrix.Count == 0)
                    {
                        //  load default matrix for both reports
                        checkMatrix.Clear();
                        checkMatrix = loadDefaultMatrix(currentSale, currentSaleNum);
                        //  save default matrix
                        bslyr.SaveLogMatrix(checkMatrix, "");
                    }   //  endif
                }
                catch
                {
                    //   need to create the table and load the default
                    int iDone = bslyr.CreateNewTable("LogMatrix");
                    checkMatrix = loadDefaultMatrix(currentSale, currentSaleNum);
                    //  save default matrix
                    bslyr.SaveLogMatrix(checkMatrix, "");
                }   //  endif

                //  see if log matrix table needs to be updated
                List <LogMatrixDO> reportMatrix = new List <LogMatrixDO>();
                DialogResult       dr           = MessageBox.Show("Reports R008 and R009 use a log matrix.\nDo you want to update the matrix now?\nNOTE: If the Log Matrix does not exist, the default matrix is used.", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    DialogResult d8 = MessageBox.Show("The log matrix is different for each report.\nUpdate R008?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (d8 == DialogResult.Yes)
                    {
                        reportMatrix = bslyr.getLogMatrix("R008");
                        LogMatrixUpdate lmu = new LogMatrixUpdate();
                        lmu.reportMatrix   = reportMatrix;
                        lmu.currSaleName   = currentSale;
                        lmu.currSaleNumber = currentSaleNum;
                        lmu.currReport     = "R008";
                        lmu.setupDialog();
                        lmu.ShowDialog();
                        reportMatrix = lmu.reportMatrix;
                        bslyr.SaveLogMatrix(reportMatrix, "R008");

                        //  need to update R009?
                        DialogResult d9 = MessageBox.Show("Update R009?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (d9 == DialogResult.Yes)
                        {
                            //  retrieve R009 matrix and update
                            reportMatrix = bslyr.getLogMatrix("R009");
                            LogMatrixUpdate lmx = new LogMatrixUpdate();
                            lmx.reportMatrix   = reportMatrix;
                            lmx.currSaleNumber = currentSale;
                            lmx.currSaleNumber = currentSaleNum;
                            lmx.currReport     = "R009";
                            lmx.setupDialog();
                            lmx.ShowDialog();
                            int rtnResult = lmx.returnValue;
                            if (rtnResult == 1)
                            {
                                reportMatrix = lmx.reportMatrix;
                                bslyr.SaveLogMatrix(reportMatrix, "R009");
                            }   //  endif
                        }       //  endif
                    }
                    else if (d8 == DialogResult.No)
                    {
                        DialogResult d9 = MessageBox.Show("Update R009?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (d9 == DialogResult.Yes)
                        {
                            //  retrieve R009 matrix and update
                            reportMatrix = bslyr.getLogMatrix("R009");
                            LogMatrixUpdate lmx = new LogMatrixUpdate();
                            lmx.reportMatrix   = reportMatrix;
                            lmx.currSaleNumber = currentSale;
                            lmx.currSaleNumber = currentSaleNum;
                            lmx.currReport     = "R009";
                            lmx.setupDialog();
                            lmx.ShowDialog();
                            int rtnResult = lmx.returnValue;
                            if (rtnResult == 1)
                            {
                                reportMatrix = lmx.reportMatrix;
                                bslyr.SaveLogMatrix(reportMatrix, "R009");
                            } //  endif
                        }     //  endif
                    }         //  endif
                }             //  endif
            }                 //  endif

            if (availableReports.Items[0].ToString().Substring(0, 2) == "EX")
            {
                // not yet tested --  January 2012
                MessageBox.Show("Under Construction", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                additionalData.Enabled = false;
                //additionalData.Enabled = true;
                return;

/*
 *              //  display dialog for capturing export grade values
 *              //  first need region number
 *              string currentRegion = "";
 *              currentRegion = bslyr.findSingleField("Region", "Sale");
 *
 *              //  need dialog object
 *              ExportDialog ed = new ExportDialog();
 *              //  Then does the ExportValues table exist?  Need to fill list with defaults for all regions or Region 10
 *              bool tableExists = bslyr.doesTableExist("ExportValues");
 *              if (tableExists == false)
 *              {
 *                  //  need to create the table
 *                  int nResult = bslyr.CreateNewTable("ExportValues");
 *                  //  then get defaults to load into dialog for user to update
 *                  exportGrades eg = new exportGrades();
 *                  //  sort list first
 *                  List<exportGrades> egSortList = eg.createDefaultList(currentRegion, "sort");
 *                  List<exportGrades> egGradeList = eg.createDefaultList(currentRegion, "grade");
 *
 *                  ed.setupDialog(egSortList, egGradeList);
 *              }
 *              else if (tableExists == true)
 *              {
 *                  //  just get data in the table for display
 *                  List<exportGrades> egList = bslyr.GetExportGrade();
 *                  List<exportGrades> dummyList = new List<exportGrades>();
 *                  ed.setupDialog(egList,dummyList);
 *              }   //  endif tableExists
 *              ed.fileName = fileName;
 *              ed.tableExists = tableExists;
 *              ed.ShowDialog();
 *
 *              additionalData.Enabled = false;
 */
            }
        }   //  end onAdditional