private static void printDocumentReceipt_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { // load data hoa don ReceiptsAll rcAll = GetAllInfo(ReId); int y_p = 0; // Logo string path = HttpContext.Current.Server.MapPath("/"); var imgLogo = System.Drawing.Image.FromFile(path + "Image//ShopImg//logoPrint.png"); Rectangle logo = new Rectangle(5, 10, 60, 40); e.Graphics.DrawImage(imgLogo, logo); /// Rectangle strHoaDon = new Rectangle(130, 5, 165, 20); string data = Common.clsLanguages.GetResource("Receipt", Language);//"HÓA ĐƠN"; StringFormat strfmt_Left = new StringFormat(); StringFormat strfmt_Center = new StringFormat(); StringFormat strfmt_Right = new StringFormat(); strfmt_Left.LineAlignment = StringAlignment.Near; strfmt_Left.Alignment = StringAlignment.Near; strfmt_Center.LineAlignment = StringAlignment.Center; strfmt_Center.Alignment = StringAlignment.Center; strfmt_Right.LineAlignment = StringAlignment.Far; strfmt_Right.Alignment = StringAlignment.Far; e.Graphics.DrawString(data, new Font("Arial", 12, FontStyle.Bold), Brushes.DarkSlateBlue, strHoaDon, strfmt_Right); //Ngày hóa đơn Rectangle strRec = new Rectangle(120, 25, 175, 15); data = Common.clsLanguages.GetResource("ReceiptDate", Language) + " : " + rcAll.receipt.CreatedDate; //"Ngày :" e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.DarkSlateBlue, strRec, strfmt_Right); Rectangle RecLine1 = new Rectangle(115, 40, 180, 2); var Line1 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line1, RecLine1); Rectangle strRec1 = new Rectangle(120, 42, 175, 18); string strSoHD = rcAll.receipt.ReceiptId; int soHD = int.Parse(strSoHD.Substring(10)); data = Common.clsLanguages.GetResource("ReceiptNumber", Language) + " : 10#" + soHD.ToString(); //"Số HĐ: " e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Italic), Brushes.DarkSlateBlue, strRec1, strfmt_Right); //// Cty.... Rectangle strCty = new Rectangle(5, 50, 140, 20); data = Common.clsLanguages.GetResource("MerchantName", Language);// "Công ty CP Việt Vang"; e.Graphics.DrawString(data, new Font("Arial", 9, FontStyle.Bold), Brushes.DarkSlateBlue, strCty, strfmt_Left); //Địa chỉ Cty Rectangle strDCCty = new Rectangle(5, 70, 160, 50); data = Common.clsLanguages.GetResource("MerchantAddress", Language) + "\n" + Common.clsLanguages.GetResource("MerchantTel", Language) + "\n" + Common.clsLanguages.GetResource("MerchantWeb", Language); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.DarkSlateBlue, strDCCty, strfmt_Left); //Headers Rectangle strHD_STT = new Rectangle(3, 120, 30, 18); data = Common.clsLanguages.GetResource("No", Language);// "STT"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, strHD_STT, strfmt_Center); Rectangle strHD_SP = new Rectangle(33, 120, 97, 18); data = Common.clsLanguages.GetResource("Product", Language);//"Sản phẩm "; e.Graphics.DrawString(data, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, strHD_SP, strfmt_Left); Rectangle strHD_SL = new Rectangle(130, 120, 30, 18); data = Common.clsLanguages.GetResource("ReceiptProQty", Language);//"SL"; e.Graphics.DrawString(data, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, strHD_SL, strfmt_Center); Rectangle strHD_DG = new Rectangle(160, 120, 60, 18); data = Common.clsLanguages.GetResource("ReceiptProPrice", Language);//"ĐG"; e.Graphics.DrawString(data, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, strHD_DG, strfmt_Center); Rectangle strHD_TT = new Rectangle(220, 120, 70, 18); data = Common.clsLanguages.GetResource("ReceiptProTotalAfterTax", Language);//"TT + Thuế"; e.Graphics.DrawString(data, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, strHD_TT, strfmt_Center); Rectangle RecLine2 = new Rectangle(5, 138, 290, 2); var Line2 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line2.png"); e.Graphics.DrawImage(Line2, RecLine2); if (rcAll.lst_Detail != null && rcAll.lst_Detail.Count > 0) { y_p = 140; int i = 0; foreach (ReceiptDetails dtl in rcAll.lst_Detail) { i++; //Headers Rectangle strCT_STT = new Rectangle(5, y_p, 28, 22); data = i.ToString(); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strCT_STT, strfmt_Center); Rectangle strCT_SP = new Rectangle(33, y_p, 97, 22); data = Common.clsLanguages.GetResource("ProductID", Language) + dtl.ProductId + " - " + dtl.ProductName; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strCT_SP, strfmt_Left); Rectangle strCT_SL = new Rectangle(130, y_p, 30, 22); data = dtl.Qty; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strCT_SL, strfmt_Center); Rectangle strTT_DG = new Rectangle(160, y_p, 60, 22); data = double.Parse(dtl.Price.ToString()).ToString("0,0"); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strTT_DG, strfmt_Right); Rectangle strTT_TT = new Rectangle(220, y_p, 70, 22); data = double.Parse(dtl.TotalAmount.ToString()).ToString("0,0"); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strTT_TT, strfmt_Right); Rectangle RecLineCT = new Rectangle(5, y_p + 22, 290, 1); var LineCT = System.Drawing.Image.FromFile(path + "Image//ShopImg//linect.png"); e.Graphics.DrawImage(LineCT, RecLineCT); y_p = y_p + 23; } } ///Tổng tiền trước thuế Rectangle RecTTTT = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalAmountBeforeTax", Language);//"Tổng tiền trước thuế "; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecTTTT, strfmt_Right); Rectangle RecTTTT_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.TotalAmountBeforeTax; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecTTTT_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền thuế Rectangle RecTTT = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalTaxAmount", Language);// "Tổng tiền thuế "; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecTTT, strfmt_Right); Rectangle RecTTT_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.TotalTax; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecTTT_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền sau thuế Rectangle RecTTST = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalAmountAfterTax", Language);//"Tổng tiền sau thuế "; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecTTST, strfmt_Right); Rectangle RecTTST_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.TotalAmount; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecTTST_Val, strfmt_Right); y_p = y_p + 15; ///Giảm giá Rectangle RecDIS = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalDiscountAmount", Language);//"Giảm giá "; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecDIS, strfmt_Right); Rectangle RecDIS_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.DiscountAmount; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecDIS_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền thanh toán Rectangle RecPAY = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalMoney", Language);//"TC Cần thanh toán"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecPAY, strfmt_Right); Rectangle RecPAY_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.TotalMoney; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecPAY_Val, strfmt_Right); y_p = y_p + 15; //// Rectangle RecLine3 = new Rectangle(90, y_p, 200, 1); var Line3 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line3, RecLine3); y_p = y_p + 2; ///Tổng tiền mặt Rectangle RecCASH = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalCashCustomer", Language);//"Tiền mặt khách đưa"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecCASH, strfmt_Right); Rectangle RecCASH_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.CashPayAmt; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecCASH_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền thẻ Rectangle RecCARD = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalCardAmount", Language);//"Tiền thẻ khách:"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecCARD, strfmt_Right); Rectangle RecCARD_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.CardPayAmt; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecCARD_Val, strfmt_Right); y_p = y_p + 15; //// Rectangle RecLine4 = new Rectangle(90, y_p, 200, 1); var Line4 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line4, RecLine4); y_p = y_p + 2; ///Tổng tiền thối lại Rectangle RecRETU = new Rectangle(90, y_p, 120, 15); data = Common.clsLanguages.GetResource("TotalReturnAmount", Language);//"Tiền thối:"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecRETU, strfmt_Right); Rectangle RecRETU_Val = new Rectangle(210, y_p, 85, 15); data = rcAll.receipt.ReturnAmt; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecRETU_Val, strfmt_Right); y_p = y_p + 15; if (rcAll.receiptMember != null && !string.IsNullOrEmpty(rcAll.receiptMember.MemberId)) { //// Rectangle RecLine5 = new Rectangle(5, y_p, 290, 2); var Line5 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line5, RecLine5); y_p = y_p + 4; Rectangle RecTTKH = new Rectangle(10, y_p, 160, 18); data = Common.clsLanguages.GetResource("CustomerInformation", Language);//"Thông tin khách hàng"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecTTKH, strfmt_Left); y_p = y_p + 18; Rectangle RecTTKH1 = new Rectangle(10, y_p, 190, 15); data = Common.clsLanguages.GetResource("FullName", Language) + " : " + rcAll.receiptMember.FullName; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH1, strfmt_Left); Rectangle RecTTKH1A = new Rectangle(205, y_p, 90, 15); data = Common.clsLanguages.GetResource("TotalScore", Language) + " : " + rcAll.receiptMember.MemberScore; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH1A, strfmt_Left); y_p = y_p + 15; Rectangle RecTTKH2 = new Rectangle(10, y_p, 190, 15); data = Common.clsLanguages.GetResource("MemberID", Language) + " : " + rcAll.receiptMember.MemberId; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH2, strfmt_Left); y_p = y_p + 15; } //// Rectangle RecLine6 = new Rectangle(5, y_p, 290, 2); var Line6 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line6, RecLine6); y_p = y_p + 4; Rectangle RecTK = new Rectangle(5, y_p, 190, 18); data = Common.clsLanguages.GetResource("ReceiptFooterText", Language); //"Cám ơn & hẹn gặp lại quý khách !"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Italic), Brushes.Black, RecTK, strfmt_Left); Rectangle RecPower = new Rectangle(200, y_p, 95, 47); var LineP = System.Drawing.Image.FromFile(path + "Image//VVImg//powered by vv.png"); e.Graphics.DrawImage(LineP, RecPower); y_p = y_p + 47; // show các PromoText DataTable dtPromo = GetValidPromotionToPrint(); if (dtPromo != null && dtPromo.Rows.Count > 0) { //// Rectangle RecLine7 = new Rectangle(5, y_p, 290, 1); var Line7 = System.Drawing.Image.FromFile(path + "Image//ShopImg//line1.png"); e.Graphics.DrawImage(Line7, RecLine7); y_p = y_p + 4; ////// foreach (DataRow dr in dtPromo.Rows) { Rectangle RecPromo = new Rectangle(5, y_p, 290, 130); data = "\n---------------\n" + dr["PromoText"].ToString() + "\n---------------\n"; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Italic), Brushes.Black, RecPromo, strfmt_Center); y_p = y_p + 130; } } }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { // load data hoa don ReceiptsAll rcAll = RptsBLL.GetAllInfo(ReceiptID_Success); int y_p = 0; int h_s = 0; /// StringFormat strfmt_Left = new StringFormat(); StringFormat strfmt_Center = new StringFormat(); StringFormat strfmt_Right = new StringFormat(); StringFormat strfmt_Left_Right = new StringFormat(); StringFormat strfmt_Center_Right = new StringFormat(); StringFormat strfmt_Right_Center = new StringFormat(); StringFormat strfmt_Left_Center = new StringFormat(); strfmt_Left.LineAlignment = StringAlignment.Near; strfmt_Left.Alignment = StringAlignment.Near; strfmt_Center.LineAlignment = StringAlignment.Center; strfmt_Center.Alignment = StringAlignment.Center; strfmt_Right.LineAlignment = StringAlignment.Far; strfmt_Right.Alignment = StringAlignment.Far; strfmt_Left_Right.LineAlignment = StringAlignment.Far; strfmt_Left_Right.Alignment = StringAlignment.Near; strfmt_Center_Right.LineAlignment = StringAlignment.Far; strfmt_Center_Right.Alignment = StringAlignment.Center; strfmt_Right_Center.LineAlignment = StringAlignment.Center; strfmt_Right_Center.Alignment = StringAlignment.Far; strfmt_Left_Center.LineAlignment = StringAlignment.Center; strfmt_Left_Center.Alignment = StringAlignment.Near; // Logo var imgLogo = Common.Utility.GetImageFromService("ShopImg", "logoPrint.png"); Rectangle logo = new Rectangle(0, 10, 70, 40); e.Graphics.DrawImage(imgLogo, logo); Rectangle strHoaDon = new Rectangle(70, 5, 120, 20); string data = Common.clsLanguages.GetResource("Receipt"); //"HÓA ĐƠN"; e.Graphics.DrawString(data, new Font("Arial", 10, FontStyle.Bold), Brushes.DarkSlateBlue, strHoaDon, strfmt_Right); //Ngày hóa đơn Rectangle strRec = new Rectangle(70, 25, 120, 15); data = Common.clsLanguages.GetResource("ReceiptDate") + rcAll.receipt.CreatedDate; //"Ngày :" e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.DarkSlateBlue, strRec, strfmt_Right); Rectangle RecLine1 = new Rectangle(70, 40, 120, 2); var Line1 = Common.Utility.GetImageFromService("ShopImg", "line1.png"); e.Graphics.DrawImage(Line1, RecLine1); Rectangle strRec1 = new Rectangle(100, 42, 90, 18); string strSoHD = rcAll.receipt.ReceiptId; int soHD = int.Parse(strSoHD.Substring(10)); data = Common.clsLanguages.GetResource("ReceiptNumber") + " : 11#" + soHD.ToString(); //"Số HĐ: " e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Italic), Brushes.DarkSlateBlue, strRec1, strfmt_Right); //// Cty.... Rectangle strCty = new Rectangle(0, 50, 100, 40); //20 data = Common.clsLanguages.GetResource("MerchantName"); // "HD Tech"; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.DarkSlateBlue, strCty, strfmt_Left); //Địa chỉ Cty Rectangle strDCCty = new Rectangle(0, 90, 190, 50); //50 data = Common.clsLanguages.GetResource("MerchantAddress") + "\n" + Common.clsLanguages.GetResource("MerchantTel") + "\n" + Common.clsLanguages.GetResource("MerchantWeb"); e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.DarkSlateBlue, strDCCty, strfmt_Left); //Headers Rectangle strHD_STT = new Rectangle(0, 140, 15, 18); data = Common.clsLanguages.GetResource("No"); // "STT"; e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.Black, strHD_STT, strfmt_Center); Rectangle strHD_SP = new Rectangle(16, 140, 79, 18); data = Common.clsLanguages.GetResource("Product"); //"Sản phẩm "; e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.Black, strHD_SP, strfmt_Left_Center); Rectangle strHD_SL = new Rectangle(95, 140, 15, 18); data = Common.clsLanguages.GetResource("ReceiptProQty"); //"SL"; e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.Black, strHD_SL, strfmt_Center); Rectangle strHD_DG = new Rectangle(110, 140, 40, 18); data = Common.clsLanguages.GetResource("ReceiptProPrice"); //"ĐG"; e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.Black, strHD_DG, strfmt_Right_Center); Rectangle strHD_TT = new Rectangle(150, 140, 40, 18); data = Common.clsLanguages.GetResource("ReceiptProTotal"); //ReceiptProTotalAfterTax "TT + Thuế"; e.Graphics.DrawString(data, new Font("Arial", 6, FontStyle.Regular), Brushes.Black, strHD_TT, strfmt_Right_Center); Rectangle RecLine2 = new Rectangle(0, 158, 190, 2); var Line2 = Common.Utility.GetImageFromService("ShopImg", "line2.png"); e.Graphics.DrawImage(Line2, RecLine2); if (rcAll.lst_Detail != null && rcAll.lst_Detail.Count > 0) { y_p = 160; int i = 0; foreach (ReceiptDetails dtl in rcAll.lst_Detail) { i++; //Headers h_s = 22; //Common.clsLanguages.GetResource("ProductID") + " " + dtl.ProductId + " - " + double _dbLength = (dtl.ProductName).Length; if (_dbLength > 85 / 5) { int _iCelling = (int)Math.Ceiling((_dbLength * 5) / 85); h_s = 14 * _iCelling + 12; } //if (dtl.IsBuffet == "0" || (dtl.IsBuffet == "1" && double.Parse(dtl.Price) > 0)) //{ Rectangle strCT_STT = new Rectangle(0, y_p, 30, h_s); data = i.ToString(); e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, strCT_STT, strfmt_Center); Rectangle strCT_SP = new Rectangle(30, y_p, 160, h_s); data = dtl.ProductName; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, strCT_SP, strfmt_Left_Center); //y_p += h_s; //Rectangle strCT_SL = new Rectangle(30, y_p, 80, h_s); //data = dtl.Qty; //e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, strCT_SL, strfmt_Center); y_p += h_s; Rectangle strTT_DG = new Rectangle(30, y_p, 80, h_s); //data = (double.Parse(dtl.Price) + (double.Parse(dtl.TaxAmount) / double.Parse(dtl.Qty))).ToString("0,0"); data = dtl.Qty + " x " + dtl.Price; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, strTT_DG, strfmt_Right_Center); Rectangle strTT_TT = new Rectangle(110, y_p, 80, h_s); data = dtl.TotalAmountBeforeTax; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, strTT_TT, strfmt_Right_Center); y_p += h_s; Rectangle RecLineCT = new Rectangle(0, y_p, 190, 1); var LineCT = Common.Utility.GetImageFromService("ShopImg", "linect.png"); e.Graphics.DrawImage(LineCT, RecLineCT); //} //else //{ // Rectangle strCT_SP = new Rectangle(43, y_p, 147, h_s);//60 // data = dtl.ProductName; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strCT_SP, strfmt_Left_Center); // Rectangle strCT_SL = new Rectangle(190, y_p, 30, h_s); // data = dtl.Qty; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, strCT_SL, strfmt_Right_Center); // y_p += h_s; // Rectangle RecLineCT = new Rectangle(43, y_p, 247, 1); // var LineCT = Common.Utility.GetImageFromService("ShopImg", "linect.png"); // e.Graphics.DrawImage(LineCT, RecLineCT); //} } } ///Tổng tiền trước thuế /sau thuế Rectangle RecTTST = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("TotalAmount"); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTST, strfmt_Right); Rectangle RecTTST_Val = new Rectangle(129, y_p, 61, 15); data = rcAll.receipt.TotalAmountBeforeTax; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.Black, RecTTST_Val, strfmt_Right); y_p = y_p + 15; ///phí dịch vụ Rectangle RecPDV = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("TaxAndServiceChange") + " (" + (int.Parse(ConfigurationManager.AppSettings["SeviceCostPercent"]) + int.Parse(ConfigurationManager.AppSettings["VAT"])) + " %)"; //Common.clsLanguages.GetResource("TotalServiceCharge");// e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecPDV, strfmt_Right); Rectangle RecPDV_Val = new Rectangle(129, y_p, 61, 15); data = (double.Parse(rcAll.receipt.ServiceCostAmount) + double.Parse(rcAll.receipt.TotalTax)).ToString("0,0"); e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.Black, RecPDV_Val, strfmt_Right); y_p = y_p + 15; ///Giảm giá Rectangle RecDIS = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("TotalDiscountAmount"); //"Giảm giá "; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecDIS, strfmt_Right); Rectangle RecDIS_Val = new Rectangle(129, y_p, 61, 15); data = rcAll.receipt.DiscountAmount; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.Black, RecDIS_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền thanh toán Rectangle RecPAY = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("TotalMoney"); //"TC Cần thanh toán"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecPAY, strfmt_Right); Rectangle RecPAY_Val = new Rectangle(129, y_p, 61, 15); data = rcAll.receipt.TotalMoney; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecPAY_Val, strfmt_Right); y_p = y_p + 15; //// Rectangle RecLine3 = new Rectangle(0, y_p, 190, 1); var Line3 = Common.Utility.GetImageFromService("ShopImg", "line1.png"); e.Graphics.DrawImage(Line3, RecLine3); y_p = y_p + 2; ///Tổng tiền mặt Rectangle RecCASH = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("CashPayment"); //Common.clsLanguages.GetResource("TotalCashCustomer");//"Tiền mặt khách đưa"; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecCASH, strfmt_Right); Rectangle RecCASH_Val = new Rectangle(129, y_p, 61, 15); data = rcAll.receipt.CashPayAmt; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.Black, RecCASH_Val, strfmt_Right); y_p = y_p + 15; ///Tổng tiền thẻ //Rectangle RecCARD = new Rectangle(80, y_p, 120, 15); //data = Common.clsLanguages.GetResource("CardPayment");//Common.clsLanguages.GetResource("TotalCardAmount");//"Tiền thẻ khách:"; //e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, RecCARD, strfmt_Right); //Rectangle RecCARD_Val = new Rectangle(200, y_p, 80, 15); //data = rcAll.receipt.CardPayAmt; //e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecCARD_Val, strfmt_Right); //y_p = y_p + 15; ///Số tiền thối lại Rectangle RecRefun = new Rectangle(0, y_p, 129, 15); data = Common.clsLanguages.GetResource("TotalReturnAmount"); //Common.clsLanguages.GetResource("TotalCardAmount");//"Tiền thẻ khách:"; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecRefun, strfmt_Right); Rectangle RecRefun_Val = new Rectangle(129, y_p, 61, 15); data = rcAll.receipt.ReturnAmt; e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Bold), Brushes.Black, RecRefun_Val, strfmt_Right); y_p = y_p + 15; //if (rcAll.receiptMember != null && !string.IsNullOrEmpty(rcAll.receiptMember.MemberId)) //{ // //// // Rectangle RecLine5 = new Rectangle(5, y_p, 290, 2); // var Line5 = Common.Utility.GetImageFromService("ShopImg", "line1.png"); // e.Graphics.DrawImage(Line5, RecLine5); // y_p = y_p + 4; // Rectangle RecTTKH = new Rectangle(10, y_p, 160, 18); // data = Common.clsLanguages.GetResource("CustomerInformation");//"Thông tin khách hàng"; // e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, RecTTKH, strfmt_Left); // y_p = y_p + 18; // Rectangle RecTTKH1 = new Rectangle(10, y_p, 190, 15); // data = Common.clsLanguages.GetResource("FullName") + " : " + rcAll.receiptMember.FullName; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH1, strfmt_Left); // Rectangle RecTTKH1A = new Rectangle(205, y_p, 90, 15); // data = Common.clsLanguages.GetResource("TotalScore") + " : " + rcAll.receiptMember.MemberScore; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH1A, strfmt_Left); // y_p = y_p + 15; // Rectangle RecTTKH2 = new Rectangle(10, y_p, 190, 15); // data = Common.clsLanguages.GetResource("MemberID") + " : " + rcAll.receiptMember.MemberId; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Regular), Brushes.Black, RecTTKH2, strfmt_Left); // y_p = y_p + 15; //} //// Rectangle RecLine6 = new Rectangle(0, y_p, 190, 2); var Line6 = Common.Utility.GetImageFromService("ShopImg", "line1.png"); e.Graphics.DrawImage(Line6, RecLine6); y_p = y_p + 4; Rectangle RecTK = new Rectangle(0, y_p, 190, 18); data = Common.clsLanguages.GetResource("ReceiptFooterText"); //"Cám ơn & hẹn gặp lại quý khách !"; e.Graphics.DrawString(data, new Font("Arial", 8, FontStyle.Italic), Brushes.Black, RecTK, strfmt_Left); //Rectangle RecPower = new Rectangle(200, y_p, 95, 47); //var LineP = Common.Utility.GetImageFromService("VVImg", "powered by vv.emf"); //e.Graphics.DrawImage(LineP, RecPower); //y_p = y_p + 47; // show các PromoText //DataTable dtPromo = RptsBLL.GetValidPromotionToPrint(); //if (dtPromo != null && dtPromo.Rows.Count > 0) //{ // //// // Rectangle RecLine7 = new Rectangle(5, y_p, 290, 1); // var Line7 = Common.Utility.GetImageFromService("ShopImg", "line1.png"); // e.Graphics.DrawImage(Line7, RecLine7); // y_p = y_p + 4; // ////// // foreach (DataRow dr in dtPromo.Rows) // { // Rectangle RecPromo = new Rectangle(5, y_p, 290, 130); // data = "\n---------------\n" + dr["PromoText"].ToString() + "\n---------------\n"; // e.Graphics.DrawString(data, new Font("Arial", 7, FontStyle.Italic), Brushes.Black, RecPromo, strfmt_Center); // y_p = y_p + 130; // } //} }
public static ReceiptsAll GetAllInfo(string ReceiptID) { ReceiptsAll res = new ReceiptsAll(); DataSet ds = new DataSet(); string[][] param = { new string[] { "p_ReceiptId", ReceiptID }, }; string errorString = ""; string cnStr = GetConnectionString(); DataStoreProcQuery_Param(cnStr, "spSelect_Receipt_AllInfo", ref ds, param, ref errorString); if (string.IsNullOrEmpty(errorString) && ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; DataRow dr = dt.Rows[0]; Receipts rc = new Receipts(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CreatedBy = dr["CreatedBy"].ToString(); rc.CreatedDate = dr["CreatedDate"].ToString(); rc.TotalAmountBeforeTax = double.Parse(dr["TotalAmountBeforeTax"].ToString()).ToString("0,0"); rc.TotalTax = double.Parse(dr["TotalTax"].ToString()).ToString("0,0"); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); rc.DiscountAmount = double.Parse(dr["DiscountAmount"].ToString()).ToString("0,0"); rc.TotalMoney = double.Parse(dr["TotalMoney"].ToString()).ToString("0,0"); rc.CashPayAmt = double.Parse(dr["CashPayAmt"].ToString()).ToString("0,0"); rc.CardPayAmt = double.Parse(dr["CardPayAmt"].ToString()).ToString("0,0"); rc.ReturnAmt = double.Parse(dr["ReturnAmt"].ToString()).ToString("0,0"); res.receipt = rc; } ///// if (ds.Tables[1].Rows.Count > 0) { DataTable dt = ds.Tables[1]; List <ReceiptDetails> lst = new List <ReceiptDetails>(); foreach (DataRow dr in dt.Rows) { ReceiptDetails rc = new ReceiptDetails(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.ProductId = dr["ProductId"].ToString(); rc.ProductName = GetProductName(dr["ProductId"].ToString()); rc.Qty = double.Parse(dr["Qty"].ToString()).ToString("0,0"); rc.Price = double.Parse(dr["Price"].ToString()).ToString("0,0"); rc.TotalAmountBeforeTax = double.Parse(dr["TotalAmountBeforeTax"].ToString()).ToString("0,0"); rc.TaxAmount = double.Parse(dr["TaxAmount"].ToString()).ToString("0,0"); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); lst.Add(rc); } res.lst_Detail = lst; } ///thẻ if (ds.Tables[2].Rows.Count > 0) { DataTable dt = ds.Tables[2]; List <ReceiptsCard> lst = new List <ReceiptsCard>(); foreach (DataRow dr in dt.Rows) { ReceiptsCard rc = new ReceiptsCard(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CardNo = dr["CardNo"].ToString(); rc.CardHolderName = dr["CardHolderName"].ToString(); rc.ExpiredDate = dr["ExpiredDate"].ToString(); rc.CardType = dr["CardType"].ToString(); rc.Bank = dr["Bank"].ToString(); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); lst.Add(rc); } res.lst_card = lst; } // ReceiptInfo if (ds.Tables[3].Rows.Count > 0) { DataTable dt = ds.Tables[3]; DataRow dr = dt.Rows[0]; ReceiptInfo rc = new ReceiptInfo(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CustomerName = dr["CustomerName"].ToString(); rc.Address = dr["Address"].ToString(); rc.Phone = dr["Phone"].ToString(); rc.Note = dr["Note"].ToString(); res.receiptInfo = rc; } // ReceiptMember if (ds.Tables[4].Rows.Count > 0) { DataTable dt = ds.Tables[4]; DataRow dr = dt.Rows[0]; ReceiptMember rc = new ReceiptMember(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.MemberId = dr["MemberId"].ToString(); rc.CreatedBy = dr["CreatedBy"].ToString(); DataTable dte = GetMemberInfo(dr["MemberId"].ToString()); if (dte != null) { DataRow drr = dte.Rows[0]; rc.MemberCode = drr["MemberCode"].ToString(); rc.ObjectId = drr["ObjectId"].ToString(); rc.NumberOfVissits = drr["NumberOfVissits"].ToString(); rc.LastestDate = drr["LastestDate"].ToString(); rc.MemberType = drr["MemberType"].ToString(); rc.MemberScore = drr["MemberScore"].ToString(); rc.ObjectGroup = drr["ObjectGroup"].ToString(); rc.ObjectType = drr["ObjectType"].ToString(); rc.Tel = drr["Tel"].ToString(); rc.Email = drr["Email"].ToString(); rc.MemberCode = drr["Gender"].ToString(); rc.FullName = drr["FullName"].ToString(); rc.TemAdd = drr["TemAdd"].ToString(); } res.receiptMember = rc; } } else { res = null; } return(res); }
public ReceiptsAll GetAllInfo(string ReceiptID) { ReceiptsAll res = new ReceiptsAll(); DataSet ds = new DataSet(); string[][] param = { new string[] { "p_ReceiptId", ReceiptID }, }; Program.destopService.DataStoreProcQuery_Param(Program.Username, Program.Password, "spSelect_Receipt_AllInfo", ref ds, param, ref errorString); if (string.IsNullOrEmpty(errorString) && ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; DataRow dr = dt.Rows[0]; Receipts rc = new Receipts(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CreatedBy = dr["CreatedBy"].ToString(); rc.CreatedDate = Convert.ToDateTime(dr["CreatedDate"].ToString()).ToString("dd/MM/yy H:s"); rc.TotalAmountBeforeTax = double.Parse(dr["TotalAmountBeforeTax"].ToString()).ToString("0,0"); rc.TotalTax = double.Parse(dr["TotalTax"].ToString()).ToString("0,0"); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); rc.DiscountAmount = double.Parse(dr["DiscountAmount"].ToString()).ToString("0,0"); rc.TotalMoney = double.Parse(dr["TotalMoney"].ToString()).ToString("0,0"); rc.CashPayAmt = double.Parse(dr["CashPayAmt"].ToString()).ToString("0,0"); rc.CardPayAmt = double.Parse(dr["CardPayAmt"].ToString()).ToString("0,0"); rc.ReturnAmt = double.Parse(dr["ReturnAmt"].ToString()).ToString("0,0"); rc.ServiceCostAmount = double.Parse(dr["ServiceCostAmount"].ToString()).ToString("0,0"); res.receipt = rc; } ///// if (ds.Tables[1].Rows.Count > 0) { Tuple <string, string> result; DataTable dt = ds.Tables[1]; List <ReceiptDetails> lst = new List <ReceiptDetails>(); foreach (DataRow dr in dt.Rows) { ReceiptDetails rc = new ReceiptDetails(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.ProductId = dr["ProductId"].ToString(); if (dr["ProductId"].ToString() != "DISCOUNT") { result = GetProductInfoForReceipt(dr["ProductId"].ToString()); //rc.ProductName = GetProductName(dr["ProductId"].ToString()); rc.ProductName = result.Item1; rc.IsBuffet = result.Item2; } else { rc.ProductName = dr["ProductId"].ToString(); rc.IsBuffet = "0"; } rc.Qty = double.Parse(dr["Qty"].ToString()).ToString("0,0"); rc.Price = double.Parse(dr["Price"].ToString()).ToString("0,0"); rc.TotalAmountBeforeTax = double.Parse(dr["TotalAmountBeforeTax"].ToString()).ToString("0,0"); rc.TaxAmount = double.Parse(dr["TaxAmount"].ToString()).ToString("0,0"); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); lst.Add(rc); } //Duyệt lại lst va set theo thu tu List <ReceiptDetails> lstNew = new List <ReceiptDetails>(); //Lấy sp khác buffet foreach (ReceiptDetails rd in lst) { ReceiptDetails rds = new ReceiptDetails(); if (rd.IsBuffet != "1") { rds.ReceiptId = rd.ReceiptId; rds.ProductId = rd.ProductId; rds.ProductName = rd.ProductName; rds.IsBuffet = rd.IsBuffet; rds.Qty = rd.Qty; rds.Price = rd.Price; rds.TotalAmountBeforeTax = rd.TotalAmountBeforeTax; rds.TaxAmount = rd.TaxAmount; rds.TotalAmount = rd.TotalAmount; lstNew.Add(rds); } } if (lst.Count > lstNew.Count) { //Lấy sp là buffet và price != 0 foreach (ReceiptDetails rd in lst) { ReceiptDetails rds1 = new ReceiptDetails(); if (rd.IsBuffet == "1" && double.Parse(rd.Price) > 0) { rds1.ReceiptId = rd.ReceiptId; rds1.ProductId = rd.ProductId; rds1.ProductName = rd.ProductName; rds1.IsBuffet = rd.IsBuffet; rds1.Qty = rd.Qty; rds1.Price = rd.Price; rds1.TotalAmountBeforeTax = rd.TotalAmountBeforeTax; rds1.TaxAmount = rd.TaxAmount; rds1.TotalAmount = rd.TotalAmount; lstNew.Add(rds1); } } foreach (ReceiptDetails rd in lst) { ReceiptDetails rds2 = new ReceiptDetails(); if (rd.IsBuffet == "1" && double.Parse(rd.Price) == 0) { rds2.ReceiptId = rd.ReceiptId; rds2.ProductId = rd.ProductId; rds2.ProductName = rd.ProductName; rds2.IsBuffet = rd.IsBuffet; rds2.Qty = rd.Qty; rds2.Price = rd.Price; rds2.TotalAmountBeforeTax = rd.TotalAmountBeforeTax; rds2.TaxAmount = rd.TaxAmount; rds2.TotalAmount = rd.TotalAmount; lstNew.Add(rds2); } } } res.lst_Detail = lstNew; } ///thẻ if (ds.Tables[2].Rows.Count > 0) { DataTable dt = ds.Tables[2]; List <ReceiptsCard> lst = new List <ReceiptsCard>(); foreach (DataRow dr in dt.Rows) { ReceiptsCard rc = new ReceiptsCard(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CardNo = dr["CardNo"].ToString(); rc.CardHolderName = dr["CardHolderName"].ToString(); rc.ExpiredDate = dr["ExpiredDate"].ToString(); rc.CardType = dr["CardType"].ToString(); rc.Bank = dr["Bank"].ToString(); rc.TotalAmount = double.Parse(dr["TotalAmount"].ToString()).ToString("0,0"); lst.Add(rc); } res.lst_card = lst; } // ReceiptInfo if (ds.Tables[3].Rows.Count > 0) { DataTable dt = ds.Tables[3]; DataRow dr = dt.Rows[0]; ReceiptInfo rc = new ReceiptInfo(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.CustomerName = dr["CustomerName"].ToString(); rc.Address = dr["Address"].ToString(); rc.Phone = dr["Phone"].ToString(); rc.Note = dr["Note"].ToString(); res.receiptInfo = rc; } // ReceiptMember if (ds.Tables[4].Rows.Count > 0) { DataTable dt = ds.Tables[4]; DataRow dr = dt.Rows[0]; ReceiptMember rc = new ReceiptMember(); rc.ReceiptId = dr["ReceiptId"].ToString(); rc.MemberId = dr["MemberId"].ToString(); rc.CreatedBy = dr["CreatedBy"].ToString(); DataTable dte = GetMemberInfo(dr["MemberId"].ToString()); if (dte != null) { DataRow drr = dte.Rows[0]; rc.MemberCode = drr["MemberCode"].ToString(); rc.ObjectId = drr["ObjectId"].ToString(); rc.NumberOfVissits = drr["NumberOfVissits"].ToString(); rc.LastestDate = drr["LastestDate"].ToString(); rc.MemberType = drr["MemberType"].ToString(); rc.MemberScore = drr["MemberScore"].ToString(); rc.ObjectGroup = drr["ObjectGroup"].ToString(); rc.ObjectType = drr["ObjectType"].ToString(); rc.Tel = drr["Tel"].ToString(); rc.Email = drr["Email"].ToString(); rc.MemberCode = drr["Gender"].ToString(); rc.FullName = drr["FullName"].ToString(); rc.TemAdd = drr["TemAdd"].ToString(); } res.receiptMember = rc; } } else { res = null; } return(res); }