Displaying Dynamic chart By C#

Html Code
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MonthWiseReport.aspx.cs"  
  2.     Inherits="qt_MonthWiseReport" %>  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ Register Src="~/qt/Menulist.ascx" TagName="Header" TagPrefix="Admin" %>  
  4. <html  
  5.     xmlns="http://www.w3.org/1999/xhtml">  
  6.     <head runat="server">  
  7.         <title>Untitled Page</title>  
  8.         <link href="style1.css" type="text/css" rel="Stylesheet" />  
  9.         <style type="text/css">  
  10.         .GridHeader  
  11.         {  
  12.             background: url(images/strip-play.jpg) repeat-x;  
  13.             font-weight: bold;  
  14.             text-align: center;  
  15.             font-size: 13px;  
  16.         }  
  17.     </style>  
  18.         <script type="text/javascript" src="../LIVE Report_files/1.7.js"></script>  
  19.         <script type="text/javascript" src="../LIVE Report_files/jquery.min1.js"></script>  
  20.     </head>  
  21.     <body>  
  22.         <form id="form1" runat="server">  
  23.             <ajaxToolkit:ToolkitScriptManager ID="ts_tool" runat="server"></ajaxToolkit:ToolkitScriptManager>  
  24.             <div>  
  25.                 <div class="wraper">  
  26.                     <div class="report-out">  
  27.                         <div class="report-type">  
  28.                             <div class="main_menu">  
  29.                                 <Admin:Header ID="adminheader" runat="server" />  
  30.                             </div>  
  31.                         </div>  
  32.                         <div class="report-header">  
  33.                             <div class="report-header-tital" style="padding-top: 50px;">  
  34.                         CallCenter Month Performance  
  35.                     </div>  
  36.                             <div class="report-header-outer">  
  37.                                 <table width="100%">  
  38.                                     <tr>  
  39.                                         <td colspan="5px" style="width:70%" align="left">  
  40.                                             <table width="100%" border="0" cellspacing="0" cellpadding="0" class="frmTable border"  
  41.                                         align="center" style="margin-bottom: 10px; background: #FFFFFF;">  
  42.                                                 <tr>  
  43.                                                     <td colspan="5px" align="center">  
  44.                                                         <asp:Label ID="lblforerror1" runat="server" ForeColor="Red" Font-Bold="true"></asp:Label>  
  45.                                                     </td>  
  46.                                                 </tr>  
  47.                                                 <tr>  
  48.                                                     <td>  
  49.                                                 Select CallCenter :  
  50.                                             </td>  
  51.                                                     <td>  
  52.                                                         <asp:DropDownList ID="dp_CallCener" runat="server" Width="185px"></asp:DropDownList>  
  53.                                                     </td>  
  54.                                                 </tr>  
  55.                                                 <tr>  
  56.                                                     <tr>  
  57.                                                         <td>  
  58.                                                     Select Type  
  59.                                                 </td>  
  60.                                                         <td>  
  61.                                                             <asp:RadioButtonList ID="Rd_SelectType" runat="server" RepeatDirection="Horizontal">  
  62.                                                                 <asp:ListItem Text="Amount Wise" Selected="True" Value="1"></asp:ListItem>  
  63.                                                                 <asp:ListItem Text="Quntity Wise" Value="2"></asp:ListItem>  
  64.                                                             </asp:RadioButtonList>  
  65.                                                         </td>  
  66.                                                     </tr>  
  67.                                                 </tr>  
  68.                                                 <tr>  
  69.                                                     <td colspan="5px">  
  70.                                                         <table width="100%">  
  71.                                                             <tr>  
  72.                                                                 <td align="left">  
  73.                                                             Month  
  74.                                                         </td>  
  75.                                                                 <td>  
  76.                                                                     <asp:DropDownList ID="dp_month" runat="server">  
  77.                                                                         <asp:ListItem Value="1" Text="Jan"></asp:ListItem>  
  78.                                                                         <asp:ListItem Value="2" Text="Feb"></asp:ListItem>  
  79.                                                                         <asp:ListItem Value="3" Text="March"></asp:ListItem>  
  80.                                                                         <asp:ListItem Value="4" Text="April"></asp:ListItem>  
  81.                                                                         <asp:ListItem Value="5" Text="May"></asp:ListItem>  
  82.                                                                         <asp:ListItem Value="6" Text="Jun"></asp:ListItem>  
  83.                                                                         <asp:ListItem Value="7" Text="July"></asp:ListItem>  
  84.                                                                         <asp:ListItem Value="8" Text="Aug"></asp:ListItem>  
  85.                                                                         <asp:ListItem Value="9" Text="Sept"></asp:ListItem>  
  86.                                                                         <asp:ListItem Value="10" Text="Oct"></asp:ListItem>  
  87.                                                                         <asp:ListItem Value="11" Text="Nov"></asp:ListItem>  
  88.                                                                         <asp:ListItem Value="12" Text="Dec"></asp:ListItem>  
  89.                                                                     </asp:DropDownList>  
  90.                                                                 </td>  
  91.                                                                 <td align="left">  
  92.                                                             Year  
  93.                                                         </td>  
  94.                                                                 <td>  
  95.                                                                     <asp:DropDownList ID="dp_year" runat="server">  
  96.                                                                         <asp:ListItem Value="2014" Text="2014"></asp:ListItem>  
  97.                                                                         <asp:ListItem Value="2015" Text="2015"></asp:ListItem>  
  98.                                                                         <asp:ListItem Value="2014" Text="2014"></asp:ListItem>  
  99.                                                                         <asp:ListItem Value="2016" Text="2016"></asp:ListItem>  
  100.                                                                         <asp:ListItem Value="2017" Text="2017"></asp:ListItem>  
  101.                                                                         <asp:ListItem Value="2018" Text="2018"></asp:ListItem>  
  102.                                                                         <asp:ListItem Value="2019" Text="2019"></asp:ListItem>  
  103.                                                                         <asp:ListItem Value="2020" Text="2020"></asp:ListItem>  
  104.                                                                     </asp:DropDownList>  
  105.                                                                 </td>  
  106.                                                             </tr>  
  107.                                                         </table>  
  108.                                                     </td>  
  109.                                                 </tr>  
  110.                                                 <tr>  
  111.                                                     <td height="20" colspan="4px" align="center">  
  112.                                                         <asp:ImageButton ID="Btn_Submit" type="image" src="images/submit.jpg" Width="65"  
  113.                                                     Height="28" runat="server" OnClick="Btn_Submit_Click" />  
  114.                                                     </td>  
  115.                                                 </tr>  
  116.                                             </table>  
  117.                                         </td>  
  118.                                         <td align="right" colspan="3px">  
  119.                                             <table style="border: solid 2px #067ac5;" width="100%">  
  120.                                                 <tr>  
  121.                                                     <td colspan="3px" align="center" style="font-size: large; font-weight: bold; color: Blue;  
  122.                                                 text-transform: uppercase;">  
  123.                                                 Total Amount  
  124.                                                   
  125.                                                         <asp:Label ID="lbl_CallcenterName" runat="server"></asp:Label>  
  126.                                                     </td>  
  127.                                                 </tr>  
  128.                                                 <tr>  
  129.                                                     <td colspan="3px" align="center" style="font-size: 12px; font-weight: bold; color: Blue;">  
  130.                                                 Month  
  131.                                                   
  132.                                                         <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>  
  133.                                                 Year-  
  134.                                                         <asp:Label ID="Label2" runat="server" ForeColor="Red"></asp:Label>  
  135.                                                     </td>  
  136.                                                 </tr>  
  137.                                                 <tr>  
  138.                                                     <td>  
  139.                                                    
  140.                                             </td>  
  141.                                                 </tr>  
  142.                                                 <tr>  
  143.                                                     <td style="font-size: larger; font-weight: bold; color: Green;">  
  144.                                                 Total Amount/Quntity  
  145.                                             </td>  
  146.                                                     <td style="font-size: larger; font-weight: bold; color: Black;">  
  147.                                                 :  
  148.                                             </td>  
  149.                                                     <td>  
  150.                                                         <asp:Label ID="lbl_TotalTelecall" runat="server" Style="font-size: larger; font-weight: bold;  
  151.                                                     color: Red;"></asp:Label>  
  152.                                                     </td>  
  153.                                                 </tr>  
  154.                                                 <tr>  
  155.                                                     <td style="font-size: larger; font-weight: bold; color: Green;">  
  156.                                                 Total Deliver  
  157.                                             </td>  
  158.                                                     <td style="font-size: larger; font-weight: bold; color: Black;">  
  159.                                                 :  
  160.                                             </td>  
  161.                                                     <td>  
  162.                                                         <asp:Label ID="lbl_TotalCall" runat="server" Style="font-size: larger; font-weight: bold;  
  163.                                                     color: Red;"></asp:Label>  
  164.                                                     </td>  
  165.                                                 </tr>  
  166.                                                 <tr>  
  167.                                                     <td style="font-size: larger; font-weight: bold; color: Green;">  
  168.                                                 Total Return/Cancel  
  169.                                             </td>  
  170.                                                     <td style="font-size: larger; font-weight: bold; color: Black;">  
  171.                                                 :  
  172.                                             </td>  
  173.                                                     <td>  
  174.                                                         <asp:Label ID="lbl_TotalOrder" runat="server" Style="font-size: larger; font-weight: bold;  
  175.                                                     color: Red;"></asp:Label>  
  176.                                                     </td>  
  177.                                                 </tr>  
  178.                                                 <tr>  
  179.                                                     <td style="font-size: larger; font-weight: bold; color: Green;">  
  180.                                                 Total Panding  
  181.                                             </td>  
  182.                                                     <td style="font-size: larger; font-weight: bold; color: Black;">  
  183.                                                 :  
  184.                                             </td>  
  185.                                                     <td>  
  186.                                                         <asp:Label ID="lab_TotalPanding" runat="server" Style="font-size: larger; font-weight: bold;  
  187.                                                     color: Red;"></asp:Label>  
  188.                                                     </td>  
  189.                                                 </tr>  
  190.                                             </table>  
  191.                                         </td>  
  192.                                     </tr>  
  193.                                 </table>  
  194.                             </div>  
  195.                         </div>  
  196.                         <div class="report-header">  
  197.                             <div class="report-header-outer2">  
  198.                                 <div id="container" style="width: %; height: 250px; margin: 0 auto">  
  199.                                     <asp:Label ID="lbl_bindimage" runat="server"></asp:Label>  
  200.                                 </div>  
  201.                                 <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">  
  202.                                     <tr>  
  203.                                         <td colspan="9" align="center" style="text-align: center;">  
  204.                                             <asp:GridView ID="gd_amount" runat="server" Font-Size="Medium" Width="100%" AutoGenerateColumns="false"  
  205.                                         GridLines="None" RowStyle-CssClass="gridTable tone" FooterStyle-ForeColor="Red"  
  206.                                         FooterStyle-Font-Size="Large" FooterStyle-Font-Bold="true">  
  207.                                                 <Columns>  
  208.                                                     <asp:BoundField DataField="MonthDate" HeaderText="Month Date" DataFormatString="{0:dd/MM/yyyy}"  
  209.                                                 ItemStyle-Font-Bold="true" />  
  210.                                                     <asp:BoundField DataField="TotalAmount" HeaderText="Total" DataFormatString="{0:n2}"  
  211.                                                 ItemStyle-Font-Bold="true" ItemStyle-ForeColor="Red" />  
  212.                                                     <asp:BoundField DataField="DelAmount" HeaderText="Deliver " DataFormatString="{0:n2}"  
  213.                                                 ItemStyle-ForeColor="#f15c80" />  
  214.                                                     <asp:BoundField DataField="Delpct" HeaderText="Del %" DataFormatString="{0:n2}" ItemStyle-ForeColor="#f15c80" />  
  215.                                                     <asp:BoundField DataField="RetAmount" HeaderText="Return/Cancel" DataFormatString="{0:n2}"  
  216.                                                 ItemStyle-ForeColor="#a8cef3" />  
  217.                                                     <asp:BoundField DataField="Retpct" HeaderText="Ret %" DataFormatString="{0:n2}" ItemStyle-ForeColor="#a8cef3" />  
  218.                                                     <asp:BoundField DataField="PanAmount" HeaderText="PanDing" DataFormatString="{0:n2}"  
  219.                                                 ItemStyle-ForeColor="Green" />  
  220.                                                     <asp:BoundField DataField="Pandingpct" HeaderText="Panding %" DataFormatString="{0:n2}"  
  221.                                                 ItemStyle-ForeColor="Green" />  
  222.                                                 </Columns>  
  223.                                                 <HeaderStyle CssClass="GridHeader" />  
  224.                                             </asp:GridView>  
  225.                                         </td>  
  226.                                     </tr>  
  227.                                 </table>  
  228.                             </div>  
  229.                         </div>  
  230.                         <div class="footer white" align="center">  
  231.                     Site Developed by: Dv info Solutions Pvt Ltd: Dv info Solutions Pvt Ltd</div>  
  232.                     </div>  
  233.                 </div>  
  234.             </div>  
  235.             <script type="text/javascript" src="../LIVE Report_files/exporting.js"></script>  
  236.             <script type="text/javascript" src="../LIVE Report_files/highcharts.js"></script>  
  237.         </form>  
  238.     </body>  
  239. </html> 
 C# Code
  1. using System;  
  2. using System.Collections;  
  3. using System.Configuration;  
  4. using System.Data;  
  5. using System.Linq;  
  6. using System.Web;  
  7. using System.Web.Security;  
  8. using System.Web.UI;  
  9. using System.Web.UI.HtmlControls;  
  10. using System.Web.UI.WebControls;  
  11. using System.Web.UI.WebControls.WebParts;  
  12. using System.Text;  
  13.   
  14. public partial class qt_MonthWiseReport: System.Web.UI.Page {  
  15.     StringBuilder sb = new StringBuilder();  
  16.     masterClass_Emp ms = new masterClass_Emp();  
  17.   
  18.     DataTable dt;  
  19.     string str_DelAmount = "";  
  20.     string str_retamount;  
  21.     string str_TotalAmount;  
  22.   
  23.     string str_Pandingamount;  
  24.     string Str_Date;  
  25.     int type;  
  26.     string Text;  
  27.     string ValuePerfix;  
  28.   
  29.     protected void Page_Load(object sender, EventArgs e) {  
  30.         if (!IsPostBack) {  
  31.             bind_ddl1();  
  32.         }  
  33.     }  
  34.     void bind_ddl1() {  
  35.   
  36.         ListItem li = new ListItem("Select""0");  
  37.         ms.bind_DropdownList(dp_CallCener, "Select * from callcenterMst order by CallcenterName""CallcenterName""Callcenterid");  
  38.         dp_CallCener.Items.Insert(0, li);  
  39.   
  40.     }  
  41.   
  42.     protected void Btn_Submit_Click(object sender, ImageClickEventArgs e) {  
  43.         if (Rd_SelectType.SelectedValue == "1") {  
  44.             type = 1;  
  45.             Text = "Amount";  
  46.             ValuePerfix = "(Rs)";  
  47.         } else {  
  48.             type = 2;  
  49.             Text = "Quntity";  
  50.             ValuePerfix = "";  
  51.         }  
  52.         dt = ms.loadGridDataTable(" sp_totalAmountCountWithMonth " + dp_month.SelectedValue + "," + dp_year.SelectedValue + "," + type + "," + dp_CallCener.SelectedValue);  
  53.         for (int i = 0; i < dt.Rows.Count; i++) {  
  54.             if (i != dt.Rows.Count - 1) {  
  55.                 str_TotalAmount += "" + dt.Rows[i][1].ToString() + ",";  
  56.                 str_DelAmount += "" + dt.Rows[i][2].ToString() + ",";  
  57.                 str_retamount += "" + dt.Rows[i][4].ToString() + ",";  
  58.                 str_Pandingamount += "" + dt.Rows[i][6].ToString() + ",";  
  59.                 Str_Date += "'" + Convert.ToDateTime(dt.Rows[i][0].ToString()).ToString("dd") + "',";  
  60.             } else {  
  61.                 str_TotalAmount += "" + dt.Rows[i][1].ToString() + "";  
  62.                 str_DelAmount += "" + dt.Rows[i][2].ToString() + "";  
  63.                 str_retamount += "" + dt.Rows[i][4].ToString() + "";  
  64.                 str_Pandingamount += "" + dt.Rows[i][6].ToString() + "";  
  65.                 Str_Date += "'" + Convert.ToDateTime(dt.Rows[i][0].ToString()).ToString("dd") + "'";  
  66.   
  67.   
  68.             }  
  69.         }  
  70.   
  71.   
  72.         sb.Append("<script type='text/javascript'>" +  
  73.             "$(function () {" +  
  74.             "$('#container').highcharts({" +  
  75.             "title: {" +  
  76.             "text: 'CallCenter Delhi " + Text + " Report '" +  
  77.   
  78.             "}," +  
  79.             "subtitle: {text: 'Month:" + dp_month.SelectedValue + " Year:" + dp_year.SelectedValue + "' }," +  
  80.             "xAxis: {" +  
  81.             " categories: [" + Str_Date + "]" +  
  82.             "}," +  
  83.             " yAxis: {" +  
  84.             " title: {" +  
  85.             "text: 'Total " + Text + "" + ValuePerfix + "'" +  
  86.             " }," +  
  87.             "plotLines: [{" +  
  88.             "value: 10000," +  
  89.             "width: 0," +  
  90.             "color: ''" +  
  91.             "}]" +  
  92.             "}," +  
  93.             "tooltip: {" +  
  94.             "valueSuffix: '" + ValuePerfix + "'" +  
  95.             "}," +  
  96.   
  97.             " series: [{" +  
  98.             "name: 'Total Amount " + Text + "'," +  
  99.             "data: [" + str_TotalAmount + "]," +  
  100.             "color: Highcharts.getOptions().colors[2]" +  
  101.             " },{" +  
  102.             "name: 'Delivery " + Text + "'," +  
  103.             "data: [" + str_DelAmount + "]," +  
  104.             "color: Highcharts.getOptions().colors[5]" +  
  105.             " }, {" +  
  106.             "name: 'Return/Cancel " + Text + "'," +  
  107.             " data: [" + str_retamount + "]," +  
  108.             "color: Highcharts.getOptions().colors[3]" +  
  109.             "}, {" +  
  110.             "name: 'Panding " + Text + "'," +  
  111.             " data: [" + str_Pandingamount + "]," +  
  112.             "color: Highcharts.getOptions().colors[4]" +  
  113.             "}]" +  
  114.   
  115.             "});" +  
  116.             "});" +  
  117.             "</script>");  
  118.         lbl_bindimage.Text = sb.ToString();  
  119.         gd_amount.DataSource = dt;  
  120.         gd_amount.DataBind();  
  121.         lbl_TotalTelecall.Text = dt.Compute("Sum(TotalAmount)""").ToString();  
  122.         lbl_TotalCall.Text = dt.Compute("Sum(DelAmount)""").ToString();  
  123.         lbl_TotalOrder.Text = dt.Compute("Sum(RetAmount)""").ToString();  
  124.         lab_TotalPanding.Text = dt.Compute("Sum(PanAmount)""").ToString();  
  125.   
  126.   
  127.     }