///<summary></summary> public void FormDocInfo_Load(object sender, System.EventArgs e) { //if (Docs.Cur.FileName.Equals(null)) listCategory.Items.Clear(); for (int i = 0; i < DefB.Short[(int)DefCat.ImageCats].Length; i++) { string folderName = DefB.Short[(int)DefCat.ImageCats][i].ItemName; listCategory.Items.Add(folderName); if (i == 0 || DefB.Short[(int)DefCat.ImageCats][i].DefNum == DocCur.DocCategory || folderName == initialSelection) { listCategory.SelectedIndex = i; } } listType.Items.Clear(); listType.Items.AddRange(Enum.GetNames(typeof(ImageType))); listType.SelectedIndex = (int)DocCur.ImgType; textToothNumbers.Text = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers); textDate.Text = DocCur.DateCreated.ToString("d"); textDescript.Text = DocCur.Description; //When the A to Z folders are disabled, the image module is disabled and this //code will never get called. Thus, by the time this point in the code is reached, //there will be a valid image path. textFileName.Text = ODFileUtils.CombinePaths(new string[] { FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1).ToUpper(), PatCur.ImageFolder, DocCur.FileName }); if (File.Exists(textFileName.Text)) { FileInfo fileInfo = new FileInfo(textFileName.Text); textSize.Text = fileInfo.Length.ToString("n0"); } textToothNumbers.Text = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers); //textNote.Text=DocCur.Note; }
/* * private void CheckClaimForm() { * butDownloadClaimform.Enabled=false; * textResultClaimform.Text=""; * if(textRegClaimform.Text.Length==0) { * return; * } * string remoteUri=textWebsitePath.Text+textRegClaimform.Text+"/"; * string fileName="Manifest.txt"; * WebClient myWebClient=new WebClient(); * string myStringWebResource=remoteUri+fileName; * string description; * try { * using(StreamReader sr=new StreamReader(myWebClient.OpenRead(myStringWebResource))) { * description=sr.ReadLine(); * BackgroundImg=sr.ReadLine(); * OldClaimFormID=sr.ReadLine(); * } * } * catch { * textResultClaimform.Text+=Lan.g(this,"Registration number not valid, or internet connection failed."); * return; * } * if(BackgroundImg==null) { * BackgroundImg=""; * } * if(OldClaimFormID==null) { * OldClaimFormID=""; * } * textResultClaimform.Text+=description; * butDownloadClaimform.Enabled=true; * }*/ private void butDownload_Click(object sender, System.EventArgs e) { string patchName = "Setup.exe"; string destDir = FormPath.GetPreferredImagePath(); if (destDir == null) //Not using A to Z folders? { destDir = Path.GetTempPath(); } DownloadInstallPatchFromURI(textWebsitePath.Text + textRegMain.Text + "/" + patchName, //Source URI ODFileUtils.CombinePaths(destDir, patchName)); //Local destination file. }
private void butAttach_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; Patient PatCur = Patients.GetPat(MessageCur.PatNum); if (PatCur.ImageFolder != "") { if (PrefB.UsingAtoZfolder) { dlg.InitialDirectory = ODFileUtils.CombinePaths(new string[] { FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1).ToUpper(), PatCur.ImageFolder }); } else { //Use the OS default directory for this type of file viewer. dlg.InitialDirectory = ""; } } if (dlg.ShowDialog() != DialogResult.OK) { return; } Random rnd = new Random(); string newName; EmailAttach attach; string attachPath = GetAttachPath(); if (!Directory.Exists(attachPath)) { Directory.CreateDirectory(attachPath); } try{ for (int i = 0; i < dlg.FileNames.Length; i++) { //copy the file newName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString(); File.Copy(dlg.FileNames[i], ODFileUtils.CombinePaths(attachPath, newName)); //create the attachment attach = new EmailAttach(); attach.DisplayedFileName = Path.GetFileName(dlg.FileNames[i]); attach.ActualFileName = newName; MessageCur.Attachments.Add(attach); } } catch (Exception ex) { MessageBox.Show(ex.Message); } FillAttachments(); }
private string GetAttachPath() { string attachPath; if (PrefB.UsingAtoZfolder) { attachPath = ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), @"EmailAttachments"); } else { //For users which have the A to Z folders disabled, there is no defined image path, so we //have to use another path. Since we have chosen the temporary directory, this means that //email attachements for a particular email may or may not be viewable later (i.e. in case //someone cleaned out their temporary files to conserve disk space). attachPath = Path.GetTempPath(); } return(attachPath); }
private void butStationary_Click(object sender, EventArgs e) { if (PrefB.GetString("StationaryDocument") == "") { MsgBox.Show(this, "You must setup your stationary document and word processor path in Setup | Misc"); return; } Cursor = Cursors.AppStarting; PtLetter_ToClipboard(); try { this.Cursor = Cursors.AppStarting; string patFolder = ODFileUtils.CombinePaths( FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1), PatCur.ImageFolder); //string ProgName = @"C:\Program Files\OpenOffice.org 2.0\program\swriter.exe"; //string ProgName = PrefB.GetString("WordProcessorPath"); string TheFile = ODFileUtils.CombinePaths(patFolder, "Letter_" + DateTime.Now.ToFileTime() + ".doc"); try{ File.Copy( ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), PrefB.GetString("StationaryDocument")), TheFile); DialogResult = DialogResult.OK; } catch { } try { Process.Start(TheFile); } catch { } this.Cursor = Cursors.Default; Commlog CommlogCur = new Commlog(); CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC); CommlogCur.PatNum = PatCur.PatNum; CommlogCur.Note = Lan.g(this, "Letter sent: See Images for this date."); Commlogs.Insert(CommlogCur); } catch { Cursor = Cursors.Default; MsgBox.Show(this, "Cannot find stationary document. Or another problem exists."); } }
///<summary>Called in two places. Once from RefreshLocalData, and also from FormBackups after a restore.</summary> public static bool CheckProgramVersion() { Version storedVersion = new Version(PrefB.GetString("ProgramVersion")); Version currentVersion = new Version(Application.ProductVersion); string database = ""; string command = ""; if (FormChooseDatabase.DBtype == DatabaseType.MySql) { command = "SELECT database()"; DataTable table = General.GetTable(command); database = PIn.PString(table.Rows[0][0].ToString()); } if (storedVersion < currentVersion) { UpdateString("ProgramVersion", currentVersion.ToString()); Prefs.Refresh(); } if (storedVersion > currentVersion) { if (PrefB.UsingAtoZfolder) { string setupBinPath = ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), "Setup.exe"); if (File.Exists(setupBinPath)) { if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n" + "But the database " + database + "\r\n" + "is already using version " + storedVersion.ToString(3) + ".\r\n" + "A newer version must have already been installed on at least one computer.\r\n" + "The setup program stored in your A to Z folder will now be launched.\r\n" + "Or, if you hit Cancel, then you will have the option to download again." , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } Application.Exit(); return(false); } try { Process.Start(setupBinPath); } catch { MessageBox.Show("Could not launch Setup.exe"); } } else if (MessageBox.Show("A newer version has been installed on at least one computer," + "but Setup.exe could not be found in any of the following paths: " + FormPath.GetPreferredImagePath() + ". Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } } else //Not using image path. //perform program update automatically. { string patchName = "Setup.exe"; string updateUri = PrefB.GetString("UpdateWebsitePath"); string registrationCode = PrefB.GetString("RegistrationNumber"); string updateInfoMajor = ""; string updateInfoMinor = ""; if (FormUpdate.ShouldDownloadUpdate(updateUri, registrationCode, out updateInfoMajor, out updateInfoMinor)) { if (MessageBox.Show(updateInfoMajor + Lan.g("Prefs", "Perform program update now?"), "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string tempFile = ODFileUtils.CombinePaths(Path.GetTempPath(), patchName); //Resort to a more common temp file name. FormUpdate.DownloadInstallPatchFromURI(updateUri + registrationCode + "/" + patchName, //Source URI tempFile); //Local destination file. File.Delete(tempFile); //Cleanup install file. } } } Application.Exit(); //always exits, whether launch of setup worked or not return(false); } return(true); }