private void 导出txt出货状况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //选择导出文件路径及名称
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title      = label1.Text;
            sfd.Filter     = "报表类型|*.txt";
            sfd.DefaultExt = "txt";
            sfd.ShowDialog();
            string str1 = sfd.FileName;

            if (str1 != "")
            {
                //利用FileWriter写入txt
                FileStream   fs = new FileStream(str1, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(fs);

                ArrayList al = cx.searchAllNode("chuHuo.xml", "outhere");


                if (al.Count > 0)
                {
                    sw.WriteLine("品种".PadRight(8) + "型号".PadRight(8) + "进价".PadRight(8) + "标价".PadRight(8) + "出货价".PadRight(8) + "编号".PadRight(8) + "数目".PadRight(8));
                    for (int i = 0; i < al.Count; i++)
                    {
                        storeFur stf1 = new storeFur();
                        stf1 = al[i] as storeFur;
                        stf1.ziBuqi();
                        sw.WriteLine(stf1.variety + stf1.number + stf1.inprice + stf1.onprice + stf1.outprice + stf1.date + " " + stf1.shumu);
                    }
                }
                sw.Close();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //判断输入数据是否正常
            if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "" && textBox4.Text == "" && textBox5.Text == "" && textBox6.Text == "")
            {
                MessageBox.Show("信息不完善");
                return;
            }
            try
            {
                float.Parse(textBox3.Text);
                float.Parse(textBox4.Text);
            }
            catch
            {
                MessageBox.Show("价格必须是一个数字");
                return;
            }
            if (targetXML == "出货记录")
            {
                try
                {
                    float.Parse(textBox5.Text);
                }
                catch
                {
                    MessageBox.Show("价格必须是一个数字");
                    return;
                }
            }
            //将添加的值加入xml文件中
            cmdXML cx = new cmdXML();

            string[] str1  = { textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, stf.date, textBox6.Text };
            storeFur stf_l = new storeFur(str1);
            //告诉主对话框刷新datagridview
            Form1 fm1 = (Form1)this.Owner;

            switch (targetXML)
            {
            case "库存状况":
                cx.updateSingleNode("mainStore.xml", "store", stf.date, stf_l);
                fm1.formRefresh("mainStore.xml", "store");
                break;

            case "进货记录":
                cx.updateSingleNode("jinHuo.xml", "inhere", stf.date, stf_l);
                fm1.formRefresh("jinHuo.xml", "inhere");
                break;

            case "出货记录":
                cx.updateSingleNode("chuHuo.xml", "outhere", stf.date, stf_l);
                fm1.formRefresh("chuHuo.xml", "outhere");
                break;
            }
            //关闭对话框
            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //判断输入数据是否正常
            if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "" && textBox4.Text == "")
            {
                MessageBox.Show("信息不完善");
                return;
            }
            try
            {
                float.Parse(textBox3.Text);
                float.Parse(textBox4.Text);
            }
            catch
            {
                MessageBox.Show("价格必须是一个数字");
                return;
            }

            try
            {
                int.Parse(textBox6.Text);
            }
            catch
            {
                MessageBox.Show("数目必须是个整数");
                return;
            }
            //将添加的值加入库存xml中
            string[] str1 = { textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, System.DateTime.Now.ToString("yyyyMMddHHmmssfff"), Convert.ToString(textBox6.Text) };
            storeFur stf  = new storeFur(str1);


            cmdXML cx = new cmdXML();

            //进货记录添加
            cx.AddFurElement("jinHuo.xml", stf, "inhere");
            //库存状况更新
            cx.hebingSingleNode("mainStore.xml", "store", stf);
            //告诉主对话框刷新datagridview
            Form1 fm1 = (Form1)this.Owner;

            fm1.formRefresh("mainStore.xml", "store");
            //关闭对话框
            this.Close();
        }
 //查询定义匹配函数
 public bool pipeiStore(storeFur stf, string[] str)
 {
     //满足所有匹配项目返回true,否则返回false
     if ((stf.variety == str[0] || str[0] == "strnouse") &&
         (stf.number == str[1] || str[1] == "strnouse") &&
         ((str[2] == "strnouse") ||
          ((float.Parse(stf.inprice) >= float.Parse(str[2])) &&
           (float.Parse(stf.inprice) <= float.Parse(str[3])))) &&
         ((str[4] == "strnouse") ||
          ((float.Parse(stf.onprice) >= float.Parse(str[4])) &&
           (float.Parse(stf.onprice) <= float.Parse(str[5])))) &&
         ((str[6] == "strnouse") ||
          ((float.Parse(stf.outprice) >= float.Parse(str[6])) &&
           (float.Parse(stf.outprice) <= float.Parse(str[7]))))
         )
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        //将数据库中的数据刷新到datagridview上
        public void formRefresh(string xmlName, string rootName)
        {
            //总成本、利润及库存
            double totalin, totalout, totalon1, totalon2;
            //通过mainstore.xml刷新datagridview的值
            ArrayList al = cx.searchAllNode(xmlName, rootName);

            dataGridView1.Rows.Clear();
            if (al.Count > 0)
            {
                dataGridView1.Rows.Add(al.Count);
                for (int i = al.Count - 1; i >= 0; i--)
                {
                    storeFur stf1 = new storeFur();
                    stf1 = al[al.Count - 1 - i] as storeFur;
                    dataGridView1.Rows[i].Cells[0].Value = stf1.variety;
                    dataGridView1.Rows[i].Cells[1].Value = stf1.number;
                    dataGridView1.Rows[i].Cells[2].Value = stf1.inprice;
                    dataGridView1.Rows[i].Cells[3].Value = stf1.onprice;
                    dataGridView1.Rows[i].Cells[4].Value = stf1.outprice;
                    dataGridView1.Rows[i].Cells[5].Value = stf1.date;
                    dataGridView1.Rows[i].Cells[6].Value = stf1.num2Date();
                    dataGridView1.Rows[i].Cells[7].Value = Convert.ToString(stf1.shumu);
                }

                switch (xmlName)
                {
                case "mainStore.xml":
                    label1.Text = "库存状况";
                    //标价总额
                    totalon1 = 0;
                    totalon2 = 0;
                    for (int i1 = 0; i1 < al.Count; i1++)
                    {
                        totalon1 += double.Parse(dataGridView1.Rows[i1].Cells[2].Value.ToString()) * double.Parse(dataGridView1.Rows[i1].Cells[7].Value.ToString());
                        totalon2 += double.Parse(dataGridView1.Rows[i1].Cells[3].Value.ToString()) * double.Parse(dataGridView1.Rows[i1].Cells[7].Value.ToString());
                    }
                    label2.Text = "当前货场投入成本:" + totalon1 + "; 货场总标价" + totalon2;
                    break;

                case "jinHuo.xml":
                    label1.Text = "进货记录";
                    //进货总成本
                    totalin = 0;
                    for (int i1 = 0; i1 < al.Count; i1++)
                    {
                        totalin += double.Parse(dataGridView1.Rows[i1].Cells[2].Value.ToString()) * double.Parse(dataGridView1.Rows[i1].Cells[7].Value.ToString());
                    }
                    label2.Text = "进货总成本:" + totalin;

                    break;

                case "chuHuo.xml":
                    label1.Text = "出货记录";
                    //总营业额
                    totalout = 0;
                    for (int i1 = 0; i1 < al.Count; i1++)
                    {
                        totalout += double.Parse(dataGridView1.Rows[i1].Cells[4].Value.ToString()) * double.Parse(dataGridView1.Rows[i1].Cells[7].Value.ToString());
                    }
                    label2.Text = "总营业额:" + totalout;
                    break;

                case "chaXun.xml":
                    label1.Text = "查询结果";
                    break;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                float.Parse(textBox3.Text);
                float.Parse(textBox4.Text);
                float.Parse(textBox5.Text);

                float.Parse(textBox3_1.Text);
                float.Parse(textBox4_1.Text);
                float.Parse(textBox5_1.Text);
            }
            catch
            {
                MessageBox.Show("价格必须是一个数字");
                return;
            }

            //得到匹配字符串
            string[] str_pipei = new string[8];
            if (checkBox1.Checked == true)
            {
                str_pipei[0] = textBox1.Text.ToString();
            }
            else
            {
                str_pipei[0] = "strnouse";
            }

            if (checkBox2.Checked == true)
            {
                str_pipei[1] = textBox2.Text.ToString();
            }
            else
            {
                str_pipei[1] = "strnouse";
            }

            if (checkBox3.Checked == true)
            {
                str_pipei[2] = textBox3.Text.ToString();
                str_pipei[3] = textBox3_1.Text.ToString();
            }
            else
            {
                str_pipei[2] = "strnouse";
            }

            if (checkBox4.Checked == true)
            {
                str_pipei[4] = textBox4.Text.ToString();
                str_pipei[5] = textBox4_1.Text.ToString();
            }
            else
            {
                str_pipei[4] = "strnouse";
            }

            if (checkBox5.Checked == true)
            {
                str_pipei[6] = textBox5.Text.ToString();
                str_pipei[7] = textBox5_1.Text.ToString();
            }
            else
            {
                str_pipei[6] = "strnouse";
            }

            //取得xml中的值,进行匹配
            {
                cmdXML    cx = new cmdXML();
                ArrayList al;
                switch (comboBox1.Text)
                {
                case "库存状况":
                    al = cx.searchAllNode("mainStore.xml", "store");
                    break;

                case "进货记录":
                    al = cx.searchAllNode("jinHuo.xml", "inhere");
                    break;

                case "出货记录":
                    al = cx.searchAllNode("chuHuo.xml", "outhere");
                    break;

                default:
                    al = new ArrayList();
                    break;
                }

                if (al.Count > 0)
                {
                    int i = 0;
                    while (i < al.Count)
                    {
                        storeFur stf = al[i] as storeFur;
                        if (pipeiStore(stf, str_pipei))
                        {
                            i++;
                        }
                        else
                        {
                            al.RemoveAt(i);
                        }
                    }
                }

                //书写匹配结果xml,如无结果,主对话框datagridview清空,且弹出消息框

                cmdXML cx1 = new cmdXML();

                if (al.Count == 0)
                {
                    //告诉主对话框进行刷新
                    Form1 f1 = (Form1)this.Owner;
                    f1.noResultWarning();
                }
                else
                {
                    for (int i = 0; i < al.Count; i++)
                    {
                        storeFur stf1 = new storeFur();
                        stf1 = al[i] as storeFur;
                        cx1.AddFurElement("chaXun.xml", stf1, "result");
                    }
                    {
                        //告诉主对话框进行刷新
                        Form1 f1 = (Form1)this.Owner;
                        f1.formRefresh("chaXun.xml", "result");
                    }
                }
                {
                    cmdXML cx2 = new cmdXML();
                    cx2.deleteAllNode("chaXun.xml", "result");
                    this.Close();
                }
            }
        }