xiaojiao
昨天 ff8b20f321a8b70ec3bdc208b9f383fd71718108
ÏîÄ¿´úÂë/´òÓ¡»ú/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)
@@ -41,7 +58,7 @@
                //    MessageBox.Show("请输入打印数据", "提示", MessageBoxButtons.OKCancel);
                //    return;
                //}
                Dictionary<string,string> printData = GetInputTxtData();
                Dictionary<string, string> printData = GetInputTxtData();
                //if (printData.Count == 0)
                //{
@@ -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,14 @@
            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 += "'产地':" + $"'{comboBox5.Text}',";
            Row += "}";
            partCode.Add(Txt_barcode1.Text, Row);
@@ -167,11 +195,6 @@
            {
                errorProvider1.SetError(textBox, ""); // æ¸…除错误提示  
                isInputError = false;
            }
            if (comboBox1.Text == "")
            {
                isInputError = true;
            }
        }
@@ -264,11 +287,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);
@@ -352,6 +377,10 @@
                            for (int j = sheet.Dimension.Start.Column, k = sheet.Dimension.End.Column; j <= k; j++)
                            {
                                string tempstr = $"'{sheet.Cells[1, j].Value?.ToString()}':'{sheet.Cells[m, j].Value?.ToString()}',";
                                if (sheet.Cells[m, j].Value == null || sheet.Cells[m, j].Value == "")
                                {
                                    break;
                                }
                                Temp_Row += tempstr;
                                if (j == 1)
                                {
@@ -379,6 +408,11 @@
                                //}
                            }
                            Temp_Row += "}";
                            if (Temp_Row == "{}")
                            {
                                break;
                            }
                            //partCode.Add(Temp_Row);
                            partCode[value] = Temp_Row;
                        }
@@ -518,10 +552,7 @@
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(comboBox1.Text != "")
            {
                isInputError = false;
            }
        }
        private void groupBox2_Enter(object sender, EventArgs e)