예제 #1
0
        private void btAddDevice_Click(object sender, EventArgs e)
        {
            ProductionInfo addInfoForm = new ProductionInfo();

            if (addInfoForm.ShowDialog() == DialogResult.OK)
            {
                ProductDal dal = new ProductDal();

                if (dal.InsertProduction(addInfoForm.Production) > 0)
                {
                    this.LoadDataGridView();
                    MessageBox.Show("添加产品信息成功!");
                }
                else
                {
                    MessageBox.Show("添加产品信息失败!");
                }
            }
        }
예제 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            this.dataGridView1.CellValueChanged -= new DataGridViewCellEventHandler(dataGridView1_CellContentClick);

            DataRow rd = null;

            switch (e.ColumnIndex)
            {
            case 5:


                ProductionInfo addInfoForm = new ProductionInfo();
                addInfoForm.IsUpdate = true;
                rd = this.infos.Rows[e.RowIndex];

                ProductionMDL info = new ProductionMDL();
                info.Load(rd);

                addInfoForm.Production = info;
                if (addInfoForm.ShowDialog() == DialogResult.OK)
                {
                    ProductDal dal = new ProductDal();
                    if (dal.UpdateProduction(info) > 0)
                    {
                        this.LoadDataGridView();
                        MessageBox.Show("修改产品信息成功!");
                    }
                    else
                    {
                        MessageBox.Show("修改产品信息失败!");
                    }
                }


                break;

            case 6:


                if (MessageBox.Show("确定要删除该产品信息吗?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    rd = this.infos.Rows[e.RowIndex];

                    int id = Convert.ToInt32(rd["tid"]);

                    ProductDal dal = new ProductDal();

                    if (dal.DeleteProduction(id) > 0)
                    {
                        this.LoadDataGridView();
                    }
                    else
                    {
                        MessageBox.Show("删除产品信息失败!");
                    }
                }



                break;

            default:
                break;
            }


            this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
        }