예제 #1
0
        private void btnGenerateReport_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;

            if (CanGenerateReport())
            {
                vemp      = new ProcessFiles();
                errorMsgs = new List <ErrorMessage>();
                var empData = vemp.ProcessEmpFiles(cmbBillingCycle.SelectedItem.ToString(), cmbYear.SelectedItem.ToString(), Convert.ToInt32(cmbAccountName.SelectedValue), costPath, billingPath, ref errorMsgs);

                if (errorMsgs.Count() > 0)
                {
                    var msgResult = MessageBox.Show("There are few discripencies in the file.\nDo you like to continue", "Discripency Alert", MessageBoxButtons.YesNo);
                    if (msgResult == System.Windows.Forms.DialogResult.Yes)
                    {
                        AccountMonthRevenue aMonthData = new AccountMonthRevenue();
                        bool isSuccessful = aMonthData.CreateAccountMonthWiseData(cmbBillingCycle.Text, Convert.ToInt32(cmbYear.Text), ((EntitiesLib.Account)(cmbAccountName.SelectedItem)).AccountID.ToString(), empData);
                        //FillReportData(empData);
                        dataGridView1.Visible = true;
                        dataGridView1.DefaultCellStyle.ForeColor = Color.Black;
                        DisableControls();
                        MessageBox.Show("Date generated successfully");
                    }
                    else
                    {
                        ClearData();
                        dataGridView1.DefaultCellStyle.ForeColor = Color.Red;
                        dataGridView1.DataSource = errorMsgs;
                        dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        //DisableControls();
                        MessageBox.Show("Cannot proceed as discripencies found in data!");
                    }
                }
                else
                {
                    AccountMonthRevenue aMonthData = new AccountMonthRevenue();
                    bool isSuccessful = aMonthData.CreateAccountMonthWiseData(cmbBillingCycle.Text, Convert.ToInt32(cmbYear.Text), ((EntitiesLib.Account)(cmbAccountName.SelectedItem)).AccountID.ToString(), empData);
                    //FillReportData(empData);
                    dataGridView1.Visible = true;
                    dataGridView1.DefaultCellStyle.ForeColor = Color.Black;
                    DisableControls();
                    MessageBox.Show("Date generated successfully");
                }
            }
        }