// 修改和删除
        private void dgvEqu_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {
                // 调用修改页面
                DataTable  dt       = equDAL.GetEquInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                DataTable  dtDetail = equDAL.GetEquEqu_DetailInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                FrmEquEdit frm      = new FrmEquEdit();
                frm.Text = "修改设备信息";
                if (IsNotFactory())
                {
                    frm.ShowDialog(dt, dtDetail);

                    // 重新绑定
                    BinddgvEqu();
                }
                else
                {
                    MessageBox.Show("请先添加生产厂家");
                    btnFactoryAdd_Click(sender, e);
                }
            }
            else if (e.ColumnIndex == 1 && e.RowIndex >= 0)
            {
                model = 1;

                // 删除
                if (MessageBox.Show("您确定要删除编号为【 " + dgvEqu.Rows[e.RowIndex].Cells[3].Value.ToString() + " 】的设备【 " + dgvEqu.Rows[e.RowIndex].Cells[4].Value.ToString() + " 】吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    //存入日志
                    LogSave.Messages("[FrmEquManage]", LogIDType.UserLogID, "删除设备信息,生产厂家:" + dgvEqu.Rows[e.RowIndex].Cells[3].Value.ToString() + ",设备名称:" + dgvEqu.Rows[e.RowIndex].Cells[4].Value.ToString());

                    int intCount = equDAL.DelEqu_BaseInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                    if (intCount == -1)
                    {
                        MessageBox.Show("删除失败");
                        return;
                    }

                    if (!New_DBAcess.IsDouble)
                    {
                        // 重新绑定
                        BinddgvEqu();
                    }
                    else
                    {
                        timer1.Stop();
                        timer1.Start();
                    }
                }
            }
        }
        // 添加
        private void btnEquAdd_Click(object sender, EventArgs e)
        {
            FrmEquEdit frm = new FrmEquEdit();

            frm.Text = "添加设备信息";
            if (IsNotFactory())
            {
                frm.ShowDialog(null, null);

                // 重新绑定
                BinddgvEqu();
            }
            else
            {
                MessageBox.Show("请先添加生产厂家");
                btnFactoryAdd_Click(sender, e);
            }
        }
Beispiel #3
0
        // 添加
        private void btnEquAdd_Click(object sender, EventArgs e)
        {
            FrmEquEdit frm = new FrmEquEdit();
            frm.Text = "添加设备信息";
            if (IsNotFactory())
            {
                frm.ShowDialog(null, null);

                // 重新绑定
                BinddgvEqu();
            }
            else
            {
                MessageBox.Show("请先添加生产厂家");
                btnFactoryAdd_Click(sender, e);
            }
        }
Beispiel #4
0
        // 修改和删除
        private void dgvEqu_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {
                // 调用修改页面
                DataTable dt = equDAL.GetEquInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                DataTable dtDetail = equDAL.GetEquEqu_DetailInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                FrmEquEdit frm = new FrmEquEdit();
                frm.Text = "修改设备信息";
                if (IsNotFactory())
                {
                    frm.ShowDialog(dt, dtDetail);

                    // 重新绑定
                    BinddgvEqu();
                }
                else
                {
                    MessageBox.Show("请先添加生产厂家");
                    btnFactoryAdd_Click(sender, e);
                }
            }
            else if (e.ColumnIndex == 1 && e.RowIndex >= 0)
            {

                model = 1;

                // 删除
                if (MessageBox.Show("您确定要删除编号为【 " + dgvEqu.Rows[e.RowIndex].Cells[3].Value.ToString() + " 】的设备【 " + dgvEqu.Rows[e.RowIndex].Cells[4].Value.ToString() + " 】吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    //存入日志
                    LogSave.Messages("[FrmEquManage]", LogIDType.UserLogID, "删除设备信息,生产厂家:" + dgvEqu.Rows[e.RowIndex].Cells[3].Value.ToString() + ",设备名称:" + dgvEqu.Rows[e.RowIndex].Cells[4].Value.ToString());

                    int intCount = equDAL.DelEqu_BaseInfo(int.Parse(dgvEqu.Rows[e.RowIndex].Cells[2].Value.ToString()));
                    if (intCount == -1)
                    {
                        MessageBox.Show("删除失败");
                        return;
                    }

                    if (!New_DBAcess.IsDouble)
                    {
                        // 重新绑定
                        BinddgvEqu();
                    }
                    else
                    {
                        timer1.Stop();
                        timer1.Start();
                    }
                }
            }
        }