public void rptInMaVach(DataTable oTblSP, Boolean isDG = false, Boolean isMaQR = true) { try { if (oTblSP == null || oTblSP.Rows.Count <= 0) { Utils.showMessage(String.Format("Bạn chưa chọn sản phẩm cần tạo mã {0}", isMaQR == true ? " QRCode.." : " Vạch.."), "Lưu ý"); return; } SqlParameter[] arrPara = new SqlParameter[5]; arrPara[0] = new SqlParameter("@tblMasp", SqlDbType.Structured); arrPara[0].Value = oTblSP; arrPara[1] = new SqlParameter("@Loai", SqlDbType.TinyInt); arrPara[1].Value = isMaQR == true ? 0 : 1; arrPara[2] = new SqlParameter("@Cogia", SqlDbType.Bit); arrPara[2].Value = isDG == true ? 1 :0; arrPara[3] = new SqlParameter("@Denngay", SqlDbType.NVarChar, 15); arrPara[3].Value = MTGlobal.MT_DENNGAY; arrPara[4] = new SqlParameter("@Nguoidung", SqlDbType.NVarChar, 50); arrPara[4].Value = MTGlobal.MT_USER_LOGIN; DataTable otblMaCode = new MTSQLServer().wRead("rptDM_InMaQRCode", arrPara); if (otblMaCode != null) { rptHH_QRCode_30_30 oReport = new rptHH_QRCode_30_30(); oReport.DataSource = otblMaCode; oReport.BindData(); //setParameterInfo(oReport); //setFormatReport(oReport); //SetMarginReport(oReport, false, 30, 30, 30, 25); PrintPreview oPreview = new PrintPreview(); oPreview.report = oReport; oPreview.ShowDialog(); } } catch { } }
/* * private System.Drawing.Image fQRCode(string mQRTitle, string mQRData){ * try{ * // Dim QRPath As String * BarcodeSettings QRSetting = new BarcodeSettings(); * QRSetting.Type = BarCodeType.QRCode; * QRSetting.Data = mQRData; * QRSetting.Data2D = mQRTitle; * QRSetting.QRCodeDataMode = QRCodeDataMode.AlphaNumber; * * QRSetting.ResolutionType = ResolutionType.Graphics; * QRSetting.Unit = System.Drawing.GraphicsUnit.Millimeter; * QRSetting.DpiX = 300; * QRSetting.DpiY = 300; * * QRSetting.BarHeight = 25; * QRSetting.HasBorder = false; * QRSetting.BorderWidth = 1; * * QRSetting.ImageHeight = 25; // 2.53 Inch | 64.2 Inch |128mm | 480 Pixel * QRSetting.ImageWidth = 25; * QRSetting.AutoResize = true; * * QRSetting.X = 0.5F; * QRSetting.QRCodeECL = QRCodeECL.H; * QRSetting.TopMargin = 1; * QRSetting.LeftMargin = 1; * QRSetting.RightMargin = 1; * QRSetting.BottomMargin = 1; * QRSetting.ForeColor = System.Drawing.Color.Black; * // QRSetting.ForeColor = Color.CadetBlue * * System.Drawing.Font myFont = new System.Drawing.Font("Verdana", 8); * QRSetting.TextFont = myFont; * QRSetting.ShowText = false; * QRSetting.TopText = mQRTitle; * QRSetting.TopTextColor = System.Drawing.Color.Green; * QRSetting.ShowTextOnBottom = false; * * BarCodeGenerator QRGer = new BarCodeGenerator(QRSetting); * System.Drawing.Image Img = QRGer.GenerateImage(); * * // 'Dim QRBitmap As System.Drawing.Bitmap = oQR.GetGraphic(20) * System.IO.MemoryStream oMS = new System.IO.MemoryStream(); * Img.Save(oMS, System.Drawing.Imaging.ImageFormat.Png); * return Img; * } * catch (Exception ex) * { * return null; * } * } */ #endregion public void rptInMaVach(DataTable oTblSP, Boolean isDG = false, Boolean isMaQR = true, String isMauIn = "25_15") { try { if (oTblSP == null || oTblSP.Rows.Count <= 0) { Utils.showMessage(String.Format("Bạn chưa chọn sản phẩm cần tạo mã {0}", isMaQR == true ? " QRCode.." : " Vạch.."), "Lưu ý"); return; } SqlParameter[] arrPara = new SqlParameter[5]; arrPara[0] = new SqlParameter("@tblMasp", SqlDbType.Structured); arrPara[0].Value = oTblSP; arrPara[1] = new SqlParameter("@Loai", SqlDbType.TinyInt); arrPara[1].Value = isMaQR == true ? 0 : 1; arrPara[2] = new SqlParameter("@Cogia", SqlDbType.Bit); arrPara[2].Value = isDG == true ? 1 : 0; arrPara[3] = new SqlParameter("@Denngay", SqlDbType.NVarChar, 15); arrPara[3].Value = MTGlobal.MT_DENNGAY; arrPara[4] = new SqlParameter("@Nguoidung", SqlDbType.NVarChar, 50); arrPara[4].Value = MTGlobal.MT_USER_LOGIN; DataTable otblMaCode = new MTSQLServer().wRead("rptDM_InMaQRCode", arrPara); if (otblMaCode != null) { switch (isMauIn) { case "25_15": rptHH_QRCode_25_15 oReport = new rptHH_QRCode_25_15(); oReport.InitMacode(isMaQR); oReport.DataSource = otblMaCode; oReport.BindData(); SetCustomPageQR(oReport, isMauIn); setFormatReport(oReport); XtraReportPreviewModel model = new XtraReportPreviewModel(oReport); model.AutoShowParametersPanel = false; DocumentPreviewWindow oPrev = new DocumentPreviewWindow() { Model = model }; oPrev.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow; oPrev.WindowState = System.Windows.WindowState.Normal; oPrev.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; oPrev.Title = "IN MÃ VẠCH"; oPrev.ShowDialog(); break; //3TEM/ROW case "35_22": /* * Spire.Barcode.BarcodeSettings.ApplyKey("3GZHB-UT3PY-9YAGD-EXYS6-PREGK"); * DataTable oTblCode = new DataTable(); * oTblCode.Columns.Add("Macode", typeof(System.String)); * oTblCode.Columns.Add("MacodeText", typeof(System.String)); * oTblCode.Columns.Add("PicCode", typeof(System.Drawing.Image)); * foreach (DataRow vR in otblMaCode.Rows) { * DataRow dR = oTblCode.NewRow(); * dR["Macode"] = vR["Macode"]; * dR["MacodeText"] = vR["MacodeText"]; * dR["PicCode"] =fQRCode(vR["MacodeText"].ToString(),vR["Macode"].ToString()); * oTblCode.Rows.Add(dR); * * } * oTblCode.AcceptChanges(); * rptHH_QRCode_3temImg_35_22 oReport3t = new rptHH_QRCode_3temImg_35_22(); * oReport3t.InitMacode(isMaQR); * oReport3t.DataSource = oTblCode; * oReport3t.BindData(); * SetCustomPageQR(oReport3t, isMauIn); * setFormatReport(oReport3t); * * PrintPreview oPreview3t = new PrintPreview(); * oPreview3t.report = oReport3t; * * oPreview3t.Show(); * break; */ if (isMaQR) { rptHH_QRCode_35_22 oRptQRcode3T = new rptHH_QRCode_35_22(); oRptQRcode3T.InitMacode(isMaQR); oRptQRcode3T.DataSource = otblMaCode; oRptQRcode3T.BindData(); SetCustomPageQR(oRptQRcode3T, isMauIn); setFormatReport(oRptQRcode3T); PrintPreview oPreviewQR = new PrintPreview(); oPreviewQR.report = oRptQRcode3T; oPreviewQR.ShowDialog(); /* * XtraReportPreviewModel model2 = new XtraReportPreviewModel(oRptQRcode3T); * model2.AutoShowParametersPanel = false; * DocumentPreviewWindow oPrev2 = new DocumentPreviewWindow() { Model = model2 }; * oPrev2.UpdateLayout(); * * oPrev2.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow; * oPrev2.WindowState = System.Windows.WindowState.Normal; * oPrev2.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; * oPrev2.Title = "IN MÃ QRCODE"; * //oPrev2.Topmost = true; * oPrev2.ShowDialog(); */ } else { rptHH_Barcode_35_22 oRptBarcode3T = new rptHH_Barcode_35_22(); oRptBarcode3T.InitMacode(isMaQR); oRptBarcode3T.DataSource = otblMaCode; oRptBarcode3T.BindData(); XtraReportPreviewModel model2 = new XtraReportPreviewModel(oRptBarcode3T); model2.AutoShowParametersPanel = false; DocumentPreviewWindow oPrev2 = new DocumentPreviewWindow() { Model = model2 }; //oRptBarcode3T.CreateDocument(false); oPrev2.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow; oPrev2.WindowState = System.Windows.WindowState.Normal; oPrev2.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; oPrev2.Title = "IN MÃ VẠCH"; //oPrev2.Topmost = true; //SetCustomPageQR(oRptBarcode3T, isMauIn); setFormatReport(oRptBarcode3T); oPrev2.ShowDialog(); } break; case "30_30": rptHH_QRCode_30_30 oReport30 = new rptHH_QRCode_30_30(); oReport30.InitMacode(isMaQR); oReport30.DataSource = otblMaCode; oReport30.BindData(); setFormatReport(oReport30); SetCustomPageQR(oReport30); PrintPreview oPreview30 = new PrintPreview(); oPreview30.report = oReport30; oPreview30.ShowDialog(); break; } } else { Utils.showMessage("Không thể đọc dữ liệu tạo mã vạch..", "Thông báo"); } } catch { } }