private bool Add()
 {
     var forbidip = new sys_ForbidIp
     {
         IP=tbxIP.Text.Trim(),                
         Describe = taDescribe.Text,
         IsUsing = Convert.ToBoolean(cbxIsUsing.Checked),
         IsDelete = false,
         CreateDate = DateTime.Now,
         CreateUserName = BaseUserName,
         CreateRealName = BaseRealName
     };
     Log(LogType.新增, string.Format("添加IP黑名单:{0}", forbidip.IP), "IP黑名单");
     return ForbidIpService.Add(forbidip);
 }
        private void ForbidIpClick()
        {
            if (Grid1.SelectedRowIndexArray.Length == 0)
            {
                Alert.Show("请至少选择一项!", MessageBoxIcon.Information);
                return;
            }
            else if (Grid1.SelectedRowIndexArray.Length > 1)
            {
                Alert.Show("只能选择一项!", MessageBoxIcon.Information);
                return;
            }

            try
            {
                int id = Convert.ToInt32(Grid1.DataKeys[Grid1.SelectedRowIndexArray[0]][0]);
                var log = LoginLogService.FirstOrDefault(p => p.Id == id);
                var server = new ForbidIpService();
                if (server.FirstOrDefault(p => p.IP == log.Ip&&p.IsDelete==false) != null)
                {
                    Alert.Show("此IP已在黑名单中,请勿重复添加!", MessageBoxIcon.Information);
                    return;
                }
                var ip = new sys_ForbidIp
                {
                    IP = log.Ip,
                    IsDelete = false,
                    IsUsing = true,
                    CreateDate = DateTime.Now,
                    CreateUserName = BaseUserName,
                    CreateRealName = BaseRealName,
                    Describe = ""
                };
                server.Add(ip);
                Log(LogType.新增, "添加IP到黑名单:" + ip.IP, "IP黑名单");
                Alert.Show("添加成功!");
            }
            catch (Exception)
            {
                Alert.Show("删除失败!", MessageBoxIcon.Warning);
            }
        }