private void btnAddGoods_Click(object sender, EventArgs e) { ProductsModel pm = new ProductsModel(); pm.ProductID1 = -1; CommoditiesEditorForm ce = new CommoditiesEditorForm(pm); ce.Show(); this.Hide(); }
private void btnUpdateGoods_Click(object sender, EventArgs e) { if (dataGridView2.SelectedCells.Count > 0) { int index = Convert.ToInt32(dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[0].Value); string name = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[1].Value.ToString(); string jp = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[3].Value.ToString(); string type = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[2].Value.ToString(); double price = Convert.ToDouble(dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[4].Value); ProductsModel pm = new ProductsModel(index, name, type, jp, price); CommoditiesEditorForm ce = new CommoditiesEditorForm(pm); ce.Show(); this.Hide(); } else { MessageBox.Show("请选择数据!"); } }