Example #1
0
 /// <summary>
 /// 生成打印报表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click(object sender, EventArgs e)
 {
     if (MainFrom.textB_CgqData_Form == null || MainFrom.textB_HbData_Form == null || MainFrom.comBoxData_Form == null)
     {
         MessageBox.Show("请先保存设备属性值,再进行打印操作");
         return;
     }
     Export_All_SY.Exp_PDF(0);
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ////////////////////////////////////////////////////////////////////////
            //得到产品型号
            Cp_no   = this.comboBox1.Text;
            Kzx_no  = this.textBox1.Text; //滑板控制箱编号
            Cgq_no  = this.textBox2.Text; //角度传感器编号
            Czy     = this.textBox3.Text; //操作员
            Sy_date = this.comboBox2.Text + this.comboBox3.Text + this.comboBox4.Text;
            date    = this.comboBox2.Text + "-" + this.comboBox3.Text + "-" + this.comboBox4.Text;
            Sycs    = this.textBox4.Text;
            //判断以哪种方式进行查询
            if (this.radioButton1.Checked)
            {
                flag = 1;//表示以文档形式查询
            }
            if (this.radioButton2.Checked)
            {
                flag = 2;//表示以数据库查询
            }
            //if (Cp_no == "" || Kzx_no == "" || Czy == "" || Cgq_no == "" || Sy_date == "" || Sycs == "" || flag == 0)
            //{
            //    MessageBox.Show("请完整填写查询属性,再保存参数!!!");
            //    return;
            //}
            if (flag == 2)
            {
                if (Cp_no == "" || Kzx_no == "" || Czy == "" || Cgq_no == "" || Sy_date == "" || flag == 0)
                {
                    MessageBox.Show("请完整填写查询属性,可以不填实验次数,再保存参数!!!");
                    return;
                }
                SY_Data data = new SY_Data(Cp_no, Kzx_no, Cgq_no, Czy, date);
                Export_All_SY.getCount(data);
                if (Export_All_SY.count == 1)
                {
                    this.label11.Text = "您在" + date + "没有做任何实验,请选择查询其它日期";
                }
                else
                {
                    this.label11.Text = "您在" + date + "一共做了" + (Export_All_SY.count - 1) + "次实验,请在上方文本框中输入您要查询哪一次实验";
                }
            }
            else
            {
                this.label11.Text = "";
            }
            ////////////////////////////////////////////////////////////////////////////////
            int f = 0;

            //判断以哪种方式进行查询
            if (this.radioButton1.Checked)
            {
                f = 1;//表示以文档形式查询
            }
            if (this.radioButton2.Checked)
            {
                f = 2;//表示以数据库查询
            }

            if (Cp_no != this.comboBox1.Text || Kzx_no != this.textBox1.Text ||
                Cgq_no != this.textBox2.Text || Czy != this.textBox3.Text ||
                Sy_date != (this.comboBox2.Text + this.comboBox3.Text + this.comboBox4.Text) ||
                Sycs != this.textBox4.Text || flag != f)
            {
                MessageBox.Show("您修改了参数但没有保存,请先保存参数,再进行查询!!!");
                return;
            }
            //FolderBrowserDialog openFileDialog = new FolderBrowserDialog();
            if (flag == 1)
            {
                Boolean  isFile = false;
                string[] com    = Cp_no.Split('/');
                string   p_no   = "";
                for (int k = 0; k < com.Length; k++)
                {
                    p_no = p_no + com[k];
                }
                //获得要查询的文件名
                FileName[0] = Sycs;
                FileName[1] = p_no;
                FileName[2] = Kzx_no;
                FileName[3] = Czy;
                FileName[4] = Cgq_no;
                FileName[5] = Sy_date;
                //DialogResult result = openFileDialog.ShowDialog();
                string hz = "pdf";
                //文件查询
                //if (result == DialogResult.OK)
                //{
                //DirectoryInfo dir = new DirectoryInfo(openFileDialog.SelectedPath);
                DirectoryInfo dir      = new DirectoryInfo(StrPath);
                FileInfo[]    fileInfo = dir.GetFiles();
                foreach (FileInfo item in fileInfo)
                {
                    int    flag     = 1;
                    string fileName = item.Name;
                    if (fileName.Substring(fileName.LastIndexOf(".") + 1) == hz)
                    {
                        string[] fname = fileName.Split('_');
                        if (fname.Length != 6)
                        {
                            continue;
                        }
                        for (int h = 0; h < 5; h++)
                        {
                            if (FileName[h] != "")
                            {
                                if (FileName[h] != fname[h])
                                {
                                    flag = 0;
                                }
                            }
                        }
                        if (FileName[5] != "")
                        {
                            if (!fname[5].Contains(FileName[5]))
                            {
                                flag = 0;
                            }
                        }
                        if (flag == 1)
                        {
                            //加判断条件
                            if (MessageBox.Show("确定打开?" + StrPath + "\\" + item.Name, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                            {
                                MessageBox.Show("正在打开" + StrPath + "\\" + item.Name);
                                Process.Start("explorer", StrPath + item.Name);
                            }
                            //MessageBox.Show("正在打开" + StrPath + "\\" + item.Name);
                            //Process.Start("explorer", StrPath + item.Name);
                            isFile = true;      //判断是否查询到文件
                        }
                    }
                }
                if (!isFile)
                {
                    MessageBox.Show("未查询到文件,重新试验或进一步查询!!!");
                }
                //}
            }
            else
            {
                if (Cp_no == "" || Kzx_no == "" || Czy == "" || Cgq_no == "" || Sy_date == "" || Sycs == "" || flag == 0)
                {
                    MessageBox.Show("请完整填写查询属性,再进行查询!!!");
                    return;
                }
                state = 0;
                getState();
                if (state == 0)
                {
                    MessageBox.Show("没有查到任何数据");
                    return;
                }
                //数据库查询,并生成文件
                Export_All_SY.Exp_PDF(1);
            }
        }