Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                RegistryKey tmpKey = Registry.CurrentUser.CreateSubKey("Software\\MCS\\InstantMessenger");
                tmpKey.SetValue("InstallPath", Application.ExecutablePath);
            }

            while (!Globals.Exiting)
            {
                frmLogin tmpLogin = new frmLogin();
                Application.Run(tmpLogin);

                string userName = tmpLogin.UserName;
                string passWord = tmpLogin.Password;
                tmpLogin.Close();
                tmpLogin.Dispose();

                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passWord))
                {
                    frmContacts tmpContacts = new frmContacts(userName, passWord);
                    if (tmpContacts.Visible)
                    {
                        Application.Run(tmpContacts);
                    }
                }
                else
                {
                    Application.Exit();
                }
            }
        }
Esempio n. 2
0
        private void btnContacts_Click(object sender, EventArgs e)
        {
            Form frmContacts = new frmContacts();
            DialogResult dlg = frmContacts.ShowDialog();
            if (dlg == DialogResult.OK && txtCompany.Text.Trim() != "")
            {
                Program.DB.AddParameter("Company", txtCompany.Text.Trim());
                DataSet ds = Program.DB.SelectAll("SELECT ID,NameFirst,NameLast FROM Contacts WHERE Company=@Company;");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    AutoCompleteStringCollection asContacts = new AutoCompleteStringCollection();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        asContacts.Add(dr["NameFirst"].ToString() + " " + dr["NameLast"].ToString());
                        if (Convert.ToInt32(dr["ID"]) == SharedData.iContactID)
                        {
                            txtContact.Text = dr["NameFirst"].ToString() + " " + dr["NameLast"].ToString();
                        }
                    }
                    txtContact.AutoCompleteCustomSource = asContacts;
                }

                SharedData.iContactID = 0;
            }
        }