private void Do_Print() { if (PrintPreviewChkBox.Checked) { PreviewDoc.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 1094, 1546); PrintPrev.Document = PreviewDoc; ((Form)PrintPrev).StartPosition = FormStartPosition.CenterScreen; DialogResult result = PrintPrev.ShowDialog(); if (result == DialogResult.OK) { PreviewDoc.Print(); } } else if (PrintChkBox.Checked) { PrintDial.Document = PreviewDoc; PrintDial.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 1094, 1546); PrintDial.PrinterSettings.Copies = 2; DialogResult result = PrintDial.ShowDialog(); if (result == DialogResult.OK) { PrintDoc.Print(); } } }
private void PrintItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (focused_tree_node == null) { return; } switch (focused_tree_node.GType.Value) { case 1: PrintDoc.Show(focused_row.Id, focused_row.WType, DB.SkladBase()); break; case 3: PrintDoc.Show(focused_row.Id, focused_row.WType, DB.SkladBase()); break; case 4: PrintDoc.Show(pp_focused_row.Id, 21, DB.SkladBase()); break; case 5: PrintDoc.Show(pc_focused_row.Id, 22, DB.SkladBase()); break; case 6: PrintDoc.Show(focused_prep_raw_mat_row.Id, focused_prep_raw_mat_row.WType, DB.SkladBase()); break; } }
private void addPrintQueueToList(PrintDoc pq) { dataGridView1.Rows.Add(); DataGridViewRow row = dataGridView1.Rows[dataGridView1.Rows.Count - 1]; row.Cells[FileName.Index].Value = pq.fileName; row.Cells[FullName.Index].Value = pq.fullName; }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var row = bandedGridView1.GetFocusedRow() as OrderedList_Result; if (row != null) { PrintDoc.Show(row.Id, row.WType, DB.SkladBase()); } }
private void Cmd_PageSettingsClick(object sender, EventArgs e) { if (Dlg_PageSetup.ShowDialog().Equals(DialogResult.OK)) { PrintDoc.DefaultPageSettings = Dlg_PageSetup.PageSettings; Show_PrintingProperties(); PrintDoc.Print(); Ctrl_Preview.Document = PrintDoc; } }
void OnFilePrint(object sender, EventArgs e) { PrintDoc pd = new PrintDoc(composizione, Path.GetFileNameWithoutExtension(sFileName)); PrintDialog dlg = new PrintDialog(); dlg.Document = pd; if (dlg.ShowDialog() == DialogResult.OK) { pd.Print(); } }
private void barButtonItem2_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { GetRelDocList_Result row = new GetRelDocList_Result(); if (gridView3.Focus()) { row = gridView3.GetFocusedRow() as GetRelDocList_Result; } else if (gridView5.Focus()) { row = gridView5.GetFocusedRow() as GetRelDocList_Result; } PrintDoc.Show(row.Id, row.DocType.Value, DB.SkladBase()); }
private void PrintItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { switch (focused_tree_node.GType) { case 2: var dr = WbGridView.GetFocusedRow() as GetWayBillListWh_Result; if (dr == null) { return; } PrintDoc.Show(dr.Id.Value, dr.WType.Value, DB.SkladBase()); break; } }
public ActionResult csv(string id) { string sql = "select [ls_inn], [ls_status] ,[ls_actuality_date] ,[ls_type] ,[ls_full_with_opf] ,[ls_short_with_opf], ls_load_status " + "from cntload_detail (nolock) where ls_ld = @ls_ld order by ls_pk"; SqlDataAdapter da = new SqlDataAdapter(sql, Program.AppConfig["mscns"]); DataTable restab = new DataTable(); da.SelectCommand.Parameters.AddWithValue("@ls_ld", id); da.Fill(restab); PrintDoc pd = new PrintDoc(); string restxt = pd.ExportCSV(restab); string filen = "Task_" + id + ".csv"; string ctype = "application/csv"; byte[] buf = Encoding.GetEncoding(1251).GetBytes(restxt); return(File(buf, ctype, filen)); }
private void Form1_Load(object sender, EventArgs e) { allfiles = Directory.GetFiles(@"Z:\TEST\staffs\Nini\letters\", "*.*", SearchOption.AllDirectories); bindingSource1 = new BindingSource(); foreach (var file in allfiles) { FileInfo info = new FileInfo(file); // Do something with the Folder or just add them to a list via nameoflist.add(); PrintDoc pq = new PrintDoc(); pq.fileName = info.Name; pq.fullName = info.FullName; fileList.Add(pq); addPrintQueueToList(pq); } }
private void PrevievBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var dr = OperLogDetBS.DataSource as GetOperLog_Result; if (dr.DocType != null) { if (dr.DocType != -3 && dr.DocType != 3 && dr.DocType != -2 && dr.DocType != 18 && dr.DocType != 8 && dr.DocType != -8 && dr.DocType != -7) { var wb = DB.SkladBase().WaybillList.Find(dr.Id); if (wb != null) { PrintDoc.Show(wb.Id, dr.DocType.Value, DB.SkladBase()); } else { MessageBox.Show("Документ не знайдено !"); } } } }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var dir = bandedGridView1.GetFocusedRow() as GetDocList_Result; PrintDoc.Show(dir.Id.Value, dir.WType.Value, DB.SkladBase()); }
private void printbarcode() { this.PrintDialog.Document = this.PrintDoc; PrintDoc.Print(); }
private void PrintBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _db.Save(wb.WbillId); PrintDoc.Show(wb.Id, wb.WType, _db); }
private void PrevievBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { wb.UpdatedAt = DateTime.Now; PrintDoc.Show(wb.Id, wb.WType, _db); }
private void simpleButton11_Click(object sender, EventArgs e) { wb.UpdatedAt = DateTime.Now; PrintDoc.Show(wb.Id, wb.WType, _db); }
private void PrevievBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PrintDoc.Show(pc.Id, 22, _db); }
private void TSB_PrintClick(object sender, EventArgs e) { Preview = false; PrintDoc.Print(); Preview = true; }
public ActionResult PrintMap(Guid FC_PK, string RH_Category, int MH_RH) { try { DataTable MapH = new DataTable(); DataTable MapD = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("p_prnMap", DBClient.CnStr); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.AddWithValue("@FC_PK", FC_PK); da.SelectCommand.Parameters.AddWithValue("@RH_Category", RH_Category); da.SelectCommand.Parameters.AddWithValue("@MH_RH", MH_RH); DataTable[] par = { MapH, MapD }; da.Fill(0, 0, par); /* * if (MapH.Rows.Count == 0) * { * MessageBox.Show("Не найден регламент!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } */ String RH_Template = MapH.Rows[0]["MH_Template"].ToString(); /* * if (String.IsNullOrEmpty(RH_Template)) * { * MessageBox.Show("Не указан файл шаблона!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } */ /* * String code = MapH.Rows[0]["AD_NN"].ToString(); * //Штрих код 17052012 * * Barcode128 bc = new Barcode128(); * bc.BarHeight = 100f; * bc.Code = code; * System.Drawing.Image img = bc.CreateDrawingImage(Color.Black, Color.White); * * * Bitmap bimg = new Bitmap(img); * //Расширяем картинку * int bmpw = 790; * int imgw = img.Width; * Bitmap bmp = new Bitmap(bmpw, 100); * for (int i = 0; i < bmpw; i++) * { * int ii = i * imgw / bmpw; * Color c = bimg.GetPixel(ii, 50); * for (int j = 0; j < 100; j++) * bmp.SetPixel(i, j, c); * } * * SortedList images = new SortedList(); * images.Add("image2", bmp); */ List <DataTable> atab = new List <DataTable>(); Dictionary <string, byte[]> images = new Dictionary <string, byte[]>(); atab.Add(MapD); Guid gd = Guid.NewGuid(); String FileName = "MapRep" + gd.ToString() + ".docx"; PrintDoc pd = new PrintDoc(); byte[] buf = pd.PrintDocx(RH_Template, MapH.Rows[0], atab, images); return(File(buf, "application/octet-stream", RH_Template)); } catch (Exception e) { byte[] buf = System.Text.Encoding.Unicode.GetBytes(e.Message); return(File(buf, "application/octet-stream", "ОшибкаПечати.txt")); } }
public ActionResult tgo(string id) { string FC_PK = id; //"9f076395-ebb8-4ade-b65a-3c6571fb0805" DataTable _MapH = new DataTable(); string sql = "select * from v_MapH_strong where FC_PK = @FC_PK and RH_Category = @RH_Category"; var cnstr = Program.AppConfig["mscns"]; string RH_Category = "Обслуживание ВС"; SqlDataAdapter _da = new SqlDataAdapter(sql, cnstr); _da.SelectCommand.Parameters.AddWithValue("@FC_PK", FC_PK); _da.SelectCommand.Parameters.AddWithValue("@RH_Category", RH_Category); _da.Fill(_MapH); if (_MapH.Rows.Count == 0) { return(File(Encoding.UTF8.GetBytes("Не найден регламент."), "application/octet-stream", "Регламент не найден.txt")); } DataTable MapH = new DataTable(); DataTable MapD = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("p_prnMap", cnstr); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.AddWithValue("@FC_PK", FC_PK); da.SelectCommand.Parameters.AddWithValue("@RH_Category", RH_Category); da.SelectCommand.Parameters.AddWithValue("@MH_RH", _MapH.Rows[0]["MH_RH"]); DataTable[] par = { MapH, MapD }; da.Fill(0, 0, par); if (MapH.Rows.Count == 0) { return(File(Encoding.UTF8.GetBytes("Не найден регламент."), "application/octet-stream", "Регламент не найден.txt")); } string RH_Template = MapH.Rows[0]["MH_Template"].ToString().ToLower().Replace(".docx", ""); /* Картинку пока не рисуем * string codeurl = "https://www.barcodesinc.com/generator/image.php?type=C128B&width=120&height=100&xres=1&font=3&code=" + MapH.Rows[0]["AD_NN"].ToString(); * var codeRequest = (HttpWebRequest)WebRequest.Create(codeurl); * codeRequest.Method = "GET"; * HttpWebResponse codeResponse = (HttpWebResponse)codeRequest.GetResponse(); * long nc = codeResponse.ContentLength; * Stream st = codeResponse.GetResponseStream(); * //byte[] buf = new byte[(int)nc]; * //st.Read(buf, 0, (int)nc); * System.Drawing.Image img = Image.FromStream(st); * Bitmap bimg = new Bitmap(img); * for (int i = 0; i < 100; i++) * { * bimg.SetPixel(0, i, Color.White); * bimg.SetPixel(img.Width - 1, i, Color.White); * * } * //Расширяем картинку * int bmpw = 790; * int imgw = img.Width; * Bitmap bmp = new Bitmap(bmpw, 100); * for (int i = 0; i < bmpw; i++) * { * int ii = i * imgw / bmpw; * Color c = bimg.GetPixel(ii, 50); * for (int j = 0; j < 100; j++) * bmp.SetPixel(i, j, c); * } * MemoryStream ms = new MemoryStream(); * bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); * byte[] buf = ms.ToArray(); * * Dictionary<string, byte[]> Images = new Dictionary<string, byte[]>() { { "image2.png", buf } }; */ Dictionary <string, byte[]> Images = new Dictionary <string, byte[]>(); /* * //Штрих код 17052012 */ string FileName = MapH.Rows[0]["MH_ArrivalFlNumber"].ToString() + "_" + MapH.Rows[0]["MH_DepartFlNumber"].ToString(); List <DataTable> atab = new List <DataTable>() { MapD }; PrintDoc pd = new PrintDoc(); byte[] res = pd.PrintDocx(RH_Template, MapH.Rows[0], atab, Images); //Возвращаем word return(File(res, "application/octet-stream", FileName + ".docx")); /* * Dictionary<string, object> param = new Dictionary<string, object>(); * Dictionary<string, object> FileValue = new Dictionary<string, object>(); * FileValue.Add("Name", FileName + ".docx"); * FileValue.Add("Data", Convert.ToBase64String(res, Base64FormattingOptions.None)); * param.Add("Name", "File"); * param.Add("FileValue", FileValue); * * string convurl = "https://v2.convertapi.com/convert/docx/to/pdf?Secret=asey91obtGbzCCSV"; * var httpRequest = (HttpWebRequest)WebRequest.Create(convurl); * httpRequest.Method = "POST"; * httpRequest.ContentType = "application/json"; * var serializer = new JsonSerializer(); * using (var w = new StreamWriter(httpRequest.GetRequestStream())) * { * using (JsonWriter writer = new JsonTextWriter(w)) * { * serializer.Serialize(writer, new { Parameters = new object[]{param} }); * } * } * string responseText = ""; * HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); * using (var r = new StreamReader(httpResponse.GetResponseStream())) * { * responseText = r.ReadToEnd(); * } * ConvertApiResponse resp = JsonConvert.DeserializeObject<ConvertApiResponse>(responseText); * return File(Convert.FromBase64String(resp.Files[0].FileData), "application/pdf", resp.Files[0].FileName); */ }
private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var row = gridView3.GetFocusedRow() as GetRelDocList_Result; PrintDoc.Show(row.Id, row.DocType.Value, DB.SkladBase()); }
private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var row = bandedGridView1.GetFocusedRow() as PosGet_Result; PrintDoc.Show(row.Id.Value, row.DocType.Value, DB.SkladBase()); }
private void PrevievBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _db.SaveChanges(); PrintDoc.Show(wb.Id, wb.WType, _db); }
private void PrevievBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _db.SaveChanges(); PrintDoc.Show(_pd.Id, _pd.DocType == -2 ? _pd.DocType : _pd.DocType * 3, _db); }