Beispiel #1
0
        private void dataGridViewReports_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            clsMonthlyReports.find(Convert.ToInt32(dataGridViewReports.Rows[e.RowIndex].Cells["clmReportId"].Value));

            //Set the checks for the report email recipeints
            setRecipientChecksForReport(e.RowIndex);

            //Set the template path
            tbTemplatePath.Text = clsMonthlyReports.GetDataValue("ReportPath").ToString();

            //Sets visibility of the recipients dataGridView
            dataGridViewReicpitents.Visible =
                (bool)dataGridViewReports.Rows[e.RowIndex].Cells["clmReportActive"].Value;
        }
        /// <summary>
        /// Checks the Report Path and finds if the reports exist for the current period
        /// </summary>
        private void findIfReportsExist()
        {
            for (int i = 1; i < lvReports.Items.Count; i++)
            {
                if (lvReports.Items[i].Tag != null && lvReports.Items[i].Tag.ToString() != "")
                {
                    //Get Report Path
                    file = CCFBPrefs.ReportsSavePath;
                    //Add Underschore
                    clsMonthlyReports.find(Convert.ToInt32(lvReports.Items[i].Tag));
                    file += cboReportYear.SelectedItem.ToString() +
                            getFormatedMonthNumber(cboReportMonth.SelectedIndex + 1).ToString() + "_";
                    //Add Period
                    file += clsMonthlyReports.ReportName + ".doc";

                    //Check if file exists
                    if (File.Exists(file) == true)
                    {
                        lvReports.Items[i].BackColor = Color.LightSteelBlue;
                        lvReports.Items[i].Checked   = false;
                    }
                    else
                    {
                        lvReports.Items[i].BackColor = Color.Beige;
                    }
                }
            }

            //For each report Checkbox
            foreach (CheckBox cb in pnlReports.Controls.OfType <CheckBox>())
            {
                //If that checkbox does not = ALL
                if (cb.Tag != null && cb.Tag.ToString() != "")
                {
                    //Get Report Path
                    file = CCFBPrefs.ReportsSavePath;
                    //Add Underschore
                    clsMonthlyReports.find(Convert.ToInt32(cb.Tag));
                    file += cboReportYear.SelectedItem.ToString() +
                            getFormatedMonthNumber(cboReportMonth.SelectedIndex + 1).ToString() + "_";
                    //Add Period
                    file += clsMonthlyReports.ReportName + ".doc";

                    //Check if file exists
                    if (File.Exists(file) == true)
                    {
                        cb.BackColor = Color.Red;
                        cb.Checked   = false;
                    }
                    else
                    {
                        cb.BackColor = Color.Cornsilk;
                    }
                }
            }
        }