Beispiel #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SettingsTsd.USEROLD = textBoxLogin.Text;
            SettingsTsd.SaveSettings();
            btnLogin.Enabled = false;
            //-----------------
            CBrHeader.Login    = textBoxLogin.Text;
            CBrHeader.Password = textBoxPassword.Text;
            //    Thread tr = new Thread(CheckLogin);
            //    tr.Start();
            //Сделаем асинхронный вызов
            WebReference.WebSDataBrCode BrServer = new WebReference.WebSDataBrCode();
            BrServer.SoapVersion   = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
            BrServer.BrHeaderValue = CBrHeader.GetHeader();
            BrServer.Credentials   = new NetworkCredential(CBrHeader.Login, CBrHeader.Password);
            BrServer.Url           = set.AdressAppServer;
            try
            {
                Date  = textBoxDate.Text;
                Smena = DropDownSmena.Items[DropDownSmena.SelectedIndex].ToString();

                BrServer.BeginTest_Login(AsyncCallTestLogin, BrServer);
            }

            catch (WebException ex)
            {
                btnLogin.BeginInvoke(new Action(() =>
                {
                    btnLogin.Enabled = true;
                }));

                string mes = ex.ToString();
                CLog.WriteException("MainWindow", "btnLogin_Click", ex.ToString());
                //MessageBox.Show(ex.ToString());
                if (mes.IndexOf("Unable to connect to the remote server") != -1)
                {
                    MessageBox.Show("Нет соединения с сервером: " + set.AdressAppServer);
                    return;
                }
                else
                {
                    MessageBox.Show("Введите правильный логин или пароль");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                btnLogin.BeginInvoke(new Action(() =>
                {
                    btnLogin.Enabled = true;
                }));

                return;
            }
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();

            DropDownSmena.SelectedIndex = 0;

            set            = new Settings("DataBrCode.xml");
            CLog.DayToSave = set.DayToSaveLog;
            CLog.InitCLog();
            CLog.WriteInfo("DataBrCode", "StartProgram");

            textBoxDate.Text = DateTime.Now.ToString("dd.MM.yy");
            this.KeyPreview  = true;

            //Заполняем поле ввода
            SettingsTsd.ReadSettings();
            textBoxLogin.Text = SettingsTsd.USEROLD;
        }