/// <summary> /// 双击打开文件,若不存在,则自动下载,双击ID显示用户基本信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mydata_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if ((e.ColumnIndex >= 1) && (e.ColumnIndex < 2)) { string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); ToJsonMy file = database.find_myjson(id); userInfo user = new userInfo(); user = usermessage(file.use_id); MessageBox.Show("用户:" + user.name + " 学号:" + user.student_number + " 手机号:" + user.phone); } else if ((e.ColumnIndex >= 2) && (e.ColumnIndex < 3)) { string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); ToJsonMy file = database.find_myjson(id); if (file != null) { if (!file.is_ibook) { 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 != ".pdf") { filename += ".pdf"; } if (File.Exists(@filename)) { System.Diagnostics.Process.Start(filename); } else { download_single_single_class file_download = new download_single_single_class(this, file); file_download.download(); } } else { string filename = ""; filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); if (File.Exists(@filename)) { System.Diagnostics.Process.Start(filename); } else { MessageBox.Show("本店电子书路径有误,请改正"); } } } } }
private void dicret_download_Click(object sender, EventArgs e) { try { string current_id = mydata.Rows[mydata.CurrentRow.Index].Cells["id"].Value.ToString(); ToJsonMy file = database.find_myjson(current_id); if (file != null) { if (!file.is_ibook) { 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.Exists(@filename)) { print_class.direct_print_file(file, this); } else { download_single_single_class file_download = new download_single_single_class(this, file); file_download.download(); } } else { print_class.direct_print_ibook(file, this); } } } catch (Exception excep) { MessageBox.Show(excep.Message, "无法打印"); } }