Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            List <DsMaterial> list = (List <DsMaterial>)bindingSource.DataSource;

            if (list == null)
            {
                MessageBox.ShowTip("请先选择标准配方"); return;
            }
            FrmMaterialEdit frm = new FrmMaterialEdit();

            frm.Text = "助剂新增";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (list.Where(s => s.MaterialCode == frm.currentMaterial.MaterialCode).Count() > 0)
                {
                    MessageBox.ShowTip("不能添加重复助剂");
                }
                else
                {
                    bindingSource.Insert(bindingSource.Count, frm.currentMaterial);
                }
            }
        }
Ejemplo n.º 2
0
        private void dataView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;

            if (e.RowIndex > -1)
            {
                DataGridViewRow dgvr = dataView1.Rows[rowIndex];
                if (dgvr.Cells[e.ColumnIndex].Value.ToString() == "修改")
                {
                    FrmMaterialEdit frm = new FrmMaterialEdit();
                    frm.Text            = "助剂修改";
                    frm.currentMaterial = (DsMaterial)bindingSource.Current;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        bindingSource.RemoveAt(e.RowIndex);
                        bindingSource.Insert(e.RowIndex, frm.currentMaterial);
                    }
                }
                else if (dgvr.Cells[e.ColumnIndex].Value.ToString() == "删除")
                {
                    bindingSource.RemoveCurrent();
                }
            }
        }