protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //记录页面使用次数
            DB.RecordPageUseCount("Quality_TotalIndicator");

            date1   = "1910-01";
            newdate = false;

            int CurrentYear = Convert.ToInt32(DateTime.Now.Year);
            int i;
            for (i = CurrentYear - 5; i <= CurrentYear; i++)
            {
                ListItem Year = new ListItem();
                Year.Text  = Convert.ToString(i);
                Year.Value = Convert.ToString(i);
                if (i == CurrentYear)
                {
                    Year.Selected = true;
                }
                else
                {
                    Year.Selected = false;
                }
                ddlYear.Items.Add(Year);
            }

            string CurrentDate = Convert.ToString(DateTime.Now.Month);
            if (CurrentDate.Length == 1)
            {
                CurrentDate = "0" + CurrentDate;
            }
            foreach (ListItem Month in ddlMonth.Items)
            {
                if (Month.Text == CurrentDate)
                {
                    Month.Selected = true;
                    ddlMonth.Text  = Month.Text;
                    break;
                }
                else
                {
                    Month.Selected = false;
                }
            }
            AddDate(sender, e);
            CurrentDate = Convert.ToString(DateTime.Now.Day);
            if (CurrentDate.Length == 1)
            {
                CurrentDate = "0" + CurrentDate;
            }
            foreach (ListItem day in ddlDay.Items)
            {
                if (day.Text == CurrentDate)
                {
                    day.Selected = true;
                    ddlDay.Text  = day.Text;
                    break;
                }
                else
                {
                    day.Selected = false;
                }
            }
        }
        else
        {
            if (newdate)
            {
                CRVTundishTempRate.ResetReportPartNavigation();
                newdate = false;
            }
            string strCurrentDate = ddlYear.SelectedValue.ToString() + "-" + ddlMonth.SelectedValue.ToString() + "-" + ddlDay.SelectedValue.ToString();

            OracleConnection  conn   = DB.createConn();
            OracleDataAdapter da     = new OracleDataAdapter();
            DataSet           ds     = new DataSet();
            string            strSQL = "";
            try
            {
                conn.Open();

                strSQL           = "Select * from TQ_TOTAL_INDICATOR where LOGTIME = '" + strCurrentDate + "'";
                da.SelectCommand = new OracleCommand(strSQL, conn);
                da.Fill(ds, "TQ_TOTAL_INDICATOR");
                string strFileName = this.Server.MapPath("").ToString() + "\\TotalIndicator.rpt";
                rdt.Load(strFileName);

                rdt.SetDataSource(ds);
                CRVTundishTempRate.ReportSource = rdt;
                CRVTundishTempRate.DataBind();
            }
            catch (Exception ee)
            {
                string strMessage = ee.Message.ToString();
            }
            finally
            {
                ds.Dispose();
                conn.Close();
            }
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //记录页面使用次数
            DB.RecordPageUseCount("Quality_PlanSteelGradeTeam");

            date1   = "1910-01";
            newdate = false;

            int CurrentYear = Convert.ToInt32(DateTime.Now.Year);
            int i;
            for (i = CurrentYear - 5; i <= CurrentYear; i++)
            {
                ListItem Year = new ListItem();
                Year.Text  = Convert.ToString(i);
                Year.Value = Convert.ToString(i);
                if (i == CurrentYear)
                {
                    Year.Selected = true;
                }
                else
                {
                    Year.Selected = false;
                }
                ddlYear.Items.Add(Year);
            }

            string CurrentDate = Convert.ToString(DateTime.Now.Month);
            if (CurrentDate.Length == 1)
            {
                CurrentDate = "0" + CurrentDate;
            }
            foreach (ListItem Month in ddlMonth.Items)
            {
                if (Month.Text == CurrentDate)
                {
                    Month.Selected = true;
                    ddlMonth.Text  = Month.Text;
                    break;
                }
                else
                {
                    Month.Selected = false;
                }
            }
            AddDate(sender, e);
            CurrentDate = Convert.ToString(DateTime.Now.Day);
            if (CurrentDate.Length == 1)
            {
                CurrentDate = "0" + CurrentDate;
            }
            foreach (ListItem day in ddlDay.Items)
            {
                if (day.Text == CurrentDate)
                {
                    day.Selected = true;
                    ddlDay.Text  = day.Text;
                    break;
                }
                else
                {
                    day.Selected = false;
                }
            }
        }
        else
        {
            if (newdate)
            {
                CRVTundishTempRate.ResetReportPartNavigation();
                newdate = false;
            }
            strCurrentDate  = ddlYear.SelectedValue.ToString() + "-" + ddlMonth.SelectedValue.ToString() + "-" + ddlDay.SelectedValue.ToString();
            strCurrentDate1 = ddlYear.SelectedValue.ToString() + "-" + ddlMonth.SelectedValue.ToString();

            OracleConnection  conn   = DB.createConn();
            OracleDataAdapter da     = new OracleDataAdapter();
            DataSet           ds     = new DataSet();
            string            strSQL = "";
            try
            {
                if (newdate)
                {
                    CRVTundishTempRate.ResetReportPartNavigation();
                    newdate = false;
                }
                conn.Open();
                string j = Quality.SelectedValue.ToString();
                if (j == "0")
                {
                    strSQL           = "Select * from TQ_PlanSteelGrade_Team where LOGTIME = '" + strCurrentDate + "'  order by Plan_SteelGrade";
                    da.SelectCommand = new OracleCommand(strSQL, conn);

                    da.Fill(ds, "TQ_PlanSteelGrade_Team");
                    rdt.Load(this.Server.MapPath("").ToString() + "\\PlanSteelGradeTeam.rpt");

                    //rdt.PrintOptions.PrinterName = "Microsoft Office Document Image Writer";
                    rdt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperEsheet;

                    rdt.SetDataSource(ds);

                    CRVTundishTempRate.ReportSource = rdt;
                    CRVTundishTempRate.DataBind();
                }
                else if (j == "1")
                {
                    strSQL           = "Select * from TQ_PlanSteelGrade_Info where substr(LOGTIME,1,7) = '" + strCurrentDate1 + "'  order by LOGTIME,Team";
                    da.SelectCommand = new OracleCommand(strSQL, conn);
                    da.Fill(ds, "TQ_PlanSteelGrade_Info");

                    rdt.Load(this.Server.MapPath("").ToString() + "\\PlanSteelGradeInfo.rpt");

                    //rdt.PrintOptions.PrinterName = "Microsoft Office Document Image Writer";
                    rdt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperEsheet;

                    rdt.SetDataSource(ds);
                    CRVTundishTempRate.ReportSource = rdt;
                    CRVTundishTempRate.DataBind();
                }
                else if (j == "2")
                {
                    strSQL           = "Select * from TQ_PlanSteelGrade_Ele where LOGTIME = '" + strCurrentDate + "'  order by Plan_SteelGrade";
                    da.SelectCommand = new OracleCommand(strSQL, conn);
                    da.Fill(ds, "TQ_PlanSteelGrade_Ele");

                    string strFileName = this.Server.MapPath("").ToString() + "\\PlanSteelGradeEle.rpt ";
                    rdt.Load(strFileName);

                    //rdt.PrintOptions.PrinterName = "Microsoft Office Document Image Writer";
                    rdt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperEsheet;

                    rdt.SetDataSource(ds);
                    CRVTundishTempRate.ReportSource = rdt;
                    CRVTundishTempRate.DataBind();
                }
            }
            catch (Exception ee)
            {
                Response.Write(ee.ToString());//"出错");
            }
            finally
            {
                ds.Dispose();
                conn.Close();
            }
        }
    }