Ejemplo n.º 1
0
        private void btnThord_Click(object sender, EventArgs e)
        {
            if (!checkSignature())
                return;

            bwThord.RunWorkerAsync();

            frmProgress frmProg = new frmProgress("Läser remisser hämtade från Thord...", ref bwThord);
            frmProg.ShowDialog();

            if (bwThord.IsBusy)
                bwThord.CancelAsync();
        }
Ejemplo n.º 2
0
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            Log4Net.Logger.loggInfo("Starting application", Config.User, "frmMain_Load");
            //tabctrlRow.TabPages.Remove(tabpProduction);

            mSavedHeight = this.Height;
            mSavedWidht = this.Width;

            try
            {
                if (bool.Parse(ConfigurationManager.AppSettings["SMS_Enabled"].ToString()))
                    btnSMS.Enabled = true;
                else
                    btnSMS.Enabled = false;
            }
            catch
            {
                btnSMS.Enabled = false;
            }

            // Check if we should we should use ALWAYS UPPERCASE
            if (Config.AlwaysUpperCase)
            {
                txtKlinik.CharacterCasing = CharacterCasing.Upper;
                txtERF.CharacterCasing = CharacterCasing.Upper;
                txtTillagg.CharacterCasing = CharacterCasing.Upper;
                txtOrdination.CharacterCasing = CharacterCasing.Upper;
                txtNotering.CharacterCasing = CharacterCasing.Upper;
            }

            try
            {
                Config.IntPtrGarp = GCS_Process.ProcessActivate.GetCurrentInstanceWindowHandle("Garp");
                Log4Net.Logger.loggInfo("IntPtr of Garp is: " + Config.IntPtrGarp.ToString(), Config.User, "frmMain");
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Error while retriving inptr for Garp", Config.User, "frmMain");
            }

            // CopDoc buttons
            try
            {
                if (Config.getCopDoc.Length > 0)
                {
                    Config.CopDoc[] cd = Config.getCopDoc;

                    foreach (Config.CopDoc c in cd)
                    {
                        if (c.btnIdx == 0)
                        {
                            btnCopDoc1.Enabled = true;
                            btnCopDoc1.Text = c.ButtonText;
                        }
                        else if (c.btnIdx == 1)
                        {
                            btnCopDoc2.Enabled = true;
                            btnCopDoc2.Text = c.ButtonText;
                        }
                    }
                }
                else
                {
                    btnCopDoc1.Enabled = false;
                    btnCopDoc2.Enabled = false;
                }
            }
            catch
            {
                btnCopDoc1.Enabled = false;
                btnCopDoc2.Enabled = false;
            }

            // Add menues for printing
            try
            {
                mnuOrderRow.MenuItems[11].MenuItems.AddRange(Config.getKallelse(new EventHandler(this.printEvent)));
                mnuOrderRow.MenuItems[11].MenuItems.AddRange(Config.getArbetsOrder(new EventHandler(this.printEvent)));
            }
            catch
            {
                MessageBox.Show(this, "Ett fel uppstod när menyalternativ för utskrift lades till", "Fel vid configuration", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            try
            {
                pnlMainLeft.Dock = DockStyle.Left;
                pnlLeft.Dock = DockStyle.Fill;
                grbOr.Tag = "";
                grbOH.Tag = "";
                grbPatient.Tag = "";
                txtONR.Parent = pnlBottom;
                txtKNR.Parent = pnlBottom;
                //lwAidRowsbtnOrderList.Parent = pnlBottom;
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Ett fel uppstod när grbOr skulle initsieras ", Config.User, "frmMain_Load");
            }

            try
            {
                cboProdStatus.Items.Add("");
                cboProdStatus.Items.AddRange(oOR.oProdStat.getListOfReservations());
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Ett fel uppstod när Produktionsstatus skulle initsieras", Config.User, "frmMain_Load");
            }

            // Get list of all handlers and updater combobox in "Details" (Signatures / Salesman i Garp)
            try
            {
                cboHandler.Items.AddRange(oOR.getListOfSalesman());
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Ett fel uppstod när Handläggare skulle initsieras", Config.User, "frmMain_Load");
            }

            try
            {
                cboSignature.Items.AddRange(oOH.getListOfSignatures());
                cboSignature.Items.Add(" ");
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Ett fel uppstod när Signaturer skulle initsieras", Config.User, "frmMain_Load");
            }

            // Get all pricelists
            try
            {
                cboPrislista.Items.AddRange(oPrislista.getPricelists());
                cboPrislista.Items.Add(" ");
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Ett fel uppstod när Prislistor skulle initsieras", Config.User, "frmMain_Load");
            }

            try
            {
                //dtpGilltigFrom.Value = DateTime.ParseExact(DateTime.Today.ToString("yyMMdd"),"yyMMdd",new CultureInfo("sv-SE"));
                dtpLevtid.Value = DateTime.ParseExact(DateTime.Today.ToString("yyMMdd"), "yyMMdd", new CultureInfo("sv-SE"));

            }
            catch { }

            try
            {
                cboAidPriority.Items.Add("");
                cboAidPriority.Items.AddRange(oDelM.getListOfNames());
            }
            catch { }

            // Thordunikt
            if (Config.IsThordUser)
            {
                cboNeedStep.Visible = true;
                label24.Visible = true;
                mnuThord.Visible = true;
                btnThord.Visible = true;
                labRemissNr.Visible = true;
                chkFirstTimePatient.Visible = true;
                Log4Net.Logger.loggInfo("Configure as Thord user", Config.User, "frmMain_Load");
            }
            else
            {
                cboNeedStep.Visible = false;
                label24.Visible = false;
                mnuThord.Visible = false;
                btnThord.Visible = false;
                labRemissNr.Visible = false;
                chkFirstTimePatient.Visible = false;
                Log4Net.Logger.loggInfo("Configure as regulare (not Thord) user", Config.User, "frmMain_Load");
            }

            #if !DEBUG
            frmProgress oProg = new frmProgress("Hämtar ordinatörer, vänta...", ref bwGetOrdinators);
            bwGetOrdinators.RunWorkerAsync();
            oProg.ShowDialog();
            #else
            oOH.getAllOrdinators(true);
            #endif

            try
            {
                this.Text = Application.ProductName + " - " + Application.ProductVersion;

            #if DEBUG
                this.Text += " ### DEBUGMODE ###";
            #endif
            }
            catch
            {
                this.Text = Application.ProductName;
            }

            /**
             * Try to start keboardspy to use multiple clipboard values
             * when switching to Garp
             **/
            try
            {
                keyboardSpy = new KeyboardSpy(Config.User, Config.IntPtrGarp);

                //if (File.Exists(Application.StartupPath + @"\ExternalResources\keyboardspy.exe"))
                //{
                //  pKeyBoardSpy = Process.Start(Application.StartupPath + @"\ExternalResources\keyboardspy.exe");
                //}
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Error when trying to start keyboardspy", Config.User, "frmMain_Load");
            }

            // Show information in statusbar?
            showStatusBar(Config.ShowPreferences);
        }