Exemple #1
0
    private void BindGvAndChart()
    {
        try
        {
            DataSet dsReturn = FragmentationLineRateData.QueryPatchLineDataDtl(sType, sName, locationkey, lineName, shiftName, stime, etime);

            DataTable dtGv = LoadColumnsResource(dsReturn.Tables["PATCH_DATA"]);
            ViewState["grid"] = dtGv;

            ASPxSummaryItem item = new ASPxSummaryItem();
            item.FieldName     = "PATCH_QUANTITY";
            item.SummaryType   = SummaryItemType.Sum;
            item.DisplayFormat = "不良总计:{0}";
            this.grid.TotalSummary.Add(item);
            this.grid.Settings.ShowFooter = true;

            this.grid.DataSource = dtGv;
            //this.grid.SummaryText = "PATCH_QUANTITY";
            this.grid.DataBind();

            if (dsReturn.Tables["PATCH_COUNT"].Rows.Count > 0)
            {
                DataTable dt = seriesTable(dsReturn.Tables["PATCH_COUNT"]);
                CreateChart(dt);
            }
        }
        catch (Exception ex)
        {
        }
    }
Exemple #2
0
    public void BindFactory()
    {
        DataSet dsFactory = FragmentationLineRateData.GetFactoryWorkPlace();

        cboFactory.DataSource = dsFactory.Tables[0];
        cboFactory.TextField  = "LOCATION_NAME";
        cboFactory.ValueField = "LOCATION_KEY";
        cboFactory.DataBind();
        cboFactory.Items.Insert(0, new ListEditItem("ALL", "ALL"));
        cboFactory.SelectedIndex = 0;
    }
Exemple #3
0
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        BindLineName();

        string   sStartDate, sEndDate, sShiftName, sDateParam1, sDateParam2, sSupplier, sSupplierName, sStepName, sStepName1, sFlowName, sFlowName1, sPorMode, sPorMode1, sFactoryroomName, sLineName;
        DateTime dtStartDate, dtEndDate, dtParam, dNow;
        int      i, nNumerator, nDenominator, nTNumerator, nTDenominator, nRow;

        string[] lineNames;
        decimal  dParam;

        i    = 0;
        nRow = 0;

        sStartDate = deStartDate.Text.Trim();
        sEndDate   = deEndDate.Text.Trim();
        //sShiftName = cboShif.Text.Trim();
        sShiftName       = cboShif.SelectedItem.Value.ToString();
        sFactoryroomName = cboFactory.Text.Trim();
        sLineName        = ddeWO.Text.Trim();
        lineName         = "";

        dNow = DateTime.Now;



        if (sLineName != "")
        {
            lineNames = sLineName.Split('#');
            for (int w = 0; w < lineNames.Length; w++)
            {
                if (lineName == "")
                {
                    lineName = "'" + lineNames[w].ToString().Trim() + "'";
                }
                else
                {
                    lineName = lineName + ",'" + lineNames[w].ToString().Trim() + "'";
                }
            }
        }

        if (sStartDate == "" || sEndDate == "")
        {
            base.ShowMessageBox(this.Page, "查询参数不能都为空!");
            return;
        }
        dtStartDate = Convert.ToDateTime(sStartDate);
        dtEndDate   = Convert.ToDateTime(sEndDate);
        if (dtStartDate > dtEndDate)
        {
            base.ShowMessageBox(this.Page, "起始日期不能大于结止日期!");
            return;
        }

        if (dtEndDate > dNow)
        {
            base.ShowMessageBox(this.Page, "截止日期不能大于当前日期!");
            return;
        }

        this.hidStartDate.Value = dtStartDate.ToString();
        this.hidEndDate.Value   = dtEndDate.ToString();

        DataTable dtFragment = new DataTable();

        dtFragment.Columns.Add("FNO");
        dtFragment.Columns.Add("FTYPE");
        dtFragment.Columns.Add("FITME");
        dtFragment.Columns.Add("FTOT");
        dtFragment.Columns.Add("FPatchTOT");
        dtParam = dtStartDate;
        while (dtParam <= dtEndDate)
        {
            dtParam = dtStartDate.AddDays(i + 1);
            dtFragment.Columns.Add("F" + i.ToString());
            i = i + 1;
        }
        object[] objrow = new object[i + 5];
        objrow[0] = (object)"NO";
        objrow[1] = (object)"类型";
        objrow[2] = (object)"项目";
        objrow[3] = (object)"累计";
        objrow[4] = (object)"碎片数目";
        for (int r = 0; r < i; r++)
        {
            objrow[r + 5] = (object)dtStartDate.AddDays(r).ToString("yyyy-MM-dd");
        }
        dtFragment.Rows.Add(objrow);

        this.hidLoactionKey.Value = sFactoryroomName.Trim();
        this.hidShiftName.Value   = sShiftName.Trim();

        DataSet dsPatchData = FragmentationLineRateData.GetLinePatchData(sFactoryroomName, lineName, dtStartDate.ToString("yyyy-MM-dd"), dtEndDate.ToString("yyyy-MM-dd"), sShiftName, "");

        #region//(焊前+焊后)总碎片率
        nNumerator    = 0;
        nDenominator  = 0;
        nTNumerator   = 0;
        nTDenominator = 0;
        dParam        = 0;
        object[] objrow1 = new object[i + 5];
        objrow1[0] = (object)"1";
        objrow1[1] = (object)"A";
        objrow1[2] = (object)"(焊前+焊后)总碎片率";

        for (int r = 0; r < i; r++)
        {
            sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
            sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

            //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 09:00:00")))
            if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
            {
                var vpatch1 = (from vp1 in dsPatchData.Tables[0].AsEnumerable()
                               where vp1.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                               vp1.Field <string>("PATCH_ITEM") == "(焊前+焊后)总碎片率"
                               select vp1.Field <int>("PATCH_QTY")).Sum();

                var vtot1 = (from vt1 in dsPatchData.Tables[0].AsEnumerable()
                             where vt1.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                             vt1.Field <string>("PATCH_ITEM") == "(焊前+焊后)总碎片率"
                             select vt1.Field <int>("TOT_QTY")).Sum();

                nNumerator  = int.Parse(vpatch1.ToString());
                nTNumerator = nTNumerator + nNumerator;

                nDenominator  = int.Parse(vtot1.ToString());
                nTDenominator = nTDenominator + nDenominator;
            }
            else
            {
                nNumerator   = 0;
                nDenominator = 0;
            }

            if (nDenominator > 0)
            {
                dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
            }
            else if (nNumerator > 0)
            {
                dParam = 100;
            }
            else
            {
                dParam = 0;
            }
            objrow1[r + 5] = (object)(dParam.ToString("##0.00") + "%");
        }
        if (nTDenominator > 0)
        {
            dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
        }
        else if (nTNumerator > 0)
        {
            dParam = 100;
        }
        else
        {
            dParam = 0;
        }
        objrow1[3] = (object)(dParam.ToString("##0.00") + "%");
        objrow1[4] = (object)(nTNumerator);
        dtFragment.Rows.Add(objrow1);
        #endregion

        #region//焊前碎片率
        nNumerator    = 0;
        nDenominator  = 0;
        nTNumerator   = 0;
        nTDenominator = 0;
        dParam        = 0;
        object[] objrow2 = new object[i + 5];
        objrow2[0] = (object)"2";
        objrow2[1] = (object)"B";
        objrow2[2] = (object)"焊前碎片率";
        for (int r = 0; r < i; r++)
        {
            sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
            sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";
            //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
            if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
            {
                var vpatch2 = (from vp2 in dsPatchData.Tables[0].AsEnumerable()
                               where vp2.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                               vp2.Field <string>("PATCH_ITEM") == "焊前碎片率"
                               select vp2.Field <int>("PATCH_QTY")).Sum();

                var vtot2 = (from vt2 in dsPatchData.Tables[0].AsEnumerable()
                             where vt2.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                             vt2.Field <string>("PATCH_ITEM") == "焊前碎片率"
                             select vt2.Field <int>("TOT_QTY")).Sum();

                nNumerator  = int.Parse(vpatch2.ToString());
                nTNumerator = nTNumerator + nNumerator;

                nDenominator  = int.Parse(vtot2.ToString());
                nTDenominator = nTDenominator + nDenominator;
            }
            else
            {
                nNumerator   = 0;
                nDenominator = 0;
            }

            if (nDenominator > 0)
            {
                dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
            }
            else if (nNumerator > 0)
            {
                dParam = 100;
            }
            else
            {
                dParam = 0;
            }
            objrow2[r + 5] = (object)(dParam.ToString("##0.00") + "%");
            objrow2[4]     = (object)(nTNumerator);
        }
        if (nTDenominator > 0)
        {
            dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
        }
        else if (nTNumerator > 0)
        {
            dParam = 100;
        }
        else
        {
            dParam = 0;
        }
        objrow2[3] = (object)(dParam.ToString("##0.00") + "%");
        dtFragment.Rows.Add(objrow2);
        #endregion

        #region//焊后碎片率
        nNumerator    = 0;
        nDenominator  = 0;
        nTNumerator   = 0;
        nTDenominator = 0;
        dParam        = 0;
        object[] objrow3 = new object[i + 5];
        objrow3[0] = (object)"3";
        objrow3[1] = (object)"C";
        objrow3[2] = (object)"焊后碎片率";
        for (int r = 0; r < i; r++)
        {
            sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
            sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

            //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
            if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
            {
                var vpatch3 = (from vp3 in dsPatchData.Tables[0].AsEnumerable()
                               where vp3.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                               vp3.Field <string>("PATCH_ITEM") == "焊后碎片率"
                               select vp3.Field <int>("PATCH_QTY")).Sum();

                var vtot3 = (from vt3 in dsPatchData.Tables[0].AsEnumerable()
                             where vt3.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                             vt3.Field <string>("PATCH_ITEM") == "焊后碎片率"
                             select vt3.Field <int>("TOT_QTY")).Sum();

                nNumerator  = int.Parse(vpatch3.ToString());
                nTNumerator = nTNumerator + nNumerator;

                nDenominator  = int.Parse(vtot3.ToString());
                nTDenominator = nTDenominator + nDenominator;
            }
            else
            {
                nNumerator   = 0;
                nDenominator = 0;
            }


            if (nDenominator > 0)
            {
                dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
            }
            else if (nNumerator > 0)
            {
                dParam = 100;
            }
            else
            {
                dParam = 0;
            }
            objrow3[r + 5] = (object)(dParam.ToString("##0.00") + "%");
        }
        if (nTDenominator > 0)
        {
            dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
        }
        else if (nTNumerator > 0)
        {
            dParam = 100;
        }
        else
        {
            dParam = 0;
        }
        objrow3[3] = (object)(dParam.ToString("##0.00") + "%");
        objrow3[4] = (object)(nTNumerator);
        dtFragment.Rows.Add(objrow3);
        #endregion

        #region//红外不良碎片率
        nNumerator    = 0;
        nDenominator  = 0;
        nTNumerator   = 0;
        nTDenominator = 0;
        dParam        = 0;
        object[] objrow4 = new object[i + 5];
        objrow4[0] = (object)"4";
        objrow4[1] = (object)"D";
        objrow4[2] = (object)"红外不良碎片率";
        for (int r = 0; r < i; r++)
        {
            sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
            sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

            //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
            if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
            {
                var vpatch4 = (from vp4 in dsPatchData.Tables[0].AsEnumerable()
                               where vp4.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                               vp4.Field <string>("PATCH_ITEM") == "红外不良碎片率"
                               select vp4.Field <int>("PATCH_QTY")).Sum();

                var vtot4 = (from vt4 in dsPatchData.Tables[0].AsEnumerable()
                             where vt4.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                             vt4.Field <string>("PATCH_ITEM") == "红外不良碎片率"
                             select vt4.Field <int>("TOT_QTY")).Sum();

                nNumerator  = int.Parse(vpatch4.ToString());
                nTNumerator = nTNumerator + nNumerator;

                nDenominator  = int.Parse(vtot4.ToString());
                nTDenominator = nTDenominator + nDenominator;
            }
            else
            {
                nNumerator   = 0;
                nDenominator = 0;
            }


            if (nDenominator > 0)
            {
                dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
            }
            else if (nNumerator > 0)
            {
                dParam = 100;
            }
            else
            {
                dParam = 0;
            }
            objrow4[r + 5] = (object)(dParam.ToString("##0.00") + "%");
        }
        if (nTDenominator > 0)
        {
            dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
        }
        else if (nTNumerator > 0)
        {
            dParam = 100;
        }
        else
        {
            dParam = 0;
        }
        objrow4[3] = (object)(dParam.ToString("##0.00") + "%");
        objrow4[4] = (object)(nTNumerator);
        dtFragment.Rows.Add(objrow4);
        #endregion

        #region//硅片供应商碎片率
        DataSet dsSupplier = FragmentationLineRateData.GetSupplier("", "", "");
        if (dsSupplier.Tables[0].Rows.Count > 0)
        {
            nRow = 5;
            for (int s = 0; s < dsSupplier.Tables[0].Rows.Count; s++)
            {
                sSupplier     = dsSupplier.Tables[0].Rows[s]["NAME"].ToString().Trim();
                sSupplierName = "(" + sSupplier + ")" + "碎片率";
                nRow          = nRow + s;
                nNumerator    = 0;
                nDenominator  = 0;
                nTNumerator   = 0;
                nTDenominator = 0;
                dParam        = 0;
                object[] objrowsup = new object[i + 5];
                objrowsup[0] = (object)nRow;
                objrowsup[1] = (object)"E";
                objrowsup[2] = (object)sSupplierName;
                for (int r = 0; r < i; r++)
                {
                    sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
                    sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

                    //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
                    if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
                    {
                        var vpatch5 = (from vp5 in dsPatchData.Tables[0].AsEnumerable()
                                       where vp5.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                       vp5.Field <string>("PATCH_ITEM") == sSupplierName
                                       select vp5.Field <int>("PATCH_QTY")).Sum();

                        var vtot5 = (from vt5 in dsPatchData.Tables[0].AsEnumerable()
                                     where vt5.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                     vt5.Field <string>("PATCH_ITEM") == sSupplierName
                                     select vt5.Field <int>("TOT_QTY")).Sum();

                        nNumerator  = int.Parse(vpatch5.ToString());
                        nTNumerator = nTNumerator + nNumerator;

                        nDenominator  = int.Parse(vtot5.ToString());
                        nTDenominator = nTDenominator + nDenominator;
                    }
                    else
                    {
                        nNumerator   = 0;
                        nDenominator = 0;
                    }


                    if (nDenominator > 0)
                    {
                        dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
                    }
                    else if (nNumerator > 0)
                    {
                        dParam = 100;
                    }
                    else
                    {
                        dParam = 0;
                    }
                    objrowsup[r + 5] = (object)(dParam.ToString("##0.00") + "%");
                }
                if (nTDenominator > 0)
                {
                    dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
                }
                else if (nTNumerator > 0)
                {
                    dParam = 100;
                }
                else
                {
                    dParam = 0;
                }
                objrowsup[3] = (object)(dParam.ToString("##0.00") + "%");
                objrowsup[4] = (object)(nTNumerator);
                dtFragment.Rows.Add(objrowsup);
            }
        }
        #endregion

        #region//各工序碎片率
        DataSet dsStepName = FragmentationLineRateData.GetStepName();
        if (dsStepName.Tables[0].Rows.Count > 0)
        {
            nRow = nRow + 1;
            for (int s = 0; s < dsStepName.Tables[0].Rows.Count; s++)
            {
                sStepName     = dsStepName.Tables[0].Rows[s]["ROUTE_OPERATION_NAME"].ToString().Trim();
                sStepName1    = "(" + sStepName + ")" + "碎片率";
                nRow          = nRow + s;
                nNumerator    = 0;
                nDenominator  = 0;
                nTNumerator   = 0;
                nTDenominator = 0;
                dParam        = 0;
                object[] objrowstep = new object[i + 5];
                objrowstep[0] = (object)nRow;
                objrowstep[1] = (object)"F";
                objrowstep[2] = (object)sStepName1;
                for (int r = 0; r < i; r++)
                {
                    sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
                    sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

                    //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
                    if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
                    {
                        var vpatch6 = (from vp6 in dsPatchData.Tables[0].AsEnumerable()
                                       where vp6.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                       vp6.Field <string>("PATCH_ITEM") == sStepName1
                                       select vp6.Field <int>("PATCH_QTY")).Sum();

                        var vtot6 = (from vt6 in dsPatchData.Tables[0].AsEnumerable()
                                     where vt6.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                     vt6.Field <string>("PATCH_ITEM") == sStepName1
                                     select vt6.Field <int>("TOT_QTY")).Sum();

                        nNumerator  = int.Parse(vpatch6.ToString());
                        nTNumerator = nTNumerator + nNumerator;

                        nDenominator  = int.Parse(vtot6.ToString());
                        nTDenominator = nTDenominator + nDenominator;
                    }
                    else
                    {
                        nNumerator   = 0;
                        nDenominator = 0;
                    }


                    if (nDenominator > 0)
                    {
                        dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
                    }
                    else if (nNumerator > 0)
                    {
                        dParam = 100;
                    }
                    else
                    {
                        dParam = 0;
                    }
                    objrowstep[r + 5] = (object)(dParam.ToString("##0.00") + "%");
                }
                if (nTDenominator > 0)
                {
                    dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
                }
                else if (nTNumerator > 0)
                {
                    dParam = 100;
                }
                else
                {
                    dParam = 0;
                }
                objrowstep[3] = (object)(dParam.ToString("##0.00") + "%");
                objrowstep[4] = (object)(nTNumerator);
                dtFragment.Rows.Add(objrowstep);
            }
        }
        #endregion

        #region//杭州各栋别碎片率
        string[] sflow = new string[] { "A", "B", "C" };
        if (sflow.Length > 0)
        {
            nRow = nRow + 1;
            for (int s = 0; s < sflow.Length; s++)
            {
                sFlowName     = sflow[s].ToString().Trim();
                sFlowName1    = "杭州(" + sFlowName + ")" + "栋碎片率";
                nRow          = nRow + s;
                nNumerator    = 0;
                nDenominator  = 0;
                nTNumerator   = 0;
                nTDenominator = 0;
                dParam        = 0;
                object[] objrowflow = new object[i + 5];
                objrowflow[0] = (object)nRow;
                objrowflow[1] = (object)"G";
                objrowflow[2] = (object)sFlowName1;
                for (int r = 0; r < i; r++)
                {
                    sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
                    sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

                    //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
                    if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
                    {
                        var vpatch7 = (from vp7 in dsPatchData.Tables[0].AsEnumerable()
                                       where vp7.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                       vp7.Field <string>("PATCH_ITEM") == sFlowName1
                                       select vp7.Field <int>("PATCH_QTY")).Sum();

                        var vtot7 = (from vt7 in dsPatchData.Tables[0].AsEnumerable()
                                     where vt7.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                     vt7.Field <string>("PATCH_ITEM") == sFlowName1
                                     select vt7.Field <int>("TOT_QTY")).Sum();

                        nNumerator  = int.Parse(vpatch7.ToString());
                        nTNumerator = nTNumerator + nNumerator;

                        nDenominator  = int.Parse(vtot7.ToString());
                        nTDenominator = nTDenominator + nDenominator;
                    }
                    else
                    {
                        nNumerator   = 0;
                        nDenominator = 0;
                    }


                    if (nDenominator > 0)
                    {
                        dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
                    }
                    else if (nNumerator > 0)
                    {
                        dParam = 100;
                    }
                    else
                    {
                        dParam = 0;
                    }
                    objrowflow[r + 5] = (object)(dParam.ToString("##0.00") + "%");
                }
                if (nTDenominator > 0)
                {
                    dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
                }
                else if (nTNumerator > 0)
                {
                    dParam = 100;
                }
                else
                {
                    dParam = 0;
                }
                objrowflow[3] = (object)(dParam.ToString("##0.00") + "%");
                objrowflow[4] = (object)(nTNumerator);
                dtFragment.Rows.Add(objrowflow);
            }
        }
        #endregion

        #region//各型号碎片率
        DataSet dsPromode = FragmentationLineRateData.GetProMode();
        if (dsPromode.Tables[0].Rows.Count > 0)
        {
            nRow = nRow + 1;
            for (int s = 0; s < dsPromode.Tables[0].Rows.Count; s++)
            {
                sPorMode      = dsPromode.Tables[0].Rows[s]["PROMODEL_NAME"].ToString().Trim();
                sPorMode1     = "(" + sPorMode + ")" + "碎片率";
                nRow          = nRow + s;
                nNumerator    = 0;
                nDenominator  = 0;
                nTNumerator   = 0;
                nTDenominator = 0;
                dParam        = 0;
                object[] objrowmode = new object[i + 5];
                objrowmode[0] = (object)nRow;
                objrowmode[1] = (object)"H";
                objrowmode[2] = (object)sPorMode1;
                for (int r = 0; r < i; r++)
                {
                    sDateParam1 = dtStartDate.AddDays(r).ToString("yyyy-MM-dd") + " 09:00:00";
                    sDateParam2 = dtStartDate.AddDays(r + 1).ToString("yyyy-MM-dd") + " 09:00:00";

                    //if ((Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd"))) || (Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") == dNow.ToString("yyyy-MM-dd") && dNow > Convert.ToDateTime(dNow.ToString("yyyy-MM-dd") + " 08:00:00")))
                    if (Convert.ToDateTime(Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd")) < Convert.ToDateTime(dNow.ToString("yyyy-MM-dd")) && dNow > Convert.ToDateTime(sDateParam2))
                    {
                        var vpatch8 = (from vp8 in dsPatchData.Tables[0].AsEnumerable()
                                       where vp8.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                       vp8.Field <string>("PATCH_ITEM") == sPorMode1
                                       select vp8.Field <int>("PATCH_QTY")).Sum();

                        var vtot8 = (from vt8 in dsPatchData.Tables[0].AsEnumerable()
                                     where vt8.Field <string>("PATCH_DATE") == Convert.ToDateTime(sDateParam1).ToString("yyyy-MM-dd") &&
                                     vt8.Field <string>("PATCH_ITEM") == sPorMode1
                                     select vt8.Field <int>("TOT_QTY")).Sum();

                        nNumerator  = int.Parse(vpatch8.ToString());
                        nTNumerator = nTNumerator + nNumerator;

                        nDenominator  = int.Parse(vtot8.ToString());
                        nTDenominator = nTDenominator + nDenominator;
                    }
                    else
                    {
                        nNumerator   = 0;
                        nDenominator = 0;
                    }


                    if (nDenominator > 0)
                    {
                        dParam = Convert.ToDecimal(nNumerator) * 100 / Convert.ToDecimal(nDenominator);
                    }
                    else if (nNumerator > 0)
                    {
                        dParam = 100;
                    }
                    else
                    {
                        dParam = 0;
                    }
                    objrowmode[r + 5] = (object)(dParam.ToString("##0.00") + "%");
                }
                if (nTDenominator > 0)
                {
                    dParam = Convert.ToDecimal(nTNumerator) * 100 / Convert.ToDecimal(nTDenominator);
                }
                else if (nTNumerator > 0)
                {
                    dParam = 100;
                }
                else
                {
                    dParam = 0;
                }
                objrowmode[3] = (object)(dParam.ToString("##0.00") + "%");
                objrowmode[4] = (object)(nTNumerator);
                dtFragment.Rows.Add(objrowmode);
            }
        }
        #endregion

        Cache[Session.SessionID + "FRATE"] = dtFragment;
        gvFragmentation.DataSource         = null;
        gvFragmentation.Columns.Clear();
        gvFragmentation.AutoGenerateColumns = true;
        gvFragmentation.DataSource          = dtFragment;
        gvFragmentation.DataBind();


        seriesTable(dtFragment);



        for (int n = 0; n < gvFragmentation.Columns.Count; n++)
        {
            if (gvFragmentation.Columns[n].ToString().Equals("FTYPE"))
            {
                gvFragmentation.Columns["FTYPE"].Visible = false;
                continue;
            }
        }
    }