예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCompany();

            this.Timer1.Enabled = false;
            //BindReportName();
            this.Session["bl"] = 0;

            Bussiness.Config config = new Config();
            DataTable        dt     = config.ReadConfig();
            if (dt != null && dt.Rows.Count > 0)
            {
                this.hddMinSplitTime.Value = dt.Rows[0][2].ToString();
                this.txtSplitTime.Value    = dt.Rows[0][2].ToString();
                this.hddMaxTime.Value      = dt.Rows[0][5].ToString();
                this.txtSYTime.Value       = dt.Rows[0][4].ToString();
                this.calSYStartTime.Text   = DateTime.Now.ToString();
            }

            Bussiness.ThermalTestReport report = new ThermalTestReport();
            if (report.IsDoingExpriment())
            {
                this.btnStartEnd.Enabled = false;
            }

            this.btnView.Enabled = false;
            this.btnView.Attributes.Add("onclick", "linkExpriment()");
        }
    }
예제 #2
0
    /// <summary>
    /// 开始试验
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnStartEnd_Click(object sender, EventArgs e)
    {
        ThermalTestReport report = new ThermalTestReport();

        if (ddlCompany.SelectedValue == "0")
        {
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "msg1", "alert('请选择分公司...');", true);
            return;
        }
        if (ddlPlant.SelectedValue == "0")
        {
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "msg1", "alert('请选择电厂...');", true);
            return;
        }
        if (ddlUnit.SelectedValue == "0")
        {
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "msg1", "alert('请选择机组...');", true);
            return;
        }
        if (ddlSYName.SelectedValue == "0")
        {
            JScript.Alert("请选择试验名称!");
            return;
        }
        if (txtSYR.Value == "")
        {
            JScript.Alert("请填写试验人!");
            return;
        }
        if (btnStartEnd.Text == "开始试验")
        {
            if (report.IsDoingExpriment())
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "msg1", "alert('已有试验正在运行,请稍后运行试验...');", true);
                return;
            }
            this.btnView.Enabled = false;

            ThermalTestTemplate template = new ThermalTestTemplate();
            if (template.GetTemplateID(this.ddlSYName.SelectedItem.Text.Trim(), this.ddlUnit.SelectedValue).ToString() == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "msg1", "alert('该机组尚未配置...');", true);
                return;
            }
            report.TESTTemplateID = template.GetTemplateID(this.ddlSYName.SelectedItem.Text.Trim(), this.ddlUnit.SelectedValue);
            report.TESTCondition  = GetCondition();
            report.ReportName     = this.txtReportName.Value;
            report.Tester         = this.txtSYR.Value;
            report.UNITID         = ddlUnit.SelectedValue.Trim();
            report.TestBegin      = Convert.ToDateTime(this.calSYStartTime.Text);
            report.TestCalBegin   = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
            report.TestDuration   = Convert.ToInt32(this.txtSYTime.Value);
            report.SampleInterval = Convert.ToInt32(this.txtSplitTime.Value);
            Bussiness.ThermalTestReport.UserState userState = ThermalTestReport.UserState.New;


            report.InsertTest(userState, report);

            this.Timer1.Interval = 1000;
            this.Timer1.Enabled  = true;
            btnStartEnd.Text     = "终止试验";

            this.Label1.Text = this.txtReportName.Value + "试验正在进行已完成0%";
        }
        else
        {
            this.Timer1.Enabled = false;
            int curReportId = report.GetMaxReportId();
            report.EndTest(curReportId);
            btnStartEnd.Text = "开始试验";
            report.EndTest(curReportId);
            this.Timer1.Enabled = true;
            btnStartEnd.Enabled = false;
            this.Label1.Text    = "试验已中止";
        }
    }