Exemplo n.º 1
0
 private void YES_MouseLeftButtonDown(object sender, RoutedEventArgs e)
 {
     if (pageName == "WhiteListSetting")
     {
         for (int i = WhiteListSetting.whiteList.Count - 1; i >= 0; i--)
         {
             if (WhiteListSetting.whiteList[i].ID == id)
             {
                 white.DeleteWhiteShip((int)double.Parse(WhiteListSetting.whiteList[i].MMSI)); //数据库删除
                 MainWindow.opeation.OptionName = "删除白名单";                                     //日志入库
                 MainWindow.opeation.LogType    = 2;
                 MainWindow.opeation.OptionTime = WhiteListSetting.GetTime(WhiteListSetting.GetTimeStampS().ToString());
                 MainWindow.OperationLogData.WriteOperationLog(MainWindow.opeation);
                 WhiteListSetting.whiteList.RemoveAt(i);//列表删除
             }
         }
         for (int i = WhiteListSetting.whiteList.Count - 1; i >= 0; i--)
         {
             WhiteListSetting.whiteList[i].ID = i;
         }
         dataAna.WhiteListSync();//白名单同步
     }
     else if (pageName == "UserManagement")
     {
         for (int i = UserManagement.userList.Count - 1; i >= 0; i--)
         {
             if (UserManagement.userList[i].ID == id)
             {
                 userData.DeleteUser(int.Parse(UserManagement.userList[i].UserID));//数据库删除用户
                 UserManagement.userList.RemoveAt(i);
             }
         }
         for (int i = UserManagement.userList.Count - 1; i >= 0; i--)
         {
             UserManagement.userList[i].ID = i;
         }
     }
     else if (pageName == "NetParameterSetting")
     {
         for (int i = NetParameterSetting.deviceList.Count - 1; i >= 0; i--)
         {
             if (NetParameterSetting.deviceList[i].ID == id)
             {
                 device.DeleteDeviceInfo(NetParameterSetting.deviceList[i].Name);//数据库删除
                 NetParameterSetting.deviceList.RemoveAt(i);
             }
         }
         for (int i = NetParameterSetting.deviceList.Count - 1; i >= 0; i--)
         {
             NetParameterSetting.deviceList[i].ID = i;
         }
     }
     this.Close();
 }
        private void comfirmClick(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(mmsi.Text) || String.IsNullOrWhiteSpace(number.Text))
            {
                MessageBoxX.Show("提示", "MMSI、船舷号不能为空!");
            }
            else
            {
                WhiteListSetting.whiteList.Clear();

                List <WhiteShip> whiteListStr = new List <WhiteShip>();
                whiteListStr = white.GetAllWhiteShip();//初始化白名单列表

                for (int i = 0; i < whiteListStr.Count(); i++)
                {
                    WhiteTarget wt = new WhiteTarget
                    {
                        ID         = i,
                        MMSI       = whiteListStr[i].MMSI.ToString(),
                        Number     = whiteListStr[i].ShipNumber,
                        IMO        = whiteListStr[i].IMO.ToString(),
                        CallSign   = whiteListStr[i].CallID,
                        Name       = whiteListStr[i].ShipName,
                        Department = whiteListStr[i].ShipDepartment,
                        Usage      = whiteListStr[i].ShipUsage,
                        ReadOnly   = true,
                    };
                    WhiteListSetting.whiteList.Add(wt);
                }

                int count;
                for (count = 0; count < WhiteListSetting.whiteList.Count; count++)
                {
                    if (WhiteListSetting.whiteList[count].MMSI == mmsi.Text)
                    {
                        MessageBoxX.Show("提示", "已存在具有相同MMSI的船只!");
                        break;
                    }
                }

                if (count == WhiteListSetting.whiteList.Count)
                {
                    try
                    {
                        WhiteShip ship = new WhiteShip();
                        ship.CallID = callSign.Text;
                        if (!String.IsNullOrWhiteSpace(imo.Text))
                        {
                            ship.IMO = uint.Parse(imo.Text);
                        }
                        ship.MMSI           = int.Parse(mmsi.Text);;
                        ship.ShipDepartment = department.Text;
                        ship.ShipName       = name.Text;
                        ship.ShipUsage      = usage.Text;
                        ship.ShipNumber     = number.Text;
                        white.AddWhiteShip(ship);                 //添加白名单入库

                        dataAna.WhiteListSync();                  //白名单同步

                        MainWindow.opeation.OptionName = "添加白名单"; //日志入库
                        MainWindow.opeation.LogType    = 2;
                        MainWindow.opeation.OptionTime = WhiteListSetting.GetTime(WhiteListSetting.GetTimeStampS().ToString());
                        MainWindow.OperationLogData.WriteOperationLog(MainWindow.opeation);

                        whiteListStr = white.GetAllWhiteShip();
                        WhiteTarget wt = new WhiteTarget
                        {
                            ID         = WhiteListSetting.whiteList.Count,
                            MMSI       = whiteListStr[whiteListStr.Count - 1].MMSI.ToString(),
                            Number     = whiteListStr[whiteListStr.Count - 1].ShipNumber,
                            IMO        = whiteListStr[whiteListStr.Count - 1].IMO.ToString(),
                            CallSign   = whiteListStr[whiteListStr.Count - 1].CallID,
                            Name       = whiteListStr[whiteListStr.Count - 1].ShipName,
                            Department = whiteListStr[whiteListStr.Count - 1].ShipDepartment,
                            Usage      = whiteListStr[whiteListStr.Count - 1].ShipUsage,
                            ReadOnly   = true,
                        };
                        WhiteListSetting.whiteList.Add(wt);
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBoxX.Show("警告", "MMSI、IMO应为整数!");
                    }
                }
            }
        }