Exemplo n.º 1
0
        private void DocFileCauHinh()
        {
            try
            {

                XmlDocument XmlDoc = new XmlDocument();
                //Loading the Config file
                XmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
                // XmlDoc.Load("App.config");
                foreach (XmlElement xElement in XmlDoc.DocumentElement)
                {
                    if (xElement.Name == "connectionStrings")
                    {
                        //setting the coonection string
                        var temp = xElement.LastChild.Attributes[1].Value;
                        try
                        {
                            DatabaseHelper help = new DatabaseHelper();
                            if (help.CheckConnection((string)temp) == 0)
                            {
                                frmKetNoi frm = new frmKetNoi();
                                frm.MdiParent = this;
                                // Display the new form.
                                frm.Show();
                            }
                            else
                            {
                                Utilities.clsThamSoUtilities.connectionString = temp;
                                help.CloseDatabase();
                            }//
                        }
                        catch (Exception ex)
                        {

                        }

                    }
                    if (xElement.Name == "appSettings")
                    {
                        bool temp = bool.Parse(xElement.ChildNodes.Item(0).Attributes[1].Value);
                        if (temp == true)
                        {
                            frmDangNhap frm = new frmDangNhap();
                            frm.MdiParent = this;
                            // Display the new form.
                            frm.Show();
                            return;
                        }
                        Utilities.clsThamSoUtilities.isSectionLogin = true;
                    }
                }
                //writing the connection string in config file
                //    XmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                //clsThamSoUtilities.ID_Kho = int.Parse(config.AppSettings.Settings["IDkho"].Value.ToString());
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Chưa cấu hình CSDL! Vui lòng cấu hình hệ thống trước.");
            }
        }
Exemplo n.º 2
0
 private void đăngNhậpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     frmDangNhap frm = new frmDangNhap();
     frm.Name = "Đăng nhập  ";
     frm.Show();
 }