Exemple #1
0
        private void DangNhap()
        {
            SetData();
            _sysConfig.UpdateStartConfig();
            _sysPackage.InitSysvar(drPackage["sysPackageID"].ToString(), drPackage["sysDBID"].ToString());
            //Kiểm tra update
            if (Config.Variables.Contains("UpdatePath"))
            {
                LogFile  log        = new LogFile();
                string   updatePath = Config.GetValue("UpdatePath").ToString();
                DateTime lastUpdate = _sysPackage.LastUpdate();
                string   path       = Application.StartupPath + "\\UpdateDate.txt";
                if (!File.Exists(path))
                {
                    LogFile.CreateFile(path);
                }
                string[] l = File.ReadAllLines(path); //LogFile.readFile(path);
                try
                {
                    if (l.Length == 0)
                    {
                        this.UpdateProgram(updatePath);
                        return;
                    }
                    DateTime curUpdateTime = DateTime.Parse(l[0]);

                    if (curUpdateTime < lastUpdate)
                    {
                        //Cập nhật
                        this.UpdateProgram(updatePath);

                        return;
                    }
                }
                catch { }
            }
            if (radioGroupLanguage.SelectedIndex == 0)
            {
                Localizer.Active        = new DevLocalizer.MyLocalizer();
                GridLocalizer.Active    = new DevLocalizer.MyGridLocalizer();
                ReportLocalizer.Active  = new DevLocalizer.MyReportLocalizer();
                PreviewLocalizer.Active = new DevLocalizer.MyPreviewLocalizer();
            }
            try
            {
                if (Config.GetValue("sysPackageID").ToString() != "5" && Config.GetValue("MaCN") == null)
                {
                    fChonCN fchoncn = new fChonCN();
                    if (fchoncn._dbCN.DsData.Tables[0].Rows.Count != 1)
                    {
                        if (fchoncn.ShowDialog() == DialogResult.Cancel)
                        {
                            this.DialogResult = DialogResult.Cancel;
                            return;
                        }
                    }
                    else if (fchoncn._dbCN.DsData.Tables[0].Rows.Count == 1)
                    {
                        Config.NewKeyValue("MaCN", fchoncn._dbCN.DsData.Tables[0].Rows[0]["MaCN"].ToString());
                    }
                    if (!Config.Variables.Contains("TheoCa"))
                    {
                        Config.NewKeyValue("TheoCa", false);
                    }
                    if (bool.Parse(Config.GetValue("TheoCa").ToString()))
                    {
                        fChonCa fchonca = new fChonCa();
                        if (fchonca._dbCa.DsData.Tables[0].Rows.Count != 1)
                        {
                            if (fchonca.ShowDialog() == DialogResult.Cancel)
                            {
                                this.DialogResult = DialogResult.Cancel;
                                return;
                            }
                        }
                        else if (fchonca._dbCa.DsData.Tables[0].Rows.Count == 1)
                        {
                            Config.NewKeyValue("MaCa", fchonca._dbCa.DsData.Tables[0].Rows[0]["MaCa"].ToString());
                        }
                        else
                        {
                            Config.NewKeyValue("MaCa", null);
                        }
                    }
                    else
                    {
                        Config.NewKeyValue("MaCa", null);
                    }
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
        private void DangNhap()
        {
            SetData();
            _sysConfig.UpdateStartConfig();
            _sysPackage.InitSysvar(drPackage["sysPackageID"].ToString(), drPackage["sysDBID"].ToString());
            //Kiểm tra update
            if (Config.Variables.Contains("UpdatePath"))
            {
                LogFile  log        = new LogFile();
                string   updatePath = Config.GetValue("UpdatePath").ToString();
                DateTime lastUpdate = _sysPackage.LastUpdate();
                string   path       = Application.StartupPath + "\\UpdateDate.txt";
                if (!File.Exists(path))
                {
                    LogFile.CreateFile(path);
                    LogFile.AppendToFile(path, DateTime.Now.ToShortDateString());
                }
                string l = LogFile.readFile(path);
                try
                {
                    DateTime curUpdateTime = DateTime.Parse(l);

                    if (curUpdateTime < lastUpdate)
                    {
                        if (Directory.Exists(updatePath))
                        {
                            LogFile.AppendNewText(path, lastUpdate.ToShortDateString());
                            this.UpdateProgram(updatePath);
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Không tìm thấy thư mục update" + updatePath);
                        }
                    }
                }
                catch { }
            }
            if (radioGroupLanguage.SelectedIndex == 0)
            {
                Localizer.Active        = new DevLocalizer.MyLocalizer();
                GridLocalizer.Active    = new DevLocalizer.MyGridLocalizer();
                ReportLocalizer.Active  = new DevLocalizer.MyReportLocalizer();
                PreviewLocalizer.Active = new DevLocalizer.MyPreviewLocalizer();
            }
            try
            {
                if (Config.GetValue("sysPackageID").ToString() != "5" && Config.GetValue("MaCN") == null)
                {
                    fChonCN fchoncn = new fChonCN();
                    if (fchoncn._dbCN.DsData.Tables[0].Rows.Count != 1)
                    {
                        if (fchoncn.ShowDialog() == DialogResult.Cancel)
                        {
                            this.DialogResult = DialogResult.Cancel;
                            return;
                        }
                    }
                    else if (fchoncn._dbCN.DsData.Tables[0].Rows.Count == 1)
                    {
                        Config.NewKeyValue("MaCN", fchoncn._dbCN.DsData.Tables[0].Rows[0]["MaCN"].ToString());
                    }
                }
                this.DialogResult = DialogResult.OK;
            }
            catch
            {
            }
        }