Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Number.Text == "")
            {
                MessageBox.Show("原材料编码不能为空!");
            }
            else if (Name1.Text == "")
            {
                MessageBox.Show("原材料名称不能为空!");
            }

            else if (Type.Text == "")
            {
                MessageBox.Show("类型不能为空!");
            }
            else if (Count.Text == "")
            {
                MessageBox.Show("数量不能为空!");
            }
            else if (Unit.Text == "")
            {
                MessageBox.Show("数量单位不能为空!");
            }
            else
            {
                string          number = Number.Text;
                string          name   = Name1.Text;
                string          type   = Type.Text;
                string          unit   = Unit.Text;
                double          count  = double.Parse(Count.Text);
                rawmaterialDaoz c      = new rawmaterialDaoz();

                string msg = "确定添加吗?";

                if ((int)MessageBox.Show(msg, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != 1)
                {
                    return;
                }
                c.addRawmaterial(number, name, type, count, unit);
                Console.Write(c.su + "!!");
                if (c.su == 0)
                {
                }
                else
                {
                    int node = s.dataGridView1.Rows.Count;
                    s.dt.Rows.Add(node + 1, number, name, type, count, unit);
                    s.dataGridView1.DataSource = s.dt;
                    this.Close();
                }
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Name1.Text == "")
            {
                MessageBox.Show("原材料名称不能为空!");
            }
            else if (Type.Text == "")
            {
                MessageBox.Show("类型不能为空!");
            }
            else if (Count.Text == "")
            {
                MessageBox.Show("数量不能为空!");
            }
            else if (Unit.Text == "")
            {
                MessageBox.Show("数量单位不能为空!");
            }

            else
            {
                string msg = "确定修改吗?";

                if ((int)MessageBox.Show(msg, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != 1)
                {
                    return;
                }
                rawmaterialDaoz c = new rawmaterialDaoz();
                c.update_rawmaterial(number, Name1.Text, Type.Text, double.Parse(Count.Text), Unit.Text);
                s.dataGridView1.Rows[j].Cells[4].Value = Name1.Text;
                s.dataGridView1.Rows[j].Cells[5].Value = Type.Text;
                s.dataGridView1.Rows[j].Cells[6].Value = Count.Text;
                s.dataGridView1.Rows[j].Cells[7].Value = Unit.Text;
                MessageBox.Show("已修改!");
                this.Close();
            }
        }
Exemple #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            bool b = true;

            if (dataGridView1.Rows.Count == 1)
            {
                MessageBox.Show("请填写信息");
                b = false;
            }
            else
            {
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value == null)
                    {
                        MessageBox.Show("编号不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[1].Value == null)
                    {
                        MessageBox.Show("商品名称不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[3].Value == null)
                    {
                        MessageBox.Show("单位不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[4].Value == null)
                    {
                        MessageBox.Show("数量不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[5].Value == null)
                    {
                        MessageBox.Show("单价不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[6].Value == null)
                    {
                        MessageBox.Show("金额不能为空");
                        b = false;
                    }
                    else if (textBox1.Text == "")
                    {
                        MessageBox.Show("请选择供应商");
                        b = false;
                    }
                    else if (textBox3.Text == "")
                    {
                        MessageBox.Show("操作人不能为空!");
                    }
                }
            }
            if (b == false)
            {
            }
            else
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("是否确认保存?", "提交", messButton);
                if (dr == DialogResult.OK)
                {
                    string[] supplier = supplier_text.Text.Split(' ');
                    string[] employer = textBox3.Text.Split(' ');
                    try
                    {
                        purchase dao = new purchase();
                        double   mm  = Convert.ToDouble(label11.Text);
                        dao.addDanju(Convert.ToDateTime(dateTimePicker1.Text), textBox1.Text, employer[0], mm, textBox4.Text, supplier[0], 0);

                        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                        {
                            purchase_material p = new purchase_material();
                            Console.Write(dataGridView1.Rows[i].Cells[0].Value + "lallalalaalalalalalalla");
                            p.RawMaterial_number = dataGridView1.Rows[i].Cells[0].Value.ToString();
                            rawmaterialDaoz rdd  = new rawmaterialDaoz();
                            rawmaterialdao  rdao = new rawmaterialdao();
                            rawmaterial     r    = rdao.selectNumber(p.RawMaterial_number);
                            if (r == null)
                            {
                                rdd.addRawmaterial(p.RawMaterial_number, dataGridView1.Rows[i].Cells[1].Value.ToString(), "其他", 0, dataGridView1.Rows[i].Cells[3].Value.ToString());
                            }
                            p.Suppliernumber = supplier[0];
                            p.Dan_date       = Convert.ToDateTime(dateTimePicker1.Text);
                            Console.Write("这是一个人" + p.Suppliernumber + "这是一个人");
                            p.Unit  = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            p.Count = Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
                            p.Price = Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value);
                            //Console.Write("这是一个人" + p.Price + "这是一个人");
                            p.Money = Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value);
                            if (dataGridView1.Rows[i].Cells[7].Value == null)
                            {
                                p.Remark = "";
                            }
                            else
                            {
                                p.Remark = dataGridView1.Rows[i].Cells[7].Value.ToString();
                            }

                            p.Status   = 0;
                            p.Danju_id = textBox1.Text;
                            // Console.Write("这是一个人" + p.Danju_id + "这是一个人");
                            dao.addpurchase(p);
                        }
                        MessageBox.Show("保存成功");
                        dataGridView1.Rows.Clear();
                    }
                    catch (SystemException)
                    {
                        MessageBox.Show("操作有误");
                    }
                }
                else
                {
                }
            }
        }