xiaojiao
7 天以前 b532ba8806996246ab7a0896bf34b884c47dee7e
ÏîÄ¿´úÂë/´òÓ¡»ú/WindowsFormsApp6/WindowsFormsApp6/Form1.cs
@@ -28,6 +28,23 @@
            InitializeComponent();
            // æ–°å¢žè¿™è¡Œï¼šè®¾ç½®EPPlus的许可证上下文
            ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
            try
            {
                // è¯»å–文件所有行
                string[] lines = System.IO.File.ReadAllLines("D:\\打印机车型轴承品牌下拉框文件夹\\车型.txt");
                string[] lines2 = System.IO.File.ReadAllLines("D:\\打印机车型轴承品牌下拉框文件夹\\轴承型号.txt");
                string[] lines3 = System.IO.File.ReadAllLines("D:\\打印机车型轴承品牌下拉框文件夹\\轴承品牌.txt");
                // æ·»åŠ åˆ°ä¸‹æ‹‰æ¡†
                this.comboBox3.Items.AddRange(lines2);
                this.comboBox2.Items.AddRange(lines);
                this.comboBox4.Items.AddRange(lines3);
            }
            catch (Exception ex)
            {
                // è¯»å–失败时提示
                MessageBox.Show("读取文件失败:" + ex.Message);
            }
        }
        private void btn_print_Click(object sender, EventArgs e)
@@ -49,12 +66,21 @@
                //    return;
                //}
                if (isInputError)
                {
                    MessageBox.Show("输入数据有误或者不完整,请先检查后再打印", "提示", MessageBoxButtons.OK);
                    return;
                }
                // è¿™é‡Œåšä¸‹æ‹‰æ¡†çš„绑定
                if (comboBox1.Text == "" || comboBox2.Text == ""
                    || comboBox3.Text == "" || comboBox4.Text == ""
                    || textBox1.Text.Trim() == "" || textBox3.Text.Trim() == "")
                {
                    MessageBox.Show("输入数据有误或者不完整,请先检查后再打印", "提示", MessageBoxButtons.OK);
                    return;
                }
                //string MFile = ReportPath + "\\FRX\\wl.frx";//FastReport设计后的文件保存的路径。
                // æ›¿æ¢åŽŸæ¥çš„ string MFile = ReportPath + "\\FRX\\wl.frx";
                string MFile = Path.Combine(ReportPath, "FRX", "wl.frx");
@@ -138,12 +164,13 @@
            string Row = "{";
            Row += "'轴承条码':"+$"'{Txt_barcode1.Text}',";
            Row += "'车型':"+$"'{Txt_barcode2.Text}',";
            Row += "'轴承型号':"+$"'{Txt_barcode3.Text}',";
            Row += "'厂家':"+$"'{Txt_barcode4.Text}',";
            Row += "'车型':"+$"'{comboBox2.Text}',";
            Row += "'轴承型号':"+$"'{comboBox3.Text}',";
            Row += "'轴承品牌':"+$"'{comboBox4.Text}',";
            Row += "'轴承类别':"+$"'{comboBox1.Text}',";
            Row += "'轴承单号':"+$"'{Txt_barcode6.Text}',";
            Row += "'轴承批次号':"+$"'{textBox1.Text}',";
            Row += "'轴承重量':" + $"'{textBox2.Text}',";
            Row += "'日期':" + $"'{textBox3.Text}',";
            Row += "}";
            partCode.Add(Txt_barcode1.Text, Row);
@@ -167,11 +194,6 @@
            {
                errorProvider1.SetError(textBox, ""); // æ¸…除错误提示  
                isInputError = false;
            }
            if (comboBox1.Text == "")
            {
                isInputError = true;
            }
        }
@@ -264,11 +286,13 @@
        {
            //载入时为每个输入框 è®¢é˜…文本校验事件
            Txt_barcode1.Validating += new CancelEventHandler(Validaltetion);
            Txt_barcode2.Validating += new CancelEventHandler(Validaltetion);
            Txt_barcode3.Validating += new CancelEventHandler(Validaltetion);
            Txt_barcode4.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode2.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode3.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode4.Validating += new CancelEventHandler(Validaltetion);
            textBox1.Validating += new CancelEventHandler(Validaltetion);
            textBox2.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode5.Validating += new CancelEventHandler(ValidateTextBox);
            Txt_barcode6.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode6.Validating += new CancelEventHandler(Validaltetion);
            //Txt_barcode7.Validating += new CancelEventHandler(ValidateTextBox);
            //Txt_barcode8.Validating += new CancelEventHandler(ValidateTextBox);
            //Txt_barcode9.Validating += new CancelEventHandler(ValidateTextBox);
@@ -518,10 +542,7 @@
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(comboBox1.Text != "")
            {
                isInputError = false;
            }
        }
        private void groupBox2_Enter(object sender, EventArgs e)