private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            MdiChildren.Any();
            var currentItems = new List <string>();

            foreach (var item in MdiChildren)
            {
                currentItems.Add(item.Text);
            }

            var genCounter = loginObj.Counters.Where(x => !currentItems.Contains(x.CounterName)).ToList();

            if (genCounter.Count > 0)
            {
                for (int i = 0; i < genCounter.Count; i++)
                {
                    var f = new FrmMain3(genCounter[i]);
                    f.Text      = genCounter[i].CounterName;
                    f.MdiParent = this;
                    f.Show();
                }
            }
            genUserTabFinish = true;

            //check call active
            if (MdiChildren.Any())
            {
                if (this.ActiveMdiChild is IChildMethods)
                {
                    ((IChildMethods)this.ActiveMdiChild).enableTimer();
                }
            }
        }
        private void FrmMainRHM_Load(object sender, EventArgs e)
        {
            lbErrorsms.Caption = "";
            try
            {
                // mo chuc nang cau hinh cho admin
                if (loginObj == null)
                {
                    ribbonPage2.Visible = true;
                }

                try
                {
                    connectString = BaseCore.Instance.GetEntityConnectString(Application.StartupPath + "\\DATA.XML");
                }
                catch (Exception)
                { }
                configs      = BLLConfig.Instance.Gets(connectString, true);
                lib_Services = BLLService.Instance.GetsForMain(connectString);
                int.TryParse(GetConfigByCode(eConfigCode.NumberOfLinePerTime), out so_lien);
                int.TryParse(GetConfigByCode(eConfigCode.PrintType), out printType);
                int.TryParse(GetConfigByCode(eConfigCode.CheckTimeBeforePrintTicket), out CheckTimeBeforePrintTicket);
                int.TryParse(GetConfigByCode(eConfigCode.PrintTicketReturnCurrentNumberOrServiceCode), out printTicketReturnCurrentNumberOrServiceCode);
                int.TryParse(GetConfigByCode(eConfigCode.StartNumber), out startNumber);
                int.TryParse(GetConfigByCode(eConfigCode.UseWithThirdPattern), out UseWithThirdPattern);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Application.StartupPath + "\\DATA.XML");
                foreach (XmlElement element in xmlDoc.DocumentElement)
                {
                    if (element.Name.Equals("AppConfig"))
                    {
                        foreach (XmlNode node in element.ChildNodes)
                        {
                            try
                            {
                                switch (node.Name)
                                {
                                //case "CounterId": numCounterId.Value = (!string.IsNullOrEmpty(node.InnerText) ? Convert.ToInt32(node.InnerText) : 1); break;
                                case "Display": IsUseMainDisplay = Convert.ToBoolean(node.InnerText); break;

                                case "COMDisplay": displaySerialCOM.PortName = node.InnerText; break;

                                case "Print": UsePrintMachine = Convert.ToBoolean(node.InnerText); break;

                                case "COMPrint": printSerialCOM.PortName = node.InnerText; break;

                                //case "PrintCode": numPrinterId.Value = (!string.IsNullOrEmpty(node.InnerText) ? Convert.ToInt32(node.InnerText) : 1); ; break;
                                case "ReadSound": IsReadSound = Convert.ToBoolean(node.InnerText); break;

                                case "SoundPath": soundPath = node.InnerText; break;

                                case "Template": ticketTemplate = node.InnerText; break;

                                case "SoLien": so_lien = (!string.IsNullOrEmpty(node.InnerText) ? Convert.ToInt32(node.InnerText) : 1);; break;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
                if (UsePrintMachine)
                {
                    InitPrintComPort();
                }
                if (loginObj != null && loginObj.Counters != null && loginObj.Counters.Count > 0)
                {
                    // var logins = BLLLoginHistory.Instance.GetsForMain(connectString);
                    // for (int i = 1; i < logins.Count; i++)
                    for (int i = 0; i < loginObj.Counters.Count; i++)
                    {
                        var f = new FrmMain3(loginObj.Counters[i]);
                        f.Text      = loginObj.Counters[i].CounterName;
                        f.MdiParent = this;
                        f.Show();
                    }
                }
                genUserTabFinish = true;

                //check call active
                if (MdiChildren.Any())
                {
                    if (this.ActiveMdiChild is IChildMethods)
                    {
                        ((IChildMethods)this.ActiveMdiChild).enableTimer();
                    }
                }
                playlist = new List <string>();
                temp     = new List <string>();

                //  if (IsUseMainDisplay)
                //    InitDisplayCOMPort();

                serviceIds  = (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ServiceIds"].ToString()) ? ConfigurationManager.AppSettings["ServiceIds"].ToString() : "1,2,3,4,5,6").Split(',').Select(x => Convert.ToInt32(x)).ToList();
                serviceObjs = BLLService.Instance.GetLookUp(connectString, false);
                serviceObjs = serviceObjs.Where(x => serviceIds.Contains(x.Id)).ToList();
            }
            catch (Exception ex)
            {
            }
        }