private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtNew.Text == txtNew2.Text && txtNew.Text.Trim().Length > 5)
            {

                BBLUser bblUser = new BBLUser();
                try
                {
                    if (loggedUser.Password == txtOld.Text.Trim())
                    {
                        loggedUser.Password = txtNew.Text.Trim();

                        bblUser.UpdateUser(loggedUser);

                    }
                    else
                    {
                        MessageBox.Show("Mật khẩu hiện tại không chính xác");
                    }

                    MessageBox.Show("Lưu mật khẩu mới thành công");

                }
                catch (Exception)
                {
                    MessageBox.Show("Lưu thông tin thất bại");
                }
            }
            else {
                MessageBox.Show("Mật khẩu mới không chính xác");
            }
        }
        private void AutoUpdateToServer()
        {
            textBox1.Text = "Starting...\n";

            string baseHost = ConfigurationManager.AppSettings["SERVERURL"];

            string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"];

            try
            {

                //WebRequest request = WebRequest.Create("http://google.com/");
                //request.Timeout =   Timeout.Infinite;
                ////request.KeepAlive = true;
                //HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                //if (response == null || response.StatusCode != HttpStatusCode.OK)
                //{
                //    Console.WriteLine("Hiện không thể kết nối máy chủ. \n Chương trình sẽ chạy với dữ liệu offline cho đến khi có kết nối với máy chủ.\n Hãy kiểm tra kết nối internet và [Thiết lập máy trạm]");
                //}
                //else
                //{
                // Đồng bộ user
                textBox1.Text += "Sync User ...\n";
                BBLUser userData = new BBLUser();
                userData.ServiceUpdate(baseHost);
                textBox1.Text += "Sync user is success n";
                textBox1.Text += "Sync Info ...\n";
                // Đồng bộ Info
                BBLInfo infoData = new BBLInfo();
                infoData.ServiceUpdate(baseHost);
                textBox1.Text += "Sync info is success n";
                textBox1.Text += "Sync client ...\n";
                // Đồng bộ BBLClient
                BBLClient clientData = new BBLClient();
                clientData.ServiceUpdate(baseHost);
                textBox1.Text += "Sync client is success n";
                textBox1.Text += "Sync Consultant ...\n";
                // Đồng bộ BBLConsultant
                BBLConsultant consultantData = new BBLConsultant();
                consultantData.ServiceUpdate(baseHost);
                //}
                textBox1.Text += "finish \n";

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.Source);
                textBox1.Text += "Error " + ex.Message;
            }
        }
Beispiel #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            panelDongBo.Invoke((Action)(() =>
            {
                panelDongBo.Visible = true;
                progressBar1.Value = progressBar1.Minimum;
            }));

            string baseHost = ConfigurationManager.AppSettings["SERVERURL"];

            string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"];

            try
            {
                progressBar1.Invoke((Action)(() => progressBar1.Value = 1));
                worker.ReportProgress(1);
                // Đồng bộ user
                BBLUser userData = new BBLUser();
                userData.ServiceUpdate(baseHost);
                progressBar1.Invoke((Action)(() => progressBar1.Value = 2));
                worker.ReportProgress(2);
                // Đồng bộ Info
                BBLInfo infoData = new BBLInfo();
                infoData.ServiceUpdate(baseHost);
                progressBar1.Invoke((Action)(() => progressBar1.Value = 6));
                worker.ReportProgress(3);
                // Đồng bộ BBLClient
                BBLClient clientData = new BBLClient();
                clientData.ServiceUpdate(baseHost);
                progressBar1.Invoke((Action)(() => progressBar1.Value = 8));
                worker.ReportProgress(4);
                // Đồng bộ BBLConsultant
                BBLConsultant consultantData = new BBLConsultant();
                consultantData.ServiceUpdate(baseHost);
                progressBar1.Invoke((Action)(() => progressBar1.Value = 10));
                worker.ReportProgress(5);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);

            }
        }
        public void UpdateNewsData()
        {
            BBLUser user = new BBLUser();

            var lstUser = user.GetUser();
        }