void VisualizeCharts() { if (comboBoxSelectProduct.SelectedIndex > -1) { if (comboBoxSelectProduct.SelectedValue is int) { ProductId = Convert.ToInt32(comboBoxSelectProduct.SelectedValue); //DataTable dtId = retrieve.GetId("usp_GetProductID", comboBoxSelectProduct.Text); //ProductId =Convert.ToInt32( dtId.Rows[0][0]); DataTable dtStockIn = new DataTable(); dtStockIn = retrieve.GetStocksGraph(ProductId, dateTimePickerStock.Value); DataTable dtStockOut = new DataTable(); dtStockOut = retrieve.GetStocksOutGraph(ProductId, dateTimePickerStock.Value); DataTable dtAvailableStock = new DataTable(); dtAvailableStock = retrieve.GetAvailableStocksGraph(ProductId, dateTimePickerStock.Value); chartStocksBarChart.Series.Clear(); chartArea.Series.Clear(); profitAmount = retrieve.GetProductProfit(ProductId, dateTimePickerStock.Value); //chartStocksBarChart.Series.Add("Available Stocks"); //chartArea.Series.Add("Stocks In"); //chartArea.Series.Add("Stocks Out"); //chartArea.Series["Stocks In"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //chartArea.Series["Stocks In"].Color = Color.Green; //chartArea.Series["Stocks Out"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //chartArea.Series["Stocks Out"].Color = Color.Red; //for (int i = 0; i < dtStockIn.Rows.Count; i++) //{ // chartArea.Series["Stocks In"].Points.AddXY(dtStockIn.Rows[i][1].ToString(), dtStockIn.Rows[i][0]); // chartArea.Series["Stocks In"].Points[i].IsValueShownAsLabel = true; //} //for (int i = 0; i < dtStockOut.Rows.Count; i++) //{ // chartArea.Series["Stocks Out"].Points.AddXY(dtStockOut.Rows[i][1].ToString(), dtStockOut.Rows[i][0]); // chartArea.Series["Stocks Out"].Points[i].IsValueShownAsLabel = true; //} //for (int i = 0; i < dtAvailableStock.Rows.Count; i++) //{ // chartStocksBarChart.Series["Available Stocks"].Points.AddXY(dtAvailableStock.Rows[i][1].ToString(), dtAvailableStock.Rows[i][0]); // chartStocksBarChart.Series["Available Stocks"].Points[i].IsValueShownAsLabel = true; //} //chartStocksBarChart.ChartAreas[0].AxisX.Interval = 1; //chartArea.ChartAreas[0].AxisX.Interval = 1; //chartArea.ChartAreas[0].BorderWidth = 10; //chartStocksBarChart.Series[0].IsVisibleInLegend = true; //chartArea.Series[0].IsVisibleInLegend = true ; //chartArea.ChartAreas[0].BackColor = System.Drawing.Color.Transparent; //chartStocksBarChart.ChartAreas[0].BackColor = System.Drawing.Color.Transparent; chartArea.Series.Add("Available Stocks"); chartStocksBarChart.Series.Add("Stocks In"); chartStocksBarChart.Series.Add("Stocks Out"); chartArea.Series["Available Stocks"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //chartArea.Series["Available Stocks"].MarkerSize = 20; chartArea.Series["Available Stocks"].BorderWidth = 2; // chartArea.Series["Available Stocks"].Color = Color.Blue; chartStocksBarChart.Series["Stocks In"].Color = Color.Red; // chartArea.Series["Stocks Out"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chartStocksBarChart.Series["Stocks Out"].Color = Color.Green; for (int i = 0; i < dtStockIn.Rows.Count; i++) { chartStocksBarChart.Series["Stocks In"].Points.AddXY(dtStockIn.Rows[i][1].ToString(), dtStockIn.Rows[i][0]); // chartStocksBarChart.Series["Stocks In"].Points[i].IsValueShownAsLabel = true; } for (int i = 0; i < dtStockOut.Rows.Count; i++) { chartStocksBarChart.Series["Stocks Out"].Points.AddXY(dtStockOut.Rows[i][1].ToString(), dtStockOut.Rows[i][0]); // chartStocksBarChart.Series["Stocks Out"].Points[i].IsValueShownAsLabel = true; } for (int i = 0; i < dtAvailableStock.Rows.Count; i++) { chartArea.Series["Available Stocks"].Points.AddXY(dtAvailableStock.Rows[i][1].ToString(), dtAvailableStock.Rows[i][0]); // chartArea.Series["Available Stocks"].Points[i].IsValueShownAsLabel = true; } chartStocksBarChart.ChartAreas[0].AxisX.Interval = 1; chartArea.ChartAreas[0].AxisX.Interval = 1; chartArea.ChartAreas[0].BorderWidth = 10; chartStocksBarChart.Series[0].IsVisibleInLegend = true; chartArea.Series[0].IsVisibleInLegend = true; chartArea.ChartAreas[0].BackColor = System.Drawing.Color.Transparent; chartStocksBarChart.ChartAreas[0].BackColor = System.Drawing.Color.Transparent; // GridView retrieve.ShowStockbyId(dataGridViewProduct, ProductIdGv, ProductNameGv, ProductCodeGv, ProductUnitGv, ProductMinValGv, AvailableStocks, ProductId, ReworkedStock, RejectedStock, OnHoldStock, PriceofStock); foreach (DataGridViewRow rows in dataGridViewProduct.Rows) { minStocks = Convert.ToDecimal(rows.Cells["ProductMinValGv"].Value); availableStock = Convert.ToDecimal(rows.Cells["AvailableStocks"].Value); if (Convert.ToDecimal(rows.Cells["ProductMinValGv"].Value) < Convert.ToDecimal(rows.Cells["AvailableStocks"].Value)) { rows.Cells["ProductNameGv"].Style.BackColor = Color.LightGreen; rows.Cells["ProductNameGv"].Style.ForeColor = Color.Black; rows.Cells["AvailableStocks"].Style.BackColor = Color.LightGreen; rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black; } else { rows.Cells["ProductNameGv"].Style.BackColor = Color.IndianRed; rows.Cells["ProductNameGv"].Style.ForeColor = Color.Black; rows.Cells["AvailableStocks"].Style.BackColor = Color.IndianRed; rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black; } labelAvaiableStockPrice.Text = "Available Stocks Price= Rs " + (Math.Round(Convert.ToDecimal(rows.Cells["PriceofStock"].Value))).ToString(); } // pictureBoxAvailableStock.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxBalance_Paint); GetAvailableStockPercentage(); if (retrieve.IsSellerProduct(ProductId) && Retrievel.User_Type_Id == 1) { GetSalesProfit(); } else if (pictureBoxSalesProfit.Visible) { pictureBoxSalesProfit.Visible = false; labelSalesProfitAmount.Visible = false; labelSalesProfit.Visible = false; } // pictureBoxSalesProfit.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxProfit_Paint); } } }