示例#1
0
        private void fillMatChart()
        {
            try
            {
                ReportDBaccess RD = new ReportDBaccess();
                grid_met.DataSource = RD.getAllMaterial();

                int a = 0;
                chart5.Titles.Add("Material Stock");
                while (a < grid_met.RowCount - 1)
                {
                    chart5.Series["Material Stock"].Points.AddXY(grid_met.Rows[a].Cells[0].Value.ToString(), grid_met.Rows[a].Cells[4].Value.ToString());
                    a = a + 1;
                }
                lb_Mattoday.Text = DateTime.Now.Date.ToString("dd/MM/yyyy");
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void fillClientChart()
        {
            try
            {
                DateTime date = DateTime.Today.Date;

                var firstDayOfMonth = new DateTime(date.Year, date.Month, 1).AddDays(-1);
                var lastDayOfMonth  = firstDayOfMonth.AddMonths(-1).AddDays(1);


                var firstDayOfMonth1 = lastDayOfMonth.AddDays(-1);
                var lastDayOfMonth1  = firstDayOfMonth.AddMonths(-2).AddDays(1);


                lb_cltFrom.Text = lastDayOfMonth.ToString("dd/MM/yyyy");
                lb_cltTo.Text   = firstDayOfMonth.ToString("dd/MM/yyyy");

                ReportDBaccess RD = new ReportDBaccess();
                DateTime       d1 = firstDayOfMonth.Date;
                DateTime       d2 = lastDayOfMonth.Date;
                DateTime       d3 = firstDayOfMonth1.Date;
                DateTime       d4 = lastDayOfMonth1.Date;

                ClientDBaccess CB = new ClientDBaccess();
                grid_Clientreport.DataSource = CB.getAllClients();
                grid_Clientreport.Columns.Add("Order_Placed", "Orders Placed");


                int x = 0;
                while (x < grid_Clientreport.RowCount - 1)
                {
                    grid_Clientreport.Rows[x].Cells["Order_Placed"].Value = RD.getClientcount(grid_Clientreport.Rows[x].Cells[0].Value.ToString(), d2, d1).Rows.Count.ToString();
                    x = x + 1;
                }

                int a = 0;
                chart3.Titles.Add("Client Orders");
                while (a < grid_Clientreport.RowCount - 1)
                {
                    chart3.Series["Client Orders"].Points.AddXY(grid_Clientreport.Rows[a].Cells[1].Value.ToString(), grid_Clientreport.Rows[a].Cells[5].Value.ToString());
                    a = a + 1;
                }

                int total = 0;
                for (int b = 0; b < grid_Clientreport.Rows.Count; b++)
                {
                    total += Convert.ToInt32(grid_Clientreport.Rows[b].Cells[5].Value);
                }
                lb_cltTot.Text = total.ToString();
                lb_cltnow.Text = total.ToString();
                int tot = 0;
                for (int b = 0; b < grid_Clientreport.Rows.Count - 1; b++)
                {
                    int[] y = new int[grid_Clientreport.Rows.Count];
                    y[b] = Convert.ToInt32(RD.getClientcount(grid_Clientreport.Rows[b].Cells[0].Value.ToString(), d4, d3).Rows.Count);
                    tot  = tot + y[b];
                }

                //int sum = Convert.ToInt32(RD.getClientcount(grid_Clientreport.Rows[x].Cells[0].Value.ToString(), d2, d1).Compute("SUM(Order_Placed)", string.Empty));
                lb_cltlast.Text = tot.ToString();

                lb_cltnext.Text = (Convert.ToInt32(total) + (Convert.ToInt32(total) - Convert.ToInt32(tot))).ToString();

                string pMonth  = DateTime.Now.AddMonths(-1).ToString("MMMM");
                string pMonth1 = DateTime.Now.AddMonths(-2).ToString("MMMM");
                string pMonth2 = DateTime.Now.ToString("MMMM");
                lb_cltlastmonth.Text = pMonth1;
                lb_cltnowmonrh.Text  = pMonth;
                lb_cltNextmonth.Text = pMonth2;
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private void fillPurChart()
        {
            try
            {
                DateTime date = DateTime.Today.Date;

                var firstDayOfMonth = new DateTime(date.Year, date.Month, 1).AddDays(-1);
                var lastDayOfMonth  = firstDayOfMonth.AddMonths(-1).AddDays(1);


                var firstDayOfMonth1 = lastDayOfMonth.AddDays(-1);
                var lastDayOfMonth1  = firstDayOfMonth.AddMonths(-2).AddDays(1);


                lb_fromdate.Text = lastDayOfMonth.ToString("dd/MM/yyyy");
                lb_todate.Text   = firstDayOfMonth.ToString("dd/MM/yyyy");

                ReportDBaccess RD = new ReportDBaccess();
                DateTime       d1 = firstDayOfMonth.Date;
                DateTime       d2 = lastDayOfMonth.Date;
                DateTime       d3 = firstDayOfMonth1.Date;
                DateTime       d4 = lastDayOfMonth1.Date;

                grid_PurReport.DataSource = RD.getPurchaseReport(d2, d1);
                int total = 0;
                for (int a = 0; a < grid_PurReport.Rows.Count; a++)
                {
                    total += Convert.ToInt32(grid_PurReport.Rows[a].Cells[3].Value);
                }
                lb_tot.Text = total.ToString();
                lb_now.Text = total.ToString();

                int sum = Convert.ToInt32(RD.getPurchaseReport(d4, d3).Compute("SUM(pur_total)", string.Empty));
                lb_last.Text = sum.ToString();

                lb_next.Text = (Convert.ToInt32(total) + (Convert.ToInt32(total) - Convert.ToInt32(sum))).ToString();


                //grid_SaleReport.DataSource = rows;

                //AddXY value in chart1 in series named as Salary
                string pMonth  = DateTime.Now.AddMonths(-1).ToString("MMMM");
                string pMonth1 = DateTime.Now.AddMonths(-2).ToString("MMMM");
                string pMonth2 = DateTime.Now.ToString("MMMM");
                chart2.Series["Purchase"].Points.AddXY(pMonth1, sum.ToString());
                chart2.Series["Purchase"].Points.AddXY(pMonth, total.ToString());
                lb_lastmonth.Text = pMonth1;
                lb_nawMonth.Text  = pMonth;
                lb_nextMonth.Text = pMonth2;
                //chart title
                chart2.Titles.Add("Purchase Chart");
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }