예제 #1
0
        public Form1()
        {
            InitializeComponent();
            //并打开一个xml文件,如不存在,则创建之
            xh = new XmlHelper();
            cx = new cmdXML();

            cx.CreateXMLDoc("mainStore.xml", "store");
            cx.CreateXMLDoc("jinHuo.xml", "inhere");
            cx.CreateXMLDoc("chuHuo.xml", "outhere");
            cx.CreateXMLDoc("chaXun.xml", "result");
            //以十条为单位,查询其内容并显示在dataGridView1上
            this.dataGridView1.Columns.Add(@"variety", @"品种");
            this.dataGridView1.Columns.Add(@"number", @"型号");
            this.dataGridView1.Columns.Add(@"inprice", @"进价");
            this.dataGridView1.Columns.Add(@"onprice", @"货场标价");
            this.dataGridView1.Columns.Add(@"outprice", @"实际出货价");
            this.dataGridView1.Columns.Add(@"id", @"存储编号");
            this.dataGridView1.Columns.Add(@"date", @"日期");
            this.dataGridView1.Columns.Add(@"shumu", @"数目");
            //不允许用户编辑datagridview中的数据
            this.dataGridView1.ReadOnly = true;


            //refresh
            formRefresh("mainStore.xml", "store");
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
                float.Parse(textBox5.Text);
            }
            catch
            {
                MessageBox.Show("价格必须是一个数字");
                return;
            }
            try
            {
                int.Parse(textBox6.Text);
            }
            catch
            {
                MessageBox.Show("数目必须是个整数");
                return;
            }


            //添加出货记录
            cmdXML cx = new cmdXML();

            stf.outprice = textBox5.Text;
            stf.shumu    = int.Parse(textBox6.Text);

            cx.AddFurElement("chuHuo.xml", stf, "outhere");
            string snews = cx.fenliSingleNode("mainStore.xml", "store", stf);

            switch (snews)
            {
            case "fail<":
                MessageBox.Show("库存不足");
                break;

            case "failNo":
                MessageBox.Show("无相应产品");
                break;

            case "succeedbut0":
                MessageBox.Show("最后一件该商品卖出啦");
                break;

            case "":
                MessageBox.Show("这种情况一般不会出现,如果出现请联系coder");
                break;

            default:
                MessageBox.Show("出货成功,剩余" + snews);
                break;
            }

            //告诉主对话框刷新datagridview
            Form1 fm1 = (Form1)this.Owner;

            fm1.formRefresh("mainStore.xml", "store");
            //关闭对话框
            this.Close();
        }
예제 #5
0
        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();
                }
            }
        }