private void readyDataArray() { int daysInMonth = DateTime.DaysInMonth(procDate.Year, procDate.Month); dayArray = new DateTime[daysInMonth]; dowArray = new int[daysInMonth]; hdayArray = new int[daysInMonth]; workHArray = new decimal[dataGridView1.RowCount, daysInMonth]; overHArray = new decimal[dataGridView1.RowCount, daysInMonth]; checkArray = new int[dataGridView1.RowCount, daysInMonth]; CalendarData cap = new CalendarData(); procDate.BeginOfMonth(); for (int i = 0; i < daysInMonth; i++) { dayArray[i] = procDate.AddDays(i); dowArray[i] = ( int )dayArray[i].DayOfWeek; hdayArray[i] = cap.ExitstenceHoliday(dayArray[i]) ? 1 : 0; } WorkReportData wrp = new WorkReportData(); CostData cdp = new CostData(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { string wkMCode = Convert.ToString(dataGridView1.Rows[i].Cells["MemberCode"].Value); cdp = new CostData(); cdp = cdp.SelectCostMaster(Convert.ToString(dataGridView1.Rows[i].Cells["MemberCode"].Value), Convert.ToString(comboBoxOffice.SelectedValue), "A"); decimal[] workHour; for (int j = 0; j < dayArray.Length; j++) { workHour = wrp.SelectSummaryWorkReport(Convert.ToString(dataGridView1.Rows[i].Cells["MemberCode"].Value), dayArray[j]); workHArray[i, j] = workHour[0]; overHArray[i, j] = workHour[1]; checkArray[i, j] = ( int )workHour[2]; if (cdp != null && cdp.Unit == "時間") { if (workHour[0] > 0) { workHArray[i, j] = workHour[0] / 8; } } } } curNo = 0; displayWorkingData(dataGridView1, curNo); }
public WorkReportPublished(WorkReportData report) { Report = report; }
private bool involvedDataDelete(DataGridViewRow dgvRow, int slipNo) { WorkReportData wrp; OsWkDetailData owd; OsPayOffData ofd; OsPaymentData omd; switch (Convert.ToString(dgvRow.Cells["Subject"].Value)) { case "A": case "B": case "K": wrp = new WorkReportData(); if (wrp.ExistenceSlipNo(slipNo)) { if (!wrp.ClearPartWorkReport(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value))) { deleteErrorMessage("作業内訳データ"); return(false); } } else { owd = new OsWkDetailData(); if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value))) { if (!owd.DeleteOsWkDetail("@slip", slipNo)) { deleteErrorMessage("外注作業内訳データ"); return(false); } } } break; case "F": ofd = new OsPayOffData(); if (ofd.ExistenceSlipNo(slipNo)) { if (!ofd.DeletePayOff("@slip", slipNo)) { deleteErrorMessage("外注精算データ"); return(false); } } else { omd = new OsPaymentData(); if (omd.ExistenceSlipNo(slipNo)) { if (!omd.DeletePayment("@slip", slipNo)) { deleteErrorMessage("外注出来高データ"); return(false); } } } break; default: owd = new OsWkDetailData(); if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value))) { if (!owd.DeleteOsWkDetail("@slip", slipNo)) { deleteErrorMessage("外注作業内訳データ"); return(false); } } break; } return(true); }
private bool involvedDataUpdate(DataGridViewRow dgvRow, int slipNo) { WorkReportData wrp; OsWkDetailData owd; OsPayOffData ofd; OsPaymentData omd; decimal unitPrice = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["UnitPrice"].Value)); decimal cost = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["Cost"].Value)); decimal qty = DHandling.ToRegDecimal(Convert.ToString(dgvRow.Cells["Quantity"].Value)); switch (Convert.ToString(dgvRow.Cells["Subject"].Value)) { case "A": case "B": case "K": wrp = new WorkReportData(); if (wrp.ExistenceSlipNo(slipNo)) { if (!wrp.UpdatePartWorkReport(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty)) { updateErrorMessage("作業内訳データ"); return(false); } } else { owd = new OsWkDetailData(); if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value))) { if (!owd.UpdatePartOsWkDetail(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty, cost)) { updateErrorMessage("外注作業内訳データ"); return(false); } } } break; case "F": ofd = new OsPayOffData(); if (ofd.ExistenceSlipNo(slipNo)) { ofd = ofd.SelectOsPayOff(slipNo); ofd.Cost = cost; if (!ofd.UpdatePayOff()) { updateErrorMessage("外注精算データ"); return(false); } //if (!ofd.UpdatePartPayOff(slipNo, cost)) //{ // updateErrorMessage("外注精算データ"); // return false; //} } else { omd = new OsPaymentData(); if (omd.ExistenceSlipNo(slipNo)) { omd = omd.SelectPayment(slipNo); omd.Amount = cost; if (!omd.UpdatePayment()) { updateErrorMessage("外注出来高データ"); return(false); } //if (!omd.UpdatePartPayment(slipNo, cost)) //{ // updateErrorMessage("外注出来高データ"); // return false; //} } } break; default: owd = new OsWkDetailData(); if (owd.ExistenceSlipNo(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value))) { if (!owd.UpdatePartOsWkDetail(slipNo, Convert.ToInt32(dgvRow.Cells["CostReportID"].Value), qty, cost)) { deleteErrorMessage("外注作業内訳データ"); return(false); } } break; } return(true); }
/// <summary> /// Creates the PDF. /// </summary> /// <param name="workReportData">The work report data.</param> public static void CreateWorkReportPdf(WorkReportData workReportData) { try { Document document = new Document(PageSize.A4, 10, 10, 42, 35); FileStream fileStream = new FileStream(Filename, FileMode.Create); PdfWriter pdfWriter = PdfWriter.GetInstance(document, fileStream); document.Open(); #region Header //// Header Paragraph paragraph = new Paragraph("Work report"); document.Add(paragraph); document.AddHeader("Header", "Work report"); #endregion #region Report information table PdfPTable rptTable = new PdfPTable(5); rptTable.SpacingBefore = 30f; rptTable.SpacingAfter = 15f; rptTable.TotalWidth = 500f; rptTable.LockedWidth = true; float[] rptWidths = { 2.1f, 1.5f, 2.1f, 1f, 1f }; rptTable.SetWidths(rptWidths); #region Row 1 PdfPCell cell = new PdfPCell(new Phrase("Creation Date:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.DateOfCreation.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase("Period:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.PeriodStart.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.PeriodStop.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); #endregion #region Row 2 cell = new PdfPCell(new Phrase("Serial Number:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.SerialNumber, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase("Project Number:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.ProjectNumber, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 2; rptTable.AddCell(cell); #endregion #region Row 3 cell = new PdfPCell(new Phrase("Machine Type:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.MachineType, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(string.Empty, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 3; rptTable.AddCell(cell); #endregion #region Row 4 cell = new PdfPCell(new Phrase("Engineer Name:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.EngineerName, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(string.Empty, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 3; rptTable.AddCell(cell); #endregion #region Row 5 cell = new PdfPCell(new Phrase("Coordinator:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.Coordinator, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase("Customer coordinator:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.CustomerCoordinator, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 2; rptTable.AddCell(cell); #endregion #region Row 6 cell = new PdfPCell(new Phrase("Module serial numbers:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.ModuleSerialNumbers, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 4; rptTable.AddCell(cell); #endregion #region Row 7 cell = new PdfPCell(new Phrase("Job description:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; rptTable.AddCell(cell); cell = new PdfPCell(new Phrase(workReportData.JobDescription, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; cell.Colspan = 4; rptTable.AddCell(cell); #endregion document.Add(rptTable); #endregion #region Work day table foreach (WorkDay day in workReportData.WorkDayCollection) { PdfPTable workDayTable = new PdfPTable(5); workDayTable.TotalWidth = 470f; workDayTable.LockedWidth = true; workDayTable.SpacingAfter = 10f; float[] workDayWidths = { 1f, 1f, 2f, 1f, 1f }; workDayTable.SetWidths(workDayWidths); #region Row 1 cell = new PdfPCell(new Phrase("Date:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.DateOfCreation.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase("Travel Time:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.TravelTimeStartAway.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.TravelTimeStopAway.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(string.Empty)); cell.Colspan = 2; cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase("Working Time:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.WorkingTimeStart.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.WorkingTimeStop.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(string.Empty)); cell.Colspan = 2; cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase("Travel Time:", new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.TravelTimeStartReturn.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.TravelTimeStopReturn.ToShortDateString(), new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.FixedHeight = 20f; workDayTable.AddCell(cell); cell = new PdfPCell(new Phrase(day.Content, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL))); cell.Colspan = 5; workDayTable.AddCell(cell); document.Add(workDayTable); #endregion } #endregion document.Close(); } catch (Exception exception) { Console.WriteLine(exception); } }