public void GenerateChart(string part, string Tablename, string fromdate, string todate, string shift, string mchn, string unit, string cell, string operation, string Dimension, string Mean, string Dynrefid, string DynValueid)
    {
        //string tempPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

        //foreach (string filePath in Directory.GetFiles(tempPath, "*.*", SearchOption.AllDirectories))
        //{
        //    try
        //    {
        //        FileInfo currentFile = new FileInfo(filePath);
        //        currentFile.Delete();
        //    }
        //    catch (Exception ex)
        //    {
        //        //Debug.WriteLine("Error on file: {0}\r\n   {1}", filePath, ex.Message);
        //    }
        //}

        DBServer db = new DBServer();
        DataSet  ds = new DataSet();

        ds = db.RunViewdimension(part, Tablename, fromdate, todate, shift, mchn, unit, cell, operation, Dimension, Mean, Dynrefid, DynValueid);
        if (ds != null)
        {
            QC_Chart.DataSource = ds.Tables[0];
            QC_Chart.DataBind();
            int row = 0;
            if (ds.Tables[0].Rows.Count > 0)
            {
                string[]  x = new string[ds.Tables[0].Rows.Count];
                decimal[] y = new decimal[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    row += 1;
                    x[i] = Convert.ToString(row);
                    y[i] = Convert.ToDecimal(ds.Tables[0].Rows[i][0]);
                    QC_Chart.Series[0].Points.AddY(Convert.ToDecimal(ds.Tables[0].Rows[i][0]));
                }

                QC_Chart.Series["Series1"].Points.DataBindXY(x, y);

                //***********MoveHOVER

                //QC_Chart.Series["Series1"].ToolTip = "#VALY, #VALX";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    QC_Chart.Series["Series1"].Points[i].ToolTip = "#VALY" + "," + ds.Tables[0].Rows[i][1].ToString();
                }

                QC_Chart.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                QC_Chart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
                QC_Chart.Series["Series3"].YValueMembers = ds.Tables[0].Columns[8].ColumnName;
                QC_Chart.Series["Series4"].YValueMembers = ds.Tables[0].Columns[9].ColumnName;
                QC_Chart.Series["Series5"].YValueMembers = ds.Tables[0].Columns[7].ColumnName;
                QC_Chart.Series["Series6"].YValueMembers = ds.Tables[0].Columns[2].ColumnName;
                QC_Chart.Series["Series7"].YValueMembers = ds.Tables[0].Columns[3].ColumnName;
                //QC_Chart.Series["Series8"].YValueMembers = ds.Tables[0].Columns[6].ColumnName;
                //QC_Chart.Series["Series9"].YValueMembers = ds.Tables[0].Columns[7].ColumnName;
                QC_Chart.Series["Series10"].YValueMembers = ds.Tables[0].Columns[4].ColumnName;

                sp_usl.InnerText = ds.Tables[0].Rows[0][8].ToString();
                sp_lsl.InnerText = ds.Tables[0].Rows[0][9].ToString();
                QC_Chart.Series["Series1"].EmptyPointStyle.Color          = System.Drawing.Color.Black;
                QC_Chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
                QC_Chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
                //if (ds.Tables[0].Rows[0][3].ToString() == "" || ds.Tables[0].Rows[0][2] == null)
                //{
                //    sp_CP.InnerText = "0.00";
                //}
                //else
                //{
                //    sp_CP.InnerText = ds.Tables[0].Rows[0][3].ToString();
                //}
                //if (ds.Tables[0].Rows[0][3].ToString() == "" || ds.Tables[0].Rows[0][3] == null)
                //{
                //    sp_CPK.InnerText = "0.00";
                //}
                //else
                //{
                //    sp_CPK.InnerText = ds.Tables[0].Rows[0][3].ToString();
                //}
                sp_CP.InnerText  = ds.Tables[0].Rows[0][2].ToString();
                sp_CPK.InnerText = ds.Tables[0].Rows[0][3].ToString();
                QC_Chart.ChartAreas["ChartArea1"].AxisY.Maximum = Convert.ToDouble(ds.Tables[0].Rows[0][5].ToString());
                QC_Chart.ChartAreas["ChartArea1"].AxisY.Minimum = Convert.ToDouble(ds.Tables[0].Rows[0][6].ToString());
                //QC_Chart.ChartAreas["ChartArea1"].AxisY.Interval = Convert.ToDouble(ds.Tables[0].Rows[0][10].ToString());
                QC_Chart.ChartAreas["ChartArea1"].AxisY.IntervalAutoMode = IntervalAutoMode.VariableCount;

                //QC_Chart.ChartAreas["ChartArea1"].AxisY.Maximum = Double.NaN; // sets the Maximum to NaN
                //QC_Chart.ChartAreas["ChartArea1"].AxisY.Minimum = Double.NaN; // sets the Minimum to NaN
                //QC_Chart.ChartAreas["ChartArea1"].RecalculateAxesScale();

                div_chart.Visible = true;
                div_error.Visible = false;

                //RUN Values
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "RunvaluesFunc(" + ds.Tables[0].Rows[0][8].ToString() + "," + ds.Tables[0].Rows[0][9].ToString() + "," + ds.Tables[0].Rows[0][7].ToString() + "," + ds.Tables[0].Rows[0][2].ToString() + "," + ds.Tables[0].Rows[0][3].ToString() + "," + ds.Tables[0].Rows[0][4].ToString() + ")", true);
            }
            else
            {
                div_chart.Visible   = false;
                div_error.Visible   = true;
                spn_error.InnerText = "SPC Chart are not available for " + part;
            }
        }
        else
        {
            div_chart.Visible   = false;
            div_error.Visible   = true;
            spn_error.InnerText = "SPC Chart are not available for " + part;
        }
    }