static public void display_list(login_download form, List <ToJsonMy> list) { foreach (var item in list) { if (item.status != "未下载") { display_single(form, item); } } }
static public void direct_print_ibook(ToJsonMy file, login_download form) { string filename = ""; filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); if (File.Exists(@filename)) { PdfDocument doc = new PdfDocument(); doc.LoadFromFile(filename); PrintDialog dialogprint = new PrintDialog(); List <string> printer_use_list = new List <string>(); printer_use_list = remember.ReadTextFileToList(@"printer_setting.sjc"); if (printer_use_list.Count != 4) { throw new Exception("请先设置需要使用的打印机"); } dialogprint.PrinterSettings.PrinterName = printer_use_list[1]; dialogprint.PrinterSettings.Duplex = Duplex.Vertical; dialogprint.PrinterSettings.DefaultPageSettings.Color = false; dialogprint.UseEXDialog = true; dialogprint.AllowPrintToFile = true; dialogprint.AllowSomePages = true; dialogprint.PrinterSettings.MinimumPage = 1; dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; dialogprint.PrinterSettings.FromPage = 1; dialogprint.PrinterSettings.Collate = true; dialogprint.PrinterSettings.ToPage = doc.Pages.Count; string copy = file.copies.Substring(0, 1); dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; doc.PrintToPage = dialogprint.PrinterSettings.ToPage; doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; PrintDocument printdoc = doc.PrintDocument; dialogprint.Document = printdoc; printdoc.Print(); file.changeStatusById("4"); form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; } else { MessageBox.Show("本店电子书路径有误,请改正"); } }
static public void setbefore_print_file(ToJsonMy file, login_download form) { string filename = ""; filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); if ((doc_extension == ".doc") || (doc_extension == ".docx")) { filename += ".pdf"; } if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) { filename += ".pdf"; } PdfDocument doc = new PdfDocument(); doc.LoadFromFile(filename); PrintDialog dialogprint = new PrintDialog(); dialogprint.UseEXDialog = true; dialogprint.AllowPrintToFile = true; dialogprint.AllowSomePages = true; dialogprint.PrinterSettings.MinimumPage = 1; dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; dialogprint.PrinterSettings.FromPage = 1; dialogprint.PrinterSettings.Collate = true; dialogprint.PrinterSettings.ToPage = doc.Pages.Count; if (file.copies != "现场打印") { string copy = file.copies.Substring(0, 1); dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); } if (dialogprint.ShowDialog() == DialogResult.OK) { doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; doc.PrintToPage = dialogprint.PrinterSettings.ToPage; doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; PrintDocument printdoc = doc.PrintDocument; dialogprint.Document = printdoc; printdoc.Print(); file.changeStatusById("4"); form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; } }
static public void setbefore_print_ibook(ToJsonMy file, login_download form) { string filename = ""; filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); if (File.Exists(@filename)) { PdfDocument doc = new PdfDocument(); doc.LoadFromFile(filename); PrintDialog dialogprint = new PrintDialog(); dialogprint.UseEXDialog = true; dialogprint.AllowPrintToFile = true; dialogprint.AllowSomePages = true; dialogprint.PrinterSettings.MinimumPage = 1; dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; dialogprint.PrinterSettings.FromPage = 1; dialogprint.PrinterSettings.Collate = true; dialogprint.PrinterSettings.ToPage = doc.Pages.Count; string copy = file.copies.Substring(0, 1); dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); if (dialogprint.ShowDialog() == DialogResult.OK) { doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; doc.PrintToPage = dialogprint.PrinterSettings.ToPage; doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; PrintDocument printdoc = doc.PrintDocument; dialogprint.Document = printdoc; printdoc.Print(); file.changeStatusById("4"); form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; } } else { MessageBox.Show("本店电子书路径有误,请改正"); } }
static public void display_single(login_download form, ToJsonMy file) { mydata_form data = new mydata_form(); data.mydata_userName = file.student_number + file.use_name; data.mydata_buttontext = ""; data.mydata_name = file.name; data.mydata_id = file.id; data.mydata_time = file.time; data.mydata_copies = file.copies; if (database.err_list.Contains(file.id)) { data.mydata_status = "下载失败"; } else { data.mydata_status = file.status; } data.mydata_doubleside = file.double_side; data.mydata_color = file.strcolor; data.mydata_ppt = file.ppt; if (file.requirements != "") { data.mydata_name = "(注)" + file.name; } if (file.isfirst == true) { data.mydata_name = "(首单!)" + file.name; } if (file.copies == "现场打印") { data.mydata_buttontext = "确认付款"; data.mydata_doubleside = "-"; data.mydata_color = "-"; data.mydata_ppt = "-"; delegate_display = display_fun; form.mydata.Invoke(delegate_display, new object[] { form, data }); } else { switch (file.status) { case "已下载": data.mydata_buttontext = "通知已打印"; break; case "已打印": data.mydata_buttontext = "确认付款"; break; case "正打印": data.mydata_buttontext = "通知已打印"; break; case "未下载": data.mydata_buttontext = "手动下载"; break; } delegate_display = display_fun; form.mydata.Invoke(delegate_display, new object[] { form, data }); } }
static public void display_fun(login_download form, mydata_form data) { form.mydata.Rows.Add(data.mydata_id, data.mydata_userName, data.mydata_name, data.mydata_copies, data.mydata_doubleside, data.mydata_color, data.mydata_ppt, data.mydata_time, data.mydata_status, data.mydata_buttontext); }
static public void direct_print_file(ToJsonMy file, login_download form) { string filename = ""; filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); if ((doc_extension == ".doc") || (doc_extension == ".docx")) { filename += ".pdf"; } if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) { filename += ".pdf"; throw new Exception("ppt文件请设置文件后打印"); } if (file.copies == "现场打印") { throw new Exception("请选择详细设置后打印"); } PdfDocument doc = new PdfDocument(); doc.LoadFromFile(filename); PrintDialog dialogprint = new PrintDialog(); List <string> printerlist = new List <string>(); string defaultprinter = dialogprint.PrinterSettings.PrinterName; List <string> printer_use_list = new List <string>(); printer_use_list = remember.ReadTextFileToList(@"printer_setting.sjc"); if (printer_use_list.Count != 4) { throw new Exception("请先设置需要使用的打印机"); } if ((file.color == "0") && (file.double_side == "单面")) { dialogprint.PrinterSettings.PrinterName = printer_use_list[0]; dialogprint.PrinterSettings.Duplex = Duplex.Simplex; dialogprint.PrinterSettings.DefaultPageSettings.Color = false; } else if ((file.color == "1") && (file.double_side == "单面")) { dialogprint.PrinterSettings.PrinterName = printer_use_list[2]; dialogprint.PrinterSettings.Duplex = Duplex.Simplex; dialogprint.PrinterSettings.DefaultPageSettings.Color = true; } else if ((file.color == "0") && (file.double_side == "双面")) { dialogprint.PrinterSettings.PrinterName = printer_use_list[1]; dialogprint.PrinterSettings.Duplex = Duplex.Vertical; dialogprint.PrinterSettings.DefaultPageSettings.Color = false; } else if ((file.color == "1") && (file.double_side == "双面")) { dialogprint.PrinterSettings.PrinterName = printer_use_list[3]; dialogprint.PrinterSettings.Duplex = Duplex.Vertical; dialogprint.PrinterSettings.DefaultPageSettings.Color = true; } dialogprint.UseEXDialog = true; dialogprint.AllowPrintToFile = true; dialogprint.AllowSomePages = true; dialogprint.PrinterSettings.MinimumPage = 1; dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; dialogprint.PrinterSettings.FromPage = 1; dialogprint.PrinterSettings.Collate = true; dialogprint.PrinterSettings.ToPage = doc.Pages.Count; string copy = file.copies.Substring(0, 1); dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; doc.PrintToPage = dialogprint.PrinterSettings.ToPage; doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; PrintDocument printdoc = doc.PrintDocument; dialogprint.Document = printdoc; printdoc.Print(); file.changeStatusById("4"); form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; }
public backgroundworker_refresh(login_download form) { this.form = form; }
//public ToJsonMy file; public download_single_single_class(login_download form, ToJsonMy file) { this.form = form; this.file = file; }
public download_errfile_class(login_download form, ToJsonMy file, int RowIndex) { this.form = form; this.file = file; this.RowIndex = RowIndex; }
public download_list_class(login_download form, List <ToJsonMy> list) { this.form = form; this.list = list; }