Example #1
0
        private void loginFun()
        {
            //禁用按钮
            loginBtn.Text    = "登录中...";
            loginBtn.Enabled = false;


            string username = userName.Text;
            string password = passWord.Text;

            //WriteMessage(GetFunction(username, MD5Encrypt32(password)));
            if (username == "" || password == "")
            {
                MessageBox.Show("账号或密码不能为空", "错误");
                //启用按钮
                loginBtn.Enabled = true;
                loginBtn.Text    = "登录";
                return;
            }
            //保存账号密码
            JToken t = Util.LoadConfig();

            t["username"] = username;
            t["password"] = password;
            System.IO.File.WriteAllText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\localConfig.ini", t.ToString(), Encoding.UTF8);
            //提交验证
            string res = Util.LoginFunction(server, username, Util.MD5Encrypt32(password));

            Console.WriteLine(res);
            JObject json = (JObject)JsonConvert.DeserializeObject(res);

            if (json["code"].ToString() == "-1")
            {
                MessageBox.Show("账号密码错误", "错误");
                //启用按钮
                loginBtn.Enabled = true;
                loginBtn.Text    = "登录";
            }
            else
            {
                //隐藏登录框并显示主界面

                this.Visible = false;
                Preview preview = new Preview(res);
                preview.ShowDialog();
            }
            //隐藏登录框并显示界面
            //this.Visible = false;
            //Preview preview = new Preview();
            //preview.ShowDialog();
        }
Example #2
0
        private void btnConfigurationSave_Click(object sender, EventArgs e)
        {
            var path = @"Config\\app.config";

            string[] config_file = File.ReadAllLines(path);

            var new_value_line1 = textBoxCameraIP1.Text
                                  + "×" + textBoxCameraPort1.Text
                                  + "×" + textBoxCameraUsername1.Text
                                  + "×" + textBoxCameraPassword1.Text
                                  + "×" + textBoxCameraChannel1.Text
                                  + "×" + comboBoxCameraStatus1.SelectedItem;

            config_file[1 - 1] = new_value_line1;

            var new_value_line2 = textBoxCameraIP2.Text
                                  + "×" + textBoxCameraPort2.Text
                                  + "×" + textBoxCameraUsername2.Text
                                  + "×" + textBoxCameraPassword2.Text
                                  + "×" + textBoxCameraChannel2.Text
                                  + "×" + comboBoxCameraStatus2.SelectedItem;

            config_file[2 - 1] = new_value_line2;

            var new_value_line3 = textBoxCameraIP3.Text
                                  + "×" + textBoxCameraPort3.Text
                                  + "×" + textBoxCameraUsername3.Text
                                  + "×" + textBoxCameraPassword3.Text
                                  + "×" + textBoxCameraChannel3.Text
                                  + "×" + comboBoxCameraStatus3.SelectedItem;

            config_file[3 - 1] = new_value_line3;

            var new_value_line4 = textBoxCameraIP4.Text
                                  + "×" + textBoxCameraPort4.Text
                                  + "×" + textBoxCameraUsername4.Text
                                  + "×" + textBoxCameraPassword4.Text
                                  + "×" + textBoxCameraChannel4.Text
                                  + "×" + comboBoxCameraStatus4.SelectedItem;

            config_file[4 - 1] = new_value_line4;

            var new_value_line5 = textBoxCameraIP5.Text
                                  + "×" + textBoxCameraPort5.Text
                                  + "×" + textBoxCameraUsername5.Text
                                  + "×" + textBoxCameraPassword5.Text
                                  + "×" + textBoxCameraChannel5.Text
                                  + "×" + comboBoxCameraStatus5.SelectedItem;

            config_file[5 - 1] = new_value_line5;

            var new_value_line7 = comboBoxBaudRate.SelectedItem
                                  + "×" + comboBoxDataBits.SelectedItem
                                  + "×" + comboBoxParityBits.SelectedItem
                                  + "×" + comboBoxStopBits.SelectedItem;

            config_file[7 - 1] = new_value_line7;

            var new_value_line9 = textBoxTareWeight.Text;

            config_file[9 - 1] = new_value_line9;

            File.WriteAllLines(path, config_file);
            MessageBox.Show("Changes Saved Successully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

            Preview formPreview = (Preview)Application.OpenForms["Preview"];

            formPreview.config();

            Preview formPreview2 = (Preview)Application.OpenForms["Preview"];
            Preview formPreview3 = (Preview)Application.OpenForms["Preview"];
            Preview formPreview4 = (Preview)Application.OpenForms["Preview"];
            Preview formPreview5 = (Preview)Application.OpenForms["Preview"];

            if (comboBoxCameraStatus1.Text == "ON")
            {
                formPreview.camera1_on();
            }

            if (comboBoxCameraStatus1.Text == "OFF")
            {
                formPreview.camera1_off();
            }

            if (comboBoxCameraStatus2.Text == "ON")
            {
                formPreview2.camera2_on();
            }

            if (comboBoxCameraStatus2.Text == "OFF")
            {
                formPreview2.camera2_off();
            }

            if (comboBoxCameraStatus3.Text == "ON")
            {
                formPreview3.camera3_on();
            }

            if (comboBoxCameraStatus3.Text == "OFF")
            {
                formPreview3.camera3_off();
            }

            if (comboBoxCameraStatus4.Text == "ON")
            {
                formPreview4.camera4_on();
            }

            if (comboBoxCameraStatus4.Text == "OFF")
            {
                formPreview4.camera4_off();
            }

            if (comboBoxCameraStatus5.Text == "ON")
            {
                formPreview5.camera5_on();
            }

            if (comboBoxCameraStatus5.Text == "OFF")
            {
                formPreview5.camera5_off();
            }

            this.Close();
        }
Example #3
0
 public VoiceTalk(Preview parent)
 {
     this.parent = parent;
     InitializeComponent();
 }