Пример #1
0
        private void gridProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(gridProduct.Rows[e.RowIndex].Cells[0].Value);

            if (e.ColumnIndex == gridProduct.Columns.Count - 1)
            {
                if (MessageBox.Show("确定要删除此数据?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        entities.Delete <Product>(id);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("数据删除失败!", "提示");
                        LogHelper.WriteLog(LogType.Error, exp, this.GetType());
                    }
                    DataBind();
                }
            }
            else if (e.ColumnIndex == gridProduct.Columns.Count - 2)
            {
                var existFrm = GetForm(frmFrmProductName);
                if (existFrm != null)
                {
                    existFrm.Close();
                }
                FrmProduct frm = new FrmProduct();
                frm.MdiParent = this.MdiParent;
                frm.ProductId = id;
                frm.Show();
            }
        }
Пример #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            var existFrm = GetForm(frmFrmProductName);

            if (existFrm != null)
            {
                existFrm.Close();
            }
            FrmProduct frm = new FrmProduct();

            frm.MdiParent = this.MdiParent;
            frm.Show();
        }