Exemplo n.º 1
0
        /// <summary>
        /// 删除巡检路径配置
        /// </summary>
        private void DeletePathInfo()
        {
            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;
                    string[] strID = new string[2];
                    strID[0] = dgvr.Cells["did"].Value.ToString();
                    strID[1] = dgvr.Cells["pathNo"].Value.ToString();
                    al.Add(strID);
                }
            }

            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++)
                {
                    string[] strTemp = (string[])al[j];
                    //操作数据库删除
                    pathInfoBll.DeletePathDetail(int.Parse(strTemp[0]), strTemp[1]);
                    //存入日志
                    LogSave.Messages("[FrmPathManage]", LogIDType.UserLogID, "删除巡检路径信息,编号为:" + strTemp[0]);
                }

                dgvMain.ClearSelection();

                if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                {
                    //刷新
                    BindData("");
                    SetTreeViewPath();
                }
                else                                //热备版,启用定时器
                {
                    HostBackRefresh(true);
                }
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Check())
            {
                PathInfoModel pathInfoModel = new PathInfoModel();
                pathInfoModel.PathNo   = txtPathID.Text;
                pathInfoModel.PathName = txtPathName.Text;
                pathInfoModel.Remark   = "";
                string strMessage = "";
                int    rowCount   = 0;
                switch (m_type)
                {
                case 1:
                    rowCount = pathinfoBll.InsertPathInfo(pathInfoModel, out strMessage);
                    break;

                case 2:
                    pathInfoModel.Id = int.Parse(txtID.Text);
                    rowCount         = pathinfoBll.UpdatePathInfo(pathInfoModel, out strMessage);
                    break;
                }
                if (strMessage.Equals("Succeeds"))
                {
                    if (rowCount > 0)
                    {
                        try
                        {
                            for (int i = 0; i < alPathDetail.Count; i++)
                            {
                                PathDetailModel pathDetail = (PathDetailModel)alPathDetail[i];
                                pathDetail.PathNo = txtPathID.Text;
                                pathinfoBll.DeletePathDetail(pathDetail.PathNo, pathDetail.StationAddress, pathDetail.StationHeadAddress);
                            }
                            for (int i = 0; i < alPathDetailAdd.Count; i++)
                            {
                                PathDetailModel pathDetail1 = (PathDetailModel)alPathDetailAdd[i];
                                pathDetail1.PathNo       = txtPathID.Text;
                                pathDetail1.PathInterval = i + 1;
                                pathinfoBll.InsertPathDetail(pathDetail1);
                            }
                            SetShowInfo("保存成功", Color.Black);

                            if (!New_DBAcess.IsDouble)          //单机版,直接刷新
                            {
                                m_frmPathManage.SetTreeViewPath();
                                m_frmPathManage.BindData("");
                            }
                            else                                //热备版,启用定时器
                            {
                                m_frmPathManage.HostBackRefresh(true);
                            }
                            //this.Close();
                        }
                        catch
                        {
                            SetShowInfo("保存失败", Color.Black);
                        }
                    }
                    else
                    {
                        SetShowInfo("路径添加重复", Color.Red);
                    }
                }
                else
                {
                    SetShowInfo("保存路径失败", Color.Black);
                }
            }
        }