private void CreateReportModel() { _PartReport = new PartReport() { Task = _Task }; _DataSource = new List <ExecuteDimensionEntityViewModel>(); if (_CurrentTemplate.Dimensions.Count == 0) { PmsService.Instance.PopulateDimensionsForPart(_CurrentTemplate); } foreach (var en in _CurrentTemplate.Dimensions) { var newDimension = en.Clone(); _PartReport.Dimensions.Add(newDimension); //为PartReport创建新的dimensions从而用于插入数据库 _DataSource.Add(new ExecuteDimensionEntityViewModel(newDimension)); } if (_CurrentTemplate.Dimensions.Count > 0) { _SeletedDimension = _PartReport.Dimensions[0]; } dataGridView1.DataSource = _DataSource; dataGridView1.Rows[0].Selected = true; }
public void PopulateDimensionsForReport(PartReport i_PartReport) { var dimension = new DbDimension(); i_PartReport.Dimensions = dimension.GetDimensionsByMeasureMentReport(i_PartReport); i_PartReport.Dimensions.Sort((i_Dimension, i_Dimension1) => i_Dimension.SerialNumber - i_Dimension1.SerialNumber); }
public void SaveReport(PartReport i_PartReport) { var dbPartReport = new DbPartReport(); if (i_PartReport.Id == -1) { dbPartReport.InsertPartReport(i_PartReport); } else { dbPartReport.UpdatePartReport(i_PartReport); } var dbDimension = new DbDimension(); foreach (var dimension in i_PartReport.Dimensions) { dimension.PartReport = i_PartReport; if (dimension.Id == -1) { dbDimension.InsertDimension(dimension); } else { dbDimension.UpdateDimension(dimension); } } }
public void Finish(PartReport i_PartReport) { PmsService.Instance.SaveReport(i_PartReport); Mediator.Mediator.Instance.NotifyColleagues(Execution.OneCompleted, i_PartReport); var executed = PmsService.Instance.GetPartReports(_Task); Mediator.Mediator.Instance.NotifyColleagues(App.ExecutionProgress, string.Format("{0}/{1}", _Task.SampleNumber, executed.Count)); }
public void GetDimensionsByMeasureMentReportTest() { DbDimension target = new DbDimension(); // TODO: Initialize to an appropriate value PartReport i_PartReport = null; // TODO: Initialize to an appropriate value List <Dimension> expected = null; // TODO: Initialize to an appropriate value List <Dimension> actual; actual = target.GetDimensionsByMeasureMentReport(i_PartReport); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void UpdatePartReport(PartReport i_PartReport) { DbHelper db = new DbHelper(); var updateCmd = db.GetSqlStringCommond( //" TaskID, MeasureDatetime, Operator, OperatorComment, Auditor, AuditDatetime, AuditComment, Approver, ApproveDatetime, ApproveComment"; string.Format( "update {0} set Operator='{1}',MeasureDatetime='{2}',OperatorComment='{3}',Auditor='{4}', AuditDatetime='{5}',AuditComment='{6}',Approver='{7}',ApproveDatetime='{8}',ApproveComment='{9}', TaskId={10} where ID={11}", TableName, i_PartReport.Operator, i_PartReport.MeasurementDatetime , i_PartReport.OperatorComment, i_PartReport.Auditor, i_PartReport.AuditDatetime, i_PartReport.AuditComment, i_PartReport.Approver, i_PartReport.ApproveDatetime, i_PartReport.ApproveComment, i_PartReport.Task.Id, i_PartReport.Id)); db.ExecuteNonQuery(updateCmd); }
public Dimension() { Part = new Part() { Id = -1 }; PartReport = new PartReport() { Id = -1 }; Dimensiontype = ""; PreFix = ""; CadHandle = ""; }
public List <Dimension> GetDimensionsByMeasureMentReport(PartReport i_PartReport) { var result = new List <Dimension>(); DbHelper db = new DbHelper(); var selCmd = db.GetSqlStringCommond( string.Format( "Select {0} from {2} where MeasurementReportID = {1}", SelectColums , i_PartReport.Id, TableName)); var reader = db.ExecuteReader(selCmd); while (reader.Read()) { result.Add(PopulateADimension(reader)); } selCmd.Connection.Close(); return(result); }
public void InsertPartReport(PartReport i_PartReport) { DbHelper db = new DbHelper(); var updateCmd = db.GetSqlStringCommond( //TaskID, MeasureDatetime, Operator, OperatorComment, Auditor, AuditDatetime, AuditComment, Approver, ApproveDatetime, ApproveComment"; string.Format( "insert into {0} ({1}) values({2},'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", TableName, InsertColumns, i_PartReport.Task.Id, i_PartReport.MeasurementDatetime, i_PartReport.Operator , i_PartReport.OperatorComment, i_PartReport.Auditor, i_PartReport.AuditDatetime, i_PartReport.AuditComment, i_PartReport.Approver, i_PartReport.ApproveDatetime, i_PartReport.ApproveComment)); db.ExecuteNonQuery(updateCmd); var selectCmd = db.GetSqlStringCommond(string.Format("select MAX(ID) from {0}", TableName)); selectCmd.Connection.Open(); var reader = selectCmd.ExecuteReader(); if (reader.Read()) { i_PartReport.Id = reader.GetInt32(0); } selectCmd.Connection.Close(); }
public void InsertGetUpdate() { DbPartReport target = new DbPartReport(); PartReport report = new PartReport() { Task = new Task() { Id = 0 }, Operator = "tester", OperatorComment = "TestComment", MeasurementDatetime = new DateTime(2014, 10, 10), Auditor = "Auditor", AuditComment = "Audit comment", AuditDatetime = new DateTime(2014, 10, 10), Approver = "Approver", ApproveComment = "Approve comment", ApproveDatetime = new DateTime(2014, 10, 10) }; target.InsertPartReport(report); var insertedTask = target.GetPartReports(report.Task); Assert.AreEqual(report.Id, insertedTask.Id); report.Task.Id = 2; target.UpdatePartReport(report); Assert.AreEqual(report.Task.Id, 2); }
public BrowseReportViewModel(PartReport i_PartReport) { _PartReport = i_PartReport; }
private void OnPartReportSpecified(object i_Obj) { BeginInvoke(new Mediator.MessageHanlderDelegate(i_O => { var partReport = i_O as PartReport; if (partReport == null) { return; } _Task = partReport.Task; _PartReport = partReport; _CurrentTemplate = partReport.Task.Part; if (_CurrentTemplate == null) { return; } _DataSource = new List <ExecuteDimensionEntityViewModel>(); PmsService.Instance.PopulateDimensionsForReport(_PartReport); foreach (var en in _PartReport.Dimensions) { _DataSource.Add(new ExecuteDimensionEntityViewModel(en)); } if (_CurrentTemplate.Dimensions.Count > 0) { _SeletedDimension = _PartReport.Dimensions[0]; } dataGridView1.DataSource = _DataSource; btnCreateReport.Text = @"保存报告"; BindingTextControls(); // RefreshCommentControls(); if (PmsService.Instance.CurrentUser.Group.Name == "检测") { BindMeasurementControl(); LblTester.Text = PmsService.Instance.CurrentUser.Name; LblTestDate.Text = DateTime.Now.ToLongDateString(); _ExecuteReportControlState = new ExecuteState(); _ExecuteReportControlState.Enter(this); } if (PmsService.Instance.CurrentUser.Group.Name == "评审") { BindMeasurementControl(); BindAuditControl(); LblAuditor.Text = PmsService.Instance.CurrentUser.Name; LblAuditDate.Text = DateTime.Now.ToLongDateString(); _ExecuteReportControlState = new AuditState(); _ExecuteReportControlState.Enter(this); } if (PmsService.Instance.CurrentUser.Group.Name == "审批") { BindMeasurementControl(); BindAuditControl(); BindApproveControl(); LblApprover.Text = PmsService.Instance.CurrentUser.Name; LblApproveDate.Text = DateTime.Now.ToLongDateString(); _ExecuteReportControlState = new ApproveState(); _ExecuteReportControlState.Enter(this); } }), i_Obj); }
public void Start(PartReport i_PartReport) { var executed = PmsService.Instance.GetPartReports(_Task); Mediator.Mediator.Instance.NotifyColleagues(App.ExecutionProgress, string.Format("{0}/{1}", _Task.SampleNumber, executed.Count)); }