private void btnGenerateReport_Click(object sender, EventArgs e) { try { List <string> selectedMonth = (List <string>)lstMonth.SelectedItems.Cast <String>().ToList(); int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); int BU = 0; var AccountList = new List <Account>(); BU = Convert.ToInt32(lstBUAcc.SelectedValue); AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; if (cmbReportType.SelectedItem.ToString() == "Revenue Report") { ds = accMonthRevenue.AccountRevenueReportBasedOnBU(BU, selectedYear, selectedMonth); } else { ds = accMonthRevenue.AccountMarginReportBasedOnBU(BU, selectedYear, selectedMonth); } dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.AutoResizeColumns(); dgvReportView.Show(); } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { List <string> selectedMonth = (List <string>)lstMonth.SelectedItems.Cast <String>().ToList(); int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); int? BU = null; var AccountList = new List <Account>(); foreach (Account item in lstBUAcc.SelectedItems) { Account a = new Account(); a.AccountID = Convert.ToInt32(item.AccountID); AccountList.Add(a); } AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; if (cmbReportType.SelectedItem.ToString() == "Revenue Report") { ds = accMonthRevenue.GroupWiseRevenueReport(BU, selectedMonth, AccountList, selectedYear); } else { ds = accMonthRevenue.GroupWiseMarginReport(BU, selectedMonth, AccountList, selectedYear); } dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.AutoResizeColumns(); dgvReportView.Show(); } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }
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"); } } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; ds = accMonthRevenue.MonthDataExists(Convert.ToInt32(cmbYear.Text)); dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.AutoResizeColumns(); dgvReportView.Show(); } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); int?BU = null; var AccountList = new List <Account>(); if (rbBUList.Checked) { BU = Convert.ToInt32(lstBUAcc.SelectedValue); } else { foreach (Account item in lstBUAcc.SelectedItems) { Account a = new Account(); a.AccountID = Convert.ToInt32(item.AccountID); AccountList.Add(a); } } AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; if (cmbReportType.SelectedItem.ToString() == "Highest Salary") { ds = accMonthRevenue.GetHighestSalary(Convert.ToInt32(txtFromNoofPeople.Text), Convert.ToInt32(txtToNoofPeople.Text) , BU, AccountList, selectedYear); } else { ds = accMonthRevenue.GetLowestSalary(Convert.ToInt32(txtFromNoofPeople.Text), Convert.ToInt32(txtToNoofPeople.Text) , BU, AccountList, selectedYear); } dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.Show(); } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); int?BU = null; var AccountList = new List <Account>(); if (rbBUList.Checked) { BU = Convert.ToInt32(lstBUAcc.SelectedValue); } else { foreach (Account item in lstBUAcc.SelectedItems) { Account a = new Account(); a.AccountID = Convert.ToInt32(item.AccountID); AccountList.Add(a); } } AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; ds = accMonthRevenue.MarginPerEmployeeYTD(BU, AccountList, selectedYear); dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.AutoResizeColumns(); dgvReportView.Show(); //CallTestMethod(); } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }
private void btnGenerateReport_Click(object sender, EventArgs e) { try { List <string> selectedMonth = (List <string>)lstMonth.SelectedItems.Cast <String>().ToList(); int selectedYear = Convert.ToInt32(cmbYear.SelectedItem.ToString()); int? BU = null; var AccountList = new List <Account>(); foreach (Account item in lstBUAcc.SelectedItems) { Account a = new Account(); a.AccountID = Convert.ToInt32(item.AccountID); AccountList.Add(a); } AccountMonthRevenue accMonthRevenue = new AccountMonthRevenue(); DataSet ds; if (cmbReportType.SelectedItem.ToString() == "Revenue Report") { ds = accMonthRevenue.ManagerWiseRevenueReport(BU, selectedMonth, AccountList, selectedYear); } else { ds = accMonthRevenue.ManagerWiseMarginReport(BU, selectedMonth, AccountList, selectedYear); } if (cmbChartType.SelectedItem.ToString() == "Grid") { dgvReportView.AutoGenerateColumns = true; dgvReportView.DataSource = ds.Tables[0]; dgvReportView.AutoResizeColumns(); dgvReportView.Show(); } else { dgvReportView.Hide(); bool chartexists = splitContainer1.Panel2.Controls.ContainsKey("chart1"); Chart ch; if (!chartexists) { ch = new Chart(); } else { ch = (Chart)splitContainer1.Panel2.Controls["chart1"]; } ch.Series.Clear(); System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.Windows.Forms.DataVisualization.Charting.Series series1; if (cmbChartType.SelectedItem.ToString() == "Bar Chart") { series1 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "Series1", Color = System.Drawing.Color.Green, IsVisibleInLegend = true, IsXValueIndexed = true, ChartType = SeriesChartType.Bar }; } else { series1 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "Series1", Color = System.Drawing.Color.Green, IsVisibleInLegend = true, IsXValueIndexed = true, ChartType = SeriesChartType.Pie }; } ch.Series.Add(series1); ch.Legends.Add(legend1); ch.Location = new System.Drawing.Point(0, 50); ch.Name = "chart1"; ch.DataSource = ds.Tables[0]; ch.Series["Series1"].XValueMember = "ManagerName"; if (cmbReportType.SelectedItem.ToString() == "Revenue Report") { ch.Series["Series1"].YValueMembers = "Revenue"; } else { ch.Series["Series1"].YValueMembers = "GrossMargin"; } chartArea1.Name = "ChartArea1"; if (!chartexists) { ch.ChartAreas.Add(chartArea1); } ch.Dock = System.Windows.Forms.DockStyle.Fill; ch.Series["Series1"].IsValueShownAsLabel = true; if (!chartexists) { splitContainer1.Panel2.Controls.Add(ch); } } } catch (Exception ex) { MessageBox.Show("An error occured while generating the report.\nPlease try again in sometime."); } }