public PDFCreateExtention(OrderPDFCreatingDTO _orderPDF) { var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); outPutDirectory = outPutDirectory.Replace(@"\QUANLYLINHKIEN_PTUD\bin\Debug", @"\Model\Font"); string directoryPath = new Uri(outPutDirectory).LocalPath; fontRobotoBold = BaseFont.CreateFont(directoryPath + @"\Roboto-Bold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); fontRobotoMedium = BaseFont.CreateFont(directoryPath + @"\Roboto-Medium.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); fontRobotoRegular = BaseFont.CreateFont(directoryPath + @"\Roboto-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); fontRobotoThin = BaseFont.CreateFont(directoryPath + @"\Roboto-Thin.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); orderPDF = _orderPDF; CreateBillPDF(); }
public void PrintOrder(OrderPDFCreatingDTO orderPDF) { dal.PrintOrder(orderPDF); }
public void PrintOrder(OrderPDFCreatingDTO orderPDF) { pdfExtention = new PDFCreateExtention(orderPDF); pdfExtention.CreateBillPDF(); }
private void btn_CreateOrder_Click(object sender, EventArgs e) { DialogResult dialogResult = DialogResult.Yes; if (string.IsNullOrEmpty(txt_CustomerName.Text)) { dialogResult = MessageBox.Show("Khách hàng không muốn cộng điểm???", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (dgv_Cart.Rows.Count <= 1 && dialogResult.Equals(DialogResult.Yes)) { MessageBox.Show("Vui lòng chọn sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var order = new Order() { StaffId = staffId, CustomerId = string.IsNullOrEmpty(txt_CustomerName.Text) ? 1 : customerBLL.GetCustomerIdByNumberPhone(txt_PhoneCustomer.Text), CreationTime = DateTime.Now, TotalPrice = Convert.ToDouble(lb_TongTien.Text.ToString().Replace("VNĐ", "")) }; var newOrderId = Convert.ToInt32(orderBLL.CreateOrder(order).ToString()); var customer = customerBLL.GetCustomerFromNumberPhone(txt_PhoneCustomer.Text); List <AccessoryPDFCreatingDTO> listAccessory = new List <AccessoryPDFCreatingDTO>(); for (int i = 0; i < (dgv_Cart.Rows.Count - 1); i++) { OrderDetail orderDetail = new OrderDetail(); orderDetail.OrderId = newOrderId; orderDetail.AccessoryCalculationUnit = dgv_Cart.Rows[i].Cells["CalculationUnit"].Value.ToString(); orderDetail.AccessoryName = dgv_Cart.Rows[i].Cells["NameAccessory"].Value.ToString(); orderDetail.AccessoryId = dgv_Cart.Rows[i].Cells["Id"].Value.ToString(); orderDetail.Quantity = Convert.ToInt32(dgv_Cart.Rows[i].Cells["Quantity"].Value.ToString()); orderDetail.AccessoryPrice = Convert.ToDouble(dgv_Cart.Rows[i].Cells["Price"].Value.ToString()); listAccessory.Add(new AccessoryPDFCreatingDTO { CalculationUnit = orderDetail.AccessoryCalculationUnit, Name = orderDetail.AccessoryName, Price = orderDetail.AccessoryPrice, Quantity = orderDetail.Quantity, Total = orderDetail.Quantity * orderDetail.AccessoryPrice }); accesoryBLL.UpdateInventoryAccessory(orderDetail.AccessoryId, orderDetail.Quantity); orderDetailBLL.CreateOrderDetail(orderDetail); } var orderPDF = new OrderPDFCreatingDTO(); orderPDF.Id = newOrderId; orderPDF.StaffName = staffBLL.GetStaffNameById(staffId); orderPDF.Total = order.TotalPrice.ToString(); if (customer != null) { orderPDF.CustomerName = customer.Name; orderPDF.CustomerAddress = customer.Address; orderPDF.CustomerPhone = customer.NumberPhone; } else { orderPDF.CustomerName = ""; orderPDF.CustomerAddress = ""; orderPDF.CustomerPhone = ""; } orderPDF.ListAccessory = listAccessory; orderBLL.PrintOrder(orderPDF); } }