示例#1
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            f_capnhat_db();//
            try
            {
                m = new LibMedi.AccessData();
                groLogin.BringToFront();
                groLicense.Visible = false;
                bool bQuanLyLicense = m.QuanLyLicense;
                if (bQuanLyLicense)
                {
                    m.RegisterDateStart();
                    if (m.DaDangKiLicense == false)
                    {
                        string   s_NgayHeThong  = m.ngayhienhanh_server;
                        DateTime dtNgayHeThong  = m.StringToDate(s_NgayHeThong);
                        string   s_NgayBatDau   = m.RegisterGetDateStart;
                        DateTime dtNgayBatDau   = m.StringToDate(s_NgayBatDau.Substring(0, 10));
                        TimeSpan tp             = dtNgayHeThong - dtNgayBatDau;
                        int      i_SoNgayConLai = tp.Days;
                        txtKey.Text        = Medisoft2009.MACAddress.MedisoftMAC.KeyInfo;
                        groLicense.Visible = true;
                        groLicense.BringToFront();
                        bChuaDangKiLicense = true;
                        if (i_SoNgayConLai <= 30)
                        {
                            lblLicense.Text = "Hệ thống chưa được đăng ký bản quyền sử dụng. " +
                                              "Hãy copy key bên dưới gởi cho quản trị hệ thống." +
                                              "\nBạn chỉ có " + (30 - i_SoNgayConLai).ToString() + " ngày dùng thử";
                        }
                        else
                        {
                            lblLicense.Text = "Hệ thống chưa được đăng ký bản quyền sử dụng. " +
                                              "Hãy copy key bên dưới gởi cho quản trị hệ thống." +
                                              "\nBạn đã hết số ngày dùng thử";
                            butTiepTuc.Enabled = false;
                            groLogin.Enabled   = false;
                        }
                    }
                    else
                    {
                        groLogin.Enabled   = true;
                        bChuaDangKiLicense = false;
                        this.Width         = 292;
                        this.Height        = 146;
                    }
                }
                else
                {
                    this.Width  = 292;
                    this.Height = 146;
                }
                try
                {
                    bool update = m_v.bAutoupdate && m_v.Path_medisoft != "";
                    if (update)
                    {
                        string file = "Vienphi", path = m_v.Path_medisoft + "\\" + file + "\\bin\\debug";
                        if (!m_v.bUpdate(System.IO.Directory.GetCurrentDirectory(), path, file))
                        {
                            m_v.writeXml("thongso", "version", "Version " + m_v.f_modify(m_v.file_exe(path, file)));
                            m_v.writeXml("thongso", "file", file);
                            m_userid_off = "";
                            Application.Exit();
                            string filerun = @m_v.path_medisofthis() + "\\version\\bin\\debug\\version.exe";
                            run    f       = new run(filerun);
                            f.Launch();
                        }
                    }
                }
                catch
                {
                }

                if (m_userid_off != "")
                {
                    foreach (DataRow r in m_v.f_get_v_dlogin(m_userid_off, "", "", "", "").Tables[9].Rows)
                    {
                        txtUsername.Text = r["username"].ToString();
                        break;
                    }
                }
            }
            catch
            {
            }
            //if (m_v.get_data("select * from medibv.thongso where id=-2").Tables[0].Rows.Count > 0)
            //    f_Check_License();///Dung license
            //else
            //    f_Uncheck_License();//Khong dung license
        }