示例#1
0
        private void btnSaveCommand_Click(object sender, RoutedEventArgs e)
        {
            txtLogMessage.Foreground = new SolidColorBrush(Colors.Red);
            if (txtCommand.Text == "" || txtCommandTitle.Text == "")
            {
                txtLogMessage.Text = "内容为空,请正确输入!";
                return;
            }
            if (txtCommandExplain.Text == "")
            {
                txtCommandExplain.Text = txtCommandTitle.Text;
            }
            string data = txtCommand.Text + ';' + txtCommandTitle.Text + ';' + txtCommandExplain.Text + ';';

            if (line == -1)
            {
                if (btnSelectSGD.IsChecked == true)
                {
                    FileTools.WriteLineFile(FileTools.commandPath + "\\commandSGD.txt", data);
                }
                if (btnSelectZPL.IsChecked == true)
                {
                    FileTools.WriteLineFile(FileTools.commandPath + "\\commandZPL.txt", data);
                }
            }
            else if (line >= 0)
            {
                if (btnSelectSGD.IsChecked == true)
                {
                    FileTools.CoverLine(FileTools.commandPath + "\\commandSGD.txt", data, line);
                }
                if (btnSelectZPL.IsChecked == true)
                {
                    FileTools.CoverLine(FileTools.commandPath + "\\commandZPL.txt", data, line);
                }
            }
            if (line >= 0)
            {
                this.Close();
            }
            txtLogMessage.Text = "保存成功!";
            if (txtLogMessage.Text == "保存成功!")
            {
                txtLogMessage.Foreground = new SolidColorBrush(Colors.Green);
            }
        }
        private void SavaRelationRecordClick(object sender, RoutedEventArgs e)
        {
            if (EE_Number_TextBox.Text == "" || Template_TextBox.Text == "")
            {
                return;
            }
            string data = EE_Number_TextBox.Text + ';' + Template_TextBox.Text + ';' + Printer_ComboBox.Text + ';';

            if (line == -1)             //添加记录
            {
                FileTools.WriteLineFile(FileTools.relationFilePath, data);
            }
            else if (line >= 0)              //修改记录
            {
                FileTools.CoverLine(FileTools.relationFilePath, data, line);
            }

            this.DialogResult = true;
            this.Close();
        }