private void writeDate(System.Drawing.Printing.PrintPageEventArgs e) { Font dateFont = new Font("Times New Roman", 14); Font controlFont = new Font("Times New Roman", 14, FontStyle.Bold); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.FormatFlags = StringFormatFlags.FitBlackBox; RectangleF dateInArea = new RectangleF(dateArea.Location.X, dateArea.Location.Y, dateArea.Width / 2, dateArea.Height); RectangleF dateOutArea = new RectangleF(dateArea.Location.X + dateInArea.Width, dateArea.Location.Y, dateArea.Width / 2, dateArea.Height); e.Graphics.DrawLine(new Pen(Brushes.Black, 2), dateArea.X + dateInArea.Width, dateArea.Y, dateArea.X + dateInArea.Width, dateArea.Y + dateArea.Height); e.Graphics.DrawString("Date in:", controlFont, Brushes.Black, dateInArea); SizeF stringSize = e.Graphics.MeasureString("Date in:", controlFont); dateInArea.X += stringSize.Width; dateInArea.Width -= stringSize.Width; e.Graphics.DrawString(currentRo.dateIn.ToLongDateString(), dateFont, Brushes.Black, dateInArea, format); if (currentRo.isCLosed()) { stringSize = e.Graphics.MeasureString("Date out:", controlFont); e.Graphics.DrawString("Date out:", controlFont, Brushes.Black, dateOutArea); dateOutArea.X += stringSize.Width; dateOutArea.Width -= stringSize.Width; e.Graphics.DrawString(currentRo.dateOut.ToLongDateString(), dateFont, Brushes.Black, dateOutArea, format); } }
private void addRoToDgv(RO ro) { object[] data = new object[7]; data[0] = ro.getId(); data[1] = ro.customer.name; data[2] = ro.bike.getMakeModel(); data[3] = ro.dateIn.ToShortDateString(); if (!ro.isCLosed()) { data[4] = "n/a"; } else { data[4] = ro.dateOut.ToShortDateString(); } data[5] = ro.getSubTotal(); data[6] = ro.getTotal(); dgvRo.Rows.Add(data); }