Пример #1
0
        private void locationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Location_setting_Form frm = new Location_setting_Form();

            frm.MdiParent = this;
            frm.Show();
        }
Пример #2
0
        private void Parent_Form_Load(object sender, EventArgs e)
        {
            try
            {
                if (!File.Exists(@"..\loc.txt"))
                {
                    File.Create(@"..\loc.txt");
                    SqlHelper.Global_Location_String = File.ReadAllText(@"..\loc.txt");
                }
                else if (File.Exists(@"..\loc.txt"))
                {
                    SqlHelper.Global_Location_String = File.ReadAllText(@"..\loc.txt");
                }

                if (!File.Exists(@"..\constr.txt"))
                {
                    File.Create(@"..\constr.txt");
                    SqlHelper.Global_Connection_String = File.ReadAllText(@"..\constr.txt");
                }
                else if (File.Exists(@"..\constr.txt"))
                {
                    SqlHelper.Global_Connection_String = File.ReadAllText(@"..\constr.txt");
                }


                if (SqlHelper.Global_Connection_String == "")
                {
                    Connection__String_from frm = new Connection__String_from();
                    frm.MdiParent = this;
                    frm.Show();
                    groupBox1.Hide();
                }


                if (SqlHelper.Global_Location_String == "")
                {
                    Location_setting_Form frm = new Location_setting_Form();
                    frm.MdiParent = this;
                    frm.Show();
                    groupBox1.Hide();
                }

                entryToolStripMenuItem.Visible         = false;
                reportsToolStripMenuItem.Visible       = false;
                adminControlsToolStripMenuItem.Visible = false;

                if (SqlHelper.Global_Connection_String != "")
                {
                    try
                    {
                        SqlHelper helper = new SqlHelper(SqlHelper.Global_Connection_String);

                        if (helper.IsConnect)
                        {
                            con = new SqlConnection(SqlHelper.Global_Connection_String);
                            AppSettings setting = new AppSettings();
                            setting.saveConnectionString("ConnectionString", SqlHelper.Global_Connection_String);
                            var DS1 = new Vehical_Entry_RecordDataSetTableAdapters.Report_QueryTableAdapter();
                            DS1.Connection.ConnectionString = SqlHelper.Global_Connection_String;

                            SqlCommand cmd = new SqlCommand("Count_Vehical", con);
                            cmd.CommandType = CommandType.StoredProcedure;
                            SqlDataAdapter da  = new SqlDataAdapter(cmd);
                            DataTable      dty = new DataTable();
                            da.Fill(dty);
                            label6.Text = dty.Rows.Count.ToString();
                        }

                        else
                        {
                            Connection__String_from frm = new Connection__String_from();
                            frm.MdiParent = this;
                            frm.Show();
                            groupBox1.Hide();
                        }
                    }
                    catch (Exception ex)
                    {
                        groupBox1.Hide();
                        MessageBox.Show("Connection Error");

                        MessageBox.Show(ex.Message);
                    }
                }
            }
            catch (Exception)
            {
                groupBox1.Hide();
                MessageBox.Show("Software Updated Its Environment On New PC. Please Restart Again");
            }
        }