示例#1
0
 private void tabControl2_SelectedIndexChanged(object sender, EventArgs e)
 {
     tabControl2.TabPages[1].Hide();
     if (tabControl2.SelectedIndex == 1)
     {
         uiWndAdmin adm = new uiWndAdmin();
         adm.StartPosition = FormStartPosition.CenterParent;
         if (DialogResult.OK != adm.ShowDialog())
             tabControl2.SelectTab(0);
         else
         {
             maskedTextBox1.Text = AppConfig.APP_Admin;
             tabControl2.SelectTab(1);
             tabControl2.TabPages[1].Show();
             listBox1.Select();
             listBox1.SelectedIndex = 0;
             listBox1.Invalidate(true);
             //NodePerformClick(treeView1.Nodes[0]);
         }
         adm.Dispose();
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();

            // get arguments
            Hashtable hargs = new Hashtable();
            components.Components.ArgumentParser.Com_ArgumentParser.TransformArguments(hargs, args);

            // load xml settings
            ApplicationConfiguration.CustomConfigurationMethod = CustomConfigurationSettingsContext;
            ApplicationConfiguration.Instance.LoadConfigurationData();

            // load bin settings
            driver.Config.ConfigManager.getInstance();
            if (!driver.Config.ConfigManager.LoadConfiguration())
                return;

            // mode only
            try
            {
                CoreLib.WriteLog(new Exception("Starting service mode for " + hargs["mode"]), "AppStartup (Main)");

                if (hargs.ContainsKey("mode"))
                {
                    // admin verification

                    DialogResult rez = DialogResult.None;
                    PayDesk.Components.UI.uiWndAdmin admin = new uiWndAdmin(FormStartPosition.CenterScreen);
                    rez = admin.ShowDialog();

                    // mode selector with admin
                    if (rez == DialogResult.OK)
                        switch (hargs["mode"].ToString())
                        {
                            case "settings":
                                {
                                    PayDesk.Components.UI.uiWndSettings wnd = new PayDesk.Components.UI.uiWndSettings();
                                    wnd.ShowDialog();
                                    break;
                                }
                            case "printer":
                                {
                                    PayDesk.Components.UI.uiWndPrinting wnd = new PayDesk.Components.UI.uiWndPrinting();
                                    wnd.ShowDialog();
                                    break;
                                }
                            case "billmanager":
                                {
                                    PayDesk.Components.UI.wndBills.uiWndBillManagercs wnd = new PayDesk.Components.UI.wndBills.uiWndBillManagercs();
                                    wnd.ShowDialog();
                                    break;
                                }
                        }

                    admin.Dispose();

                    return;
                }

            }
            catch { }

            ApplicationName = string.Empty;
            //if (args.Length != 0 && args[0] != null && args[0] != string.Empty)
            try
            {
                if (hargs.ContainsKey("app") && hargs["app"].ToString().Length != 0)
                    ApplicationName = args[0];
            }
            catch { }

            //axCfg = ApplicationConfiguration. ("display", @"default/config", (ApplicationName == "" ? "" : ApplicationName + @"/config"), (Program.ApplicationName != string.Empty));

            //MessageBox.Show("wait");

            //appApi = new ApiManager(args);
            /*
            if (!SecureLib.SetGetState(string.Empty))
            {
                Registration reg = new Registration();
                reg.ShowDialog();
                reg.Dispose();
                Environment.Exit(Environment.ExitCode);
            }
            */
            // in futrue move this to mdcore lib
            /* test
            if (MainArgs.ContainsKey("-c") && MainArgs["-c"] != null)
                AppConfig.LoadData(MainArgs["-c"].ToString());
            else
                AppConfig.LoadData();
            test */
            // [a] // AppConfig.LoadData();

            FileMgrLib.VerifyAllFolders();
            CoreLib.WriteLog(new Exception("It is not an error. This message used for tracking of app's startup only."), "AppStartup (Main)");

            // [a] // plugs = new PluginModule.Plugins(AppConfig.Path_Plugins);
            plugs = new Com_PluginManager(driver.Config.ConfigManager.Instance.CommonConfiguration.Path_Plugins);

            //one copy
            System.Threading.Mutex myMutex = null;
            try
            {
                myMutex = System.Threading.Mutex.OpenExisting("PayDeskMutex");
            }
            catch { }
            if (myMutex != null && driver.Config.ConfigManager.Instance.CommonConfiguration.APP_AllowOneCopy)
            {
                MMessageBox.Show("Вже запущена одна копія програми", Application.ProductName);
                Environment.Exit(0);
            }
            else
                myMutex = new System.Threading.Mutex(true, "PayDeskMutex");

            bool active = true;
            do
            {
                active = true;

                uiWndStartupDialog entry = new uiWndStartupDialog();
                active = entry.ShowDialog() == DialogResult.OK;
                entry.Dispose();

                if (!active)
                    break;

                switch (SecureLib.Authorize(entry.Password, entry.Login))
                {
                    case "service":
                        {
                            uiWndService serv = new uiWndService();
                            serv.ShowDialog();
                            serv.Dispose();
                            break;
                        }
                    case "main":
                        {
                            uiWndMain main = new uiWndMain();
                            if (main.ShowDialog() != DialogResult.Retry)
                                active = false;
                            main.Dispose();/*
                            if (Program.MainArgs.ContainsKey("-c") && Program.MainArgs["-c"] != null)
                                AppConfig.SaveData(Program.MainArgs["-c"].ToString());
                            else*/
                            driver.Config.ConfigManager.SaveConfiguration();
                            break;
                        }
                    default: { break; }
                }

            } while (active);

            CoreLib.WriteLog(new Exception("It is not an error. This message used for tracking of app's exit only."), "AppStartup (Main)");

            System.Diagnostics.Process[] prc = System.Diagnostics.Process.GetProcessesByName("vk");
            foreach (System.Diagnostics.Process p in prc)
                p.Kill();
        }
示例#3
0
        /// <summary>
        /// Перевизначений метод для виконання операцій відновлення
        /// інтерфейсу та інших параметрів програми під час її завантаження
        /// </summary>
        /// <param name="e">Event arguments</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            /* initialise data values */
            InitChequeInformationStructure();
            admin = new uiWndAdmin();
            admin.OwnerControlEx = this.chequeDGV;

            //winapi.Funcs.OutputDebugString("load_begin");
            this._fl_isOk = new Com_SecureRuntime().FullLoader();

            //Restore position
            this.Text = string.Format("{2}{1}{0}", Application.ProductName, " - ", ConfigManager.Instance.CommonConfiguration.APP_SubUnitName);
            this.WindowState = ConfigManager.Instance.CommonConfiguration.STYLE_MainWndState;
            this.Location = new Point(ConfigManager.Instance.CommonConfiguration.STYLE_MainWndPosition.X, ConfigManager.Instance.CommonConfiguration.STYLE_MainWndPosition.Y);
            this.Size = new Size(ConfigManager.Instance.CommonConfiguration.STYLE_MainWndSize.Width, ConfigManager.Instance.CommonConfiguration.STYLE_MainWndSize.Height);
            this.splitContainer1.Panel2Collapsed = ConfigManager.Instance.CommonConfiguration.STYLE_ArtSideCollapsed;

            try
            {
                this.splitContainer1.Orientation = ConfigManager.Instance.CommonConfiguration.STYLE_SplitOrient;
                this.splitContainer1.SplitterDistance = ConfigManager.Instance.CommonConfiguration.STYLE_SplitterDistance;
            }
            catch { }
            //updateThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(CheckForUpdate));

            _fl_adminMode = UserConfig.AdminState;

            //create tables

            DataWorkSource.CreateTables(ref Cheque, ref Articles, ref AltBC, ref Cards, ref Cheques);
            this.CreateOrderStructure(this.Cheque);
            if (ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                foreach (DictionaryEntry de in ConfigManager.Instance.CommonConfiguration.PROFILES_Items)
                    this.CreateOrderStructure(this.Cheques.Tables[de.Key.ToString()]);

            // new feature: this.bdo

            chequeDGV.DataSource = Cheque;
            articleDGV.DataSource = Articles;
            DataGridView[] grids = new DataGridView[] { chequeDGV, articleDGV };
            ViewLib.LoadGridsView(ref grids, splitContainer1.Orientation);

            if (ConfigManager.Instance.CommonConfiguration.Path_Exchnage == string.Empty)
            {
                MMessageBoxEx.Show("Вкажіть шлях до папки обміну", Application.ProductName,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop;
                folderBrowserDialog1.ShowDialog();
                ConfigManager.Instance.CommonConfiguration.Path_Exchnage = folderBrowserDialog1.SelectedPath;
                /*
                if (Program.MainArgs.ContainsKey("-c") && Program.MainArgs["-c"] != null)
                    ConfigManager.Instance.CommonConfiguration.SaveData(Program.MainArgs["-c"].ToString());
                else*/
                ConfigManager.SaveConfiguration();
            }

            UpdateMyControls();

            // temporary refresh skins
            Com_WinApi.OutputDebugString("RefershStyles_Start");
            if (ConfigManager.Instance.CommonConfiguration.skin_sensor_active)
            {
                this.сенсорToolStripMenuItem.PerformClick();
            }

            Com_WinApi.OutputDebugString("RefershStyles_End");

            //Set default type of search
            SearchFilter(false, ConfigManager.Instance.CommonConfiguration.APP_SearchType, true);
            UpdateSumInfo(true);

            this.Activate();
            this.BringToFront();
            this.UpdateZOrder();

            if (ConfigManager.Instance.CommonConfiguration.APP_BuyerBarCodeSource != 0)
            {
                // port config

                //Hashtable xmlPortCfg = ComPort.GetXmlPortConfiguration("MagstripeCardReaderPort.xml");
                Hashtable xmlPortCfg = (Hashtable)ApplicationConfiguration.Instance["serialPortConnect.additionalDevices.magstripe"];
                bool error = false;
                try
                {
                    this.serialPort1.PortName = xmlPortCfg["PORT"].ToString();
                    this.serialPort1.BaudRate = int.Parse(xmlPortCfg["RATE"].ToString());
                    this.serialPort1.DataBits = int.Parse(xmlPortCfg["DBITS"].ToString());
                    this.serialPort1.StopBits = (System.IO.Ports.StopBits)(int.Parse(xmlPortCfg["SBITS"].ToString()));
                    this.serialPort1.Parity = (System.IO.Ports.Parity)(int.Parse(xmlPortCfg["PARITY"].ToString()));
                }
                catch (Exception ex)
                {
                    error = true;
                    driver.Lib.CoreLib.WriteLog(ex, "Неможливо налаштувати сом-порт зчитувача карток");
                    MMessageBox.Show("Неможливо налаштувати сом-порт зчитувача карток.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (!error)
                    try
                    {
                        this.serialPort1.Open();
                        this.timer_buyer_ready.Start();
                    }
                    catch (Exception ex)
                    {
                        driver.Lib.CoreLib.WriteLog(ex, "Неможливо відкрити сом-порт зчитувача карток");
                        MMessageBox.Show("Неможливо відкрити сом-порт зчитувача карток.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
            }
            else
            {
                this.timer_buyer_ready.Stop();
            }

            if (Program.AppPlugins.IsActive(PluginType.FPDriver))
            {
                try
                {
                    bool status = (bool)Program.AppPlugins.GetActive<IFPDriver>().CallFunction("FP_SetCashier", ConfigManager.Instance.CommonConfiguration.APP_PayDesk, UserConfig.UserFpLogin, UserConfig.UserFpPassword, UserConfig.UserID);
                    if (status)
                        DDM_FPStatus.Image = Properties.Resources.ok;
                    else
                    {
                        MMessageBoxEx.Show(this.chequeDGV, "Немає зв'язку з фіскальним пристроєм.\r\nНеможливо зареєструвати касира в ЕККР",
                            Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DDM_FPStatus.Image = Properties.Resources.FpNotOk;
                    }
                }
                catch (Exception ex)
                {
                    DDM_FPStatus.Image = Properties.Resources.FpNotOk;
                    driver.Lib.CoreLib.WriteLog(ex, "Немає зв'язку з фіскальним пристроєм.\r\nНеможливо зареєструвати касира в ЕККР");
                    MMessageBoxEx.Show(this.chequeDGV, ex.Message + "\r\nНемає зв'язку з фіскальним пристроєм.\r\nНеможливо зареєструвати касира в ЕККР",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
                DDM_FPStatus.Image = Properties.Resources.FpNotOk;

            this.label_uiWndmain_DemoShowArt.Visible = this.label_uiWndmain_DemoShowChq.Visible = !this._fl_isOk;

            // set additional devices
            //components.Components.SerialPort.

            //global::components.Components.SerialPort.Com_SerialPort.GetAndConfigurePort("scales", (Hashtable)ApplicationConfiguration.Instance["serialPortConnect.additionalDevices.scale"]);
            //WinAPI.OutputDebugString("load_end");
        }
示例#4
0
        /// <summary>
        /// Перевизначений метод для виконання операцій відновлення
        /// інтерфейсу та інших параметрів програми під час її завантаження
        /// </summary>
        /// <param name="e">Event arguments</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            /* initialise data values */

            /* loop by all available profiles */
            if (ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                foreach (DictionaryEntry de in ConfigManager.Instance.CommonConfiguration.PROFILES_Items)
                {
                    this.Discount.Add(de.Key, DataWorkShared.GetStandartDiscountInfoStructure2());
                    this.Summa.Add(de.Key, DataWorkShared.GetStandartCalculationInfoStructure2());
                }
            else
            {
                this.Discount.Add(CoreConst.KEY_DEFAULT_PROFILE_ID, this.PD_DiscountInfo);
                this.Summa.Add(CoreConst.KEY_DEFAULT_PROFILE_ID, DataWorkShared.GetStandartCalculationInfoStructure2());
            }

            admin = new uiWndAdmin();
            admin.OwnerControlEx = this.chequeDGV;

            //winapi.Funcs.OutputDebugString("load_begin");
            this._fl_isOk = new Com_SecureRuntime().FullLoader();

            //Restore position
            this.Text = string.Format("{2}{1}{0}", Application.ProductName, " - ", ConfigManager.Instance.CommonConfiguration.APP_SubUnitName);
            this.WindowState = ConfigManager.Instance.CommonConfiguration.STYLE_MainWndState;
            this.Location = new Point(ConfigManager.Instance.CommonConfiguration.STYLE_MainWndPosition.X, ConfigManager.Instance.CommonConfiguration.STYLE_MainWndPosition.Y);
            this.Size = new Size(ConfigManager.Instance.CommonConfiguration.STYLE_MainWndSize.Width, ConfigManager.Instance.CommonConfiguration.STYLE_MainWndSize.Height);
            this.splitContainer1.Panel2Collapsed = ConfigManager.Instance.CommonConfiguration.STYLE_ArtSideCollapsed;

            try
            {
                this.splitContainer1.Orientation = ConfigManager.Instance.CommonConfiguration.STYLE_SplitOrient;
                this.splitContainer1.SplitterDistance = ConfigManager.Instance.CommonConfiguration.STYLE_SplitterDistance;
            }
            catch { }
            //updateThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(CheckForUpdate));

            ADMIN_STATE = UserConfig.AdminState;

            //create tables

            DataWorkSource.CreateTables(ref Cheque, ref Articles, ref AltBC, ref Cards, ref Cheques);
            this.CreateOrderStructure(this.Cheque);
            if (ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                foreach (DictionaryEntry de in ConfigManager.Instance.CommonConfiguration.PROFILES_Items)
                    this.CreateOrderStructure(this.Cheques.Tables[de.Key.ToString()]);

            // new feature: this.bdo

            chequeDGV.DataSource = Cheque;
            articleDGV.DataSource = Articles;
            DataGridView[] grids = new DataGridView[] { chequeDGV, articleDGV };
            ViewLib.LoadGridsView(ref grids, splitContainer1.Orientation);

            if (ConfigManager.Instance.CommonConfiguration.Path_Exchnage == string.Empty)
            {
                MMessageBoxEx.Show("Вкажіть шлях до папки обміну", Application.ProductName,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop;
                folderBrowserDialog1.ShowDialog();
                ConfigManager.Instance.CommonConfiguration.Path_Exchnage = folderBrowserDialog1.SelectedPath;
                /*
                if (Program.MainArgs.ContainsKey("-c") && Program.MainArgs["-c"] != null)
                    ConfigManager.Instance.CommonConfiguration.SaveData(Program.MainArgs["-c"].ToString());
                else*/
                ConfigManager.SaveConfiguration();
            }

            UpdateMyControls();

            // temporary refresh skins
            Com_WinApi.OutputDebugString("RefershStyles_Start");
            if (ConfigManager.Instance.CommonConfiguration.skin_sensor_active)
            {
                this.сенсорToolStripMenuItem.PerformClick();
            }

            Com_WinApi.OutputDebugString("RefershStyles_End");

            //Set default type of search
            SearchFilter(false, ConfigManager.Instance.CommonConfiguration.APP_SearchType, true);
            UpdateSumInfo(true);

            this.Activate();
            this.BringToFront();
            this.UpdateZOrder();

            if (Program.AppPlugins.IsActive(PluginType.FPDriver))
            {
                try
                {
                    bool status = (bool)Program.AppPlugins.GetActive<IFPDriver>().CallFunction("FP_SetCashier", ConfigManager.Instance.CommonConfiguration.APP_PayDesk, UserConfig.UserFpLogin, UserConfig.UserFpPassword, UserConfig.UserID);
                    if (status)
                        DDM_FPStatus.Image = Properties.Resources.ok;
                    else
                    {
                        MMessageBoxEx.Show(this.chequeDGV, "Неможливо зареєструвати касира в ЕККР",
                            Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DDM_FPStatus.Image = Properties.Resources.FpNotOk;
                    }
                }
                catch (Exception ex)
                {
                    DDM_FPStatus.Image = Properties.Resources.FpNotOk;
                    MMessageBoxEx.Show(this.chequeDGV, ex.Message + "\r\nНеможливо зареєструвати касира в ЕККР",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            } else
                DDM_FPStatus.Image = Properties.Resources.FpNotOk;

            this.label_uiWndmain_DemoShowArt.Visible = this.label_uiWndmain_DemoShowChq.Visible = !this._fl_isOk;

            // set additional devices
            //components.Components.SerialPort.

            //global::components.Components.SerialPort.Com_SerialPort.GetAndConfigurePort("scales", (Hashtable)ApplicationConfiguration.Instance["serialPortConnect.additionalDevices.scale"]);
            //WinAPI.OutputDebugString("load_end");
        }