Exemplo n.º 1
0
        private void btnGenerateCompany_Click(object sender, EventArgs e)
        {
            string dbname = txtCompanyName.Text.Trim().ToUpper();

            string[] bakfile = Directory.GetFiles(Application.StartupPath, "dapro.bak");

            if (!dbname.ISNullOrWhiteSpace())
            {
                if (bakfile.Length >= 1)
                {
                    if (!IsValidDB(dbname))
                    {
                        Cursor = Cursors.WaitCursor;
                        //*************CREATE COMPANY USE CMD *******************
                        //CreateCompanyTools.CreateCompanyUtils(dbname, "dapro.bak",null);
                        //***********************CREATE COMPANY USE C# CODE********************************
                        if (CreateCompanyTools.CreateCompanyDB(dbname))
                        {
                            UpdateApplicationInfo();
                        }
                        Cursor = Cursors.Default;
                    }
                    else
                    {
                        MessageBox.Show("Alredy Exsist..", "Company", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtCompanyName.Select();
                    }
                }
                else
                {
                    MessageBox.Show("Error:> .bak File not avabile.", "Company", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            GetDatabaseName();
        }
Exemplo n.º 2
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string dbname = txtCompanyName.Text.Trim().ToUpper();

            if (!dbname.ISNullOrWhiteSpace())
            {
                //***********Check .bak FIle Alrady Release Folder Exist Or Not/*********
                string[] bakfile = Directory.GetFiles(Application.StartupPath, "dapro.bak");
                if (bakfile.Length >= 1)
                {
                    if (!IsValidDB(dbname))
                    {
                        Cursor = Cursors.WaitCursor;
                        //********Create & Restore database*********
                        //CreateCompanyTools.CreateCompanyUtils(dbname, "dapro.bak", null);
                        //********UpdateConfig Setting*********
                        if (CreateCompanyTools.CreateCompanyDB(dbname))
                        {
                            UpdateAppsConfig(".\\SQLEXPRESS", dbname, "|DataDirectory|\\" + dbname + ".mdf");
                            //********Insert Application Info Table Start Date and Ens Date*********
                            SrverSecurityToolsInsert();
                        }
                        Cursor = Cursors.Default;
                    }
                    else
                    {
                        MessageBox.Show("Alredy Exsist..", "Company", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtCompanyName.Select();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("ERROR:>> .bak file are not available in your application");
                }
                //*******************Comapny window send to back*******************
                pnlCompany.SendToBack();
                //***************Local DB Main Server Connection*******************
                AttaachDB();
            }
            else
            {
                MessageBox.Show("Please Insert Valid Company Name");
            }
            DatabaseDetails();
        }