コード例 #1
0
        /// <summary>
        /// 单击单元格:删除,修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dbgvMain_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                string operate = dgvMain.CurrentRow.Cells[e.ColumnIndex].Value.ToString();

                if (operate == "修改")
                {
                    InitialzeUpdate();
                }

                else if (operate == "删除")
                {
                    try
                    {
                        DialogResult dr = MessageBox.Show("您确认要删除这条记录?", "确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            operated = 2;

                            //存入日志
                            LogSave.Messages("[FrmPathEmp]", LogIDType.UserLogID, "删除员工路径关系信息,路线编号:"
                                             + dgvMain.CurrentRow.Cells["PathNo"].Value.ToString() + ",员工姓名:" + dgvMain.CurrentRow.Cells[5].Value.ToString() + "。");

                            int id    = Convert.ToInt32(dgvMain.CurrentRow.Cells["Id"].Value.ToString());
                            int count = pathEmpRelationbll.DeletePathEmpRelation(id);

                            bool flag = (count == 1 ? true : false);

                            if (flag)
                            {
                                if (!New_DBAcess.IsDouble)
                                {
                                    InitialzeDataGridView();
                                }
                                else
                                {
                                    timer1.Start();
                                }
                            }
                            else
                            {
                                MessageBox.Show("删除操作失败", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("操作失败:" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 删除巡检路径配置
        /// </summary>
        private void DeletePathEmpInfo()
        {
            int          i  = 0;
            ArrayList    al = new ArrayList();
            DialogResult result;

            foreach (DataGridViewRow dgvr in dgvMain.Rows)
            {
                if (dgvr.Cells[0].Value != null && dgvr.Cells[0].Value.Equals("True"))
                {
                    i += 1;
                    int id = int.Parse(dgvr.Cells["id"].Value.ToString());
                    al.Add(id);
                }
            }

            if (i == 0)
            {
                MessageBox.Show("请选择要删除的人员巡检路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            result = MessageBox.Show("是否要删除选中人员巡检路径?", "提示", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                btnSelectAll.Text = "全选";
                for (int j = 0; j < al.Count; j++)
                {
                    int iTemp = (int)al[j];
                    //操作数据库删除
                    pathempRelationBll.DeletePathEmpRelation(iTemp);
                    //存入日志
                    LogSave.Messages("[FrmPathManage]", LogIDType.UserLogID, "删除人员巡检路径信息,编号为:" + iTemp.ToString());
                }

                dgvMain.ClearSelection();
                if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                {
                    //刷新
                    BindData("");
                    SetTreeViewPathEmp();
                }
                else                                //热备版,启用定时器
                {
                    HostBackRefresh(true);
                }
            }
        }