using System;
using System.Windows.Controls;
using PetroleumViscosityTest.Models;

namespace PetroleumViscosityTest.Controls
{
    public partial class TestReportControl : UserControl
    {
        public TestReportControl()
        {
            InitializeComponent();
            txtReportNo.Text = "R" + DateTime.Now.ToString("yyyyMMddHHmmss");
        }

        public void LoadData(ViscosityTestData data)
        {
            txtTestDate.Text = data.TestDate.ToString("yyyy-MM-dd");
            txtSampleID.Text = data.SampleID;
            txtSampleName.Text = data.SampleName;
            txtTestTemp.Text = data.TestTemp.ToString("F1");
            txtConstant.Text = data.Constant.ToString("G5");
            txtViscosity.Text = data.Viscosity.ToString("G4");
            txtDynamicViscosity.Text = data.DynamicViscosity > 0 ? data.DynamicViscosity.ToString("G4") : "—";
            txtPrecision.Text = data.IsRepeatabilityOK ? "符合重复性要求" : "重复性超差，数据仅供参考";
        }
    }
}