private void ExeTableDetail(Word.Table pTable, FASTrack.Model.DTO.FARDeviceDetailsDto device) { for (int iRow = 1; iRow <= pTable.Rows.Count; iRow++) { Word.Cell wCell = pTable.Cell(iRow, 1); string sValue = wCell.Range.Text; if (sValue.Contains(KeyWord.FA_DETAILS_DESCRIPTION)) { wCell.Range.Text = device.Master.FailureDesc; continue; } if (sValue.Contains(KeyWord.PROCESSES) && exportType == ExportType.TEMP1) { if (ProcessTypes == null) continue; int iCount = ProcessTypes.Count; int iNumRowOfProcess = (int)Math.Ceiling(iCount / 2d); Word.Table wParent = wCell.Range.Tables.Add(wCell.Range, 1, 2); Word.Cell wCell1 = wParent.Cell(1, 1); Word.Cell wCell2 = wParent.Cell(1, 2); ReportProcessTypeCell(wCell1, (iCount % 2 == 1) ? iNumRowOfProcess - 1 : iNumRowOfProcess, 1, device.ProcessHis); ReportProcessTypeCell(wCell2, iNumRowOfProcess, 2, device.ProcessHis); ////Word.Table wTableProcess = wCell.Range.Tables.Add(wCell.Range, iNumRowOfProcess, 2); //Word.Table wTableProcess = wCell.Range.Tables.Add(wCell.Range, iCount, 1); //wTableProcess.BottomPadding = 1; //wTableProcess.TopPadding = 1; //wTableProcess.LeftPadding = 5; //wTableProcess.RightPadding = 5; //wTableProcess.Spacing = 10; ////for (int i = 1; i <= iNumRowOfProcess; i++) //for (int i = 1; i <= iCount; i++) //{ // //for (int j = 1; j <= 2; j++) // //{ // //Word.Range range = wTableProcess.Cell(i, j).Range; // Word.Range range = wTableProcess.Cell(i, 1).Range; // range.Font.Name = "Verdana"; // range.Font.Size = 10; // //Word.FormField checkBox = range.FormFields.Add(wTableProcess.Cell(i, j).Range, Word.WdFieldType.wdFieldFormCheckBox); // Word.FormField checkBox = range.FormFields.Add(wTableProcess.Cell(i, 1).Range, Word.WdFieldType.wdFieldFormCheckBox); // //checkBox.CheckBox.Default = false; // //checkBox.CheckBox.Size = 15; // //checkBox.CalculateOnExit = true; // //checkBox.Enabled = true; // //checkBox.OwnHelp = false; // //checkBox.OwnStatus = false; // //var pro = ProcessTypes[(i * 2) - j]; // var pro = ProcessTypes[i - 1]; // if (device.ProcessHis.FirstOrDefault(x => x.ProcessTypeId == pro.Id) != null) // { // //checkBox.CheckBox.Default = true; // checkBox.CheckBox.Value = true; // } // else // { // //checkBox.CheckBox.Default = false; // checkBox.CheckBox.Value = false; // } // checkBox.Enabled = false; // range.InsertAfter(pro.Name); // //} //} continue; } if (sValue.Contains(KeyWord.PROCESSES_COMMENT) && exportType == ExportType.TEMP1) { int wCount = device.ProcessHis.Count; object missing = Type.Missing; wCell.Range.Text = String.Empty; Word.Paragraph pText = null; for (int i = 0; i < device.ProcessHis.Count; i++) { var item = device.ProcessHis[i]; if (i == 0) { wCell.Range.Bold = 1; wCell.Range.Text = item.ProcessType.Name; } else { pText = wCell.Range.Paragraphs.Add(missing); pText.Range.Bold = 1; pText.Range.Text = item.ProcessType.Name; } pText = wCell.Range.Paragraphs.Add(missing); pText.Range.Bold = 0; pText.Range.Text = item.Comment; wCell.Range.InsertParagraphAfter(); } } } }
private void ExeTableInfo(Word.Table pTable, FASTrack.ViewModel.FARReportGeneratorViewModel master) { for (int iRow = 1; iRow <= pTable.Rows.Count; iRow++) { for (int iCol = 1; iCol <= 2; iCol++) { Word.Cell wCell = pTable.Cell(iRow, iCol); string sValue = wCell.Range.Text; //[Analyst/User who will generate the Report] if (sValue.Contains(KeyWord.USER_GEN_RE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.USER_GEN_RE, User1.FullName);//Get full name of user login current continue; } //Phone number of Analyst if (sValue.Contains(KeyWord.PHONE_1)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.PHONE_1, User1.Phone); continue; } //[FA Overall Incharge] if (sValue.Contains(KeyWord.FA_OVERALL_INCHARGE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.FA_OVERALL_INCHARGE, User2.FullName); continue; } //Phone number of Reviewed by if (sValue.Contains(KeyWord.PHONE_2)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.PHONE_2, User2.Phone); continue; } } } }
private void ExeFullGenerate(Word.Table pTable, FASTrack.Model.DTO.FARDeviceDetailsDto device) { int iMaxRow = 6; int iMaxXol = 3; for (int iRow = 1; iRow <= iMaxRow; iRow++) { for (int iCol = 1; iCol <= iMaxXol; iCol++) { Word.Cell wCell = pTable.Cell(iRow, iCol); string sValue = wCell.Range.Text; if (sValue.Contains(KeyWord.FAR_REF)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.FAR_REF, device.Master.Number); continue; } if (sValue.Contains(KeyWord.CUSTOMER)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.CUSTOMER, device.Master.Customer); continue; } if (sValue.Contains(KeyWord.FAILURE_RATE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.FAILURE_RATE, device.Master.FailureRate + ""); continue; } if (sValue.Contains(KeyWord.REQUEST_DATE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.REQUEST_DATE, device.Master.RequestDate.ToString("dd MMM yyyy")); continue; } if (sValue.Contains(KeyWord.REQUESTOR)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.REQUESTOR, Requestor.FullName);//TODO:get full name continue; } if (sValue.Contains(KeyWord.PRODUCT_LINE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.PRODUCT_LINE, device.Master.Product); continue; } if (sValue.Contains(KeyWord.REQUESTOR_EMAIL)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.REQUESTOR_EMAIL, Requestor.Email); continue; } if (exportType == ExportType.TEMP1) { if (sValue.Contains(KeyWord.DATE_CODE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.DATE_CODE, device.DateCode); continue; } if (sValue.Contains(KeyWord.PART_NUMBER)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.PART_NUMBER, device.MfgPartNo); continue; } if (sValue.Contains(KeyWord.PACK_TYPE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.PACK_TYPE, device.PackageType.Name); continue; } if (sValue.Contains(KeyWord.ASSEMBLY_SITE)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.ASSEMBLY_SITE, device.AssemblySites.Name); continue; } if (sValue.Contains(KeyWord.LOT_NUMBER)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.LOT_NUMBER, device.LotNo); continue; } if (sValue.Contains(KeyWord.SAMPLES_QTY)) { wCell.Range.Text = wCell.Range.Text.Replace(KeyWord.SAMPLES_QTY, device.Quantity + ""); continue; } } } } }