1165 lines
50 KiB
C#
1165 lines
50 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using SafeMobileLib;
|
|
using Telerik.WinControls;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Telerik.WinControls.UI;
|
|
|
|
namespace SubscriberAndUserManager
|
|
{
|
|
public partial class controlGateways : UserControl
|
|
{
|
|
private DBgatewaysManager DB;
|
|
private int totalGateways;
|
|
private List<Gateway> gwList;
|
|
private List<RadioGateway> radioGwList;
|
|
private List<RadioZones> radioZonesList;
|
|
private List<RadioChannels> radioChannelsList;
|
|
DBregistrationManager regManager;
|
|
private Gateway selectedGW;
|
|
private RadioGateway selectedRadioGW;
|
|
private RadioZones selectedRadioZone;
|
|
private RadioChannels selectedRadioChannel;
|
|
private DBcontactsManager DBcontact = new DBcontactsManager(MainForm.DBServer, MainForm.DBSchema, MainForm.DBUser, MainForm.DBPass, MainForm.DBPort);
|
|
private DBcallPatchManager dbpatch = new DBcallPatchManager(MainForm.DBServer, MainForm.DBSchema, MainForm.DBUser, MainForm.DBPass, MainForm.DBPort);
|
|
private Boolean isrepeaterSW = false;
|
|
int remainingGateways = 0;
|
|
|
|
private void setLanguage()
|
|
{
|
|
radLabel15.Text = MainForm.returnLNGString("avb");
|
|
gbAddNew.Text = MainForm.returnLNGString("addgate");
|
|
gbAddNewRadioGW.Text = MainForm.returnLNGString("addradgate");
|
|
radGroupBox1.Text = MainForm.returnLNGString("addradzone");
|
|
radGroupBox2.Text = MainForm.returnLNGString("addradchan");
|
|
btnAddGW.Text = MainForm.returnLNGString("add");
|
|
btnAddZone.Text = MainForm.returnLNGString("add");
|
|
btnChannelAdd.Text = MainForm.returnLNGString("add");
|
|
btnRadioGWadd.Text = MainForm.returnLNGString("add");
|
|
btnRadioGWDeleteSelected.Text = MainForm.returnLNGString("delsel");
|
|
btnRadioZoneDeleteSelected.Text = MainForm.returnLNGString("delsel");
|
|
btnRadioChannelDeleteSelected.Text = MainForm.returnLNGString("delsel");
|
|
btEditSelected.Text = MainForm.returnLNGString("editSel");
|
|
btnDeleteGW.Text = MainForm.returnLNGString("delsel");
|
|
radLabel1.Text = MainForm.returnLNGString("ip");
|
|
rlRadioIP.Text = MainForm.returnLNGString("ip");
|
|
radLabel3.Text = MainForm.returnLNGString("nr") + ":";
|
|
radLabel4.Text = MainForm.returnLNGString("nr") + ":";
|
|
radLabel5.Text = MainForm.returnLNGString("name") + ":";
|
|
radLabel6.Text = MainForm.returnLNGString("name") + ":";
|
|
radLabel9.Text = MainForm.returnLNGString("name") + ":";
|
|
lbImei.Text = MainForm.returnLNGString("radid") + ":";
|
|
checkBvoice.Text = MainForm.returnLNGString("voiceEN");
|
|
lbAddChannel_text.Text = MainForm.returnLNGString("addchZone")+":";
|
|
lbAddZone_text.Text = MainForm.returnLNGString("addZonefor") + ":";
|
|
lbAddRGW_text.Text = MainForm.returnLNGString("addRadioGW") + ":";
|
|
btEditGateway.Text = MainForm.returnLNGString("editSel") + ";";
|
|
ckRepeaterGateway.Text = MainForm.returnLNGString("repGateway");
|
|
lbPeer.Text = MainForm.returnLNGString("peerid") + ":";
|
|
cbActive.Text = MainForm.returnLNGString("active");
|
|
|
|
GridViewGWList.Columns[0].HeaderText = MainForm.returnLNGString("id");
|
|
GridViewGWList.Columns[1].HeaderText = MainForm.returnLNGString("ip");
|
|
GridViewGWList.Columns[2].HeaderText = MainForm.returnLNGString("peerid");
|
|
GridViewGWList.Columns[3].HeaderText = MainForm.returnLNGString("active");
|
|
GridViewRadioGWList.Columns[1].HeaderText = MainForm.returnLNGString("ip");
|
|
GridViewRadioGWList.Columns[5].HeaderText = MainForm.returnLNGString("subnetID");
|
|
GridViewRadioGWList.Columns["IMEI"].HeaderText = MainForm.returnLNGString("imei");
|
|
GridViewRadioGWList.Columns["Gw_voice"].HeaderText = MainForm.returnLNGString("voice");
|
|
GridViewRadioGWList.Columns["Name"].HeaderText = MainForm.returnLNGString("name");
|
|
GridViewRadioGWList.Columns["TypeDesc"].HeaderText = MainForm.returnLNGString("type");
|
|
lbSubID.Text = MainForm.returnLNGString("subnetID")+":";
|
|
GridViewRadioZOnesList.Columns[1].HeaderText = MainForm.returnLNGString("nr");
|
|
GridViewRadioZOnesList.Columns[2].HeaderText = MainForm.returnLNGString("name");
|
|
GridViewRadioChannelList.Columns[1].HeaderText = MainForm.returnLNGString("nr");
|
|
GridViewRadioChannelList.Columns[2].HeaderText = MainForm.returnLNGString("name");
|
|
radTextBox2.NullText = tbRadioGWip.NullText = MainForm.returnLNGString("BasestationIP");
|
|
tbRadioGWName.NullText = MainForm.returnLNGString("RadioGWName");
|
|
tbZoneName.Text = MainForm.returnLNGString("ZoneName");
|
|
tbChannelName.Text = MainForm.returnLNGString("ChannelName");
|
|
lbGWType.Text = MainForm.returnLNGString("type") + ":";
|
|
}
|
|
|
|
private MainForm parent = null;
|
|
|
|
public controlGateways(DBgatewaysManager DB, int totalGateways, DBregistrationManager DBreg)
|
|
{
|
|
this.DB = DB;
|
|
regManager = DBreg;
|
|
this.totalGateways = totalGateways;
|
|
InitializeComponent();
|
|
|
|
RadMessageBox.SetThemeName("TelerikMetroBlue");
|
|
|
|
parent = (MainForm)this.Parent;
|
|
|
|
|
|
lbAddChannel.Text = "";
|
|
lbAddRGW.Text = "";
|
|
lbAddZone.Text = "";
|
|
setLanguage();
|
|
ckRepeaterGateway.Visible = false;
|
|
tbPeerID.Visible = false;
|
|
lbPeer.Visible = false;
|
|
GridViewGWList.Columns[2].IsVisible = false;
|
|
rbSlot1.Visible = false;
|
|
rbSlot2.Visible = false;
|
|
rbSlot1.Location = new Point(10,49);
|
|
rbSlot2.Location = new Point(65, 49);
|
|
switch (MainForm.radioType)
|
|
{
|
|
#region REPEATER TRBO
|
|
case RADIOTYPE.REPEATER_TRBO:
|
|
lbSubID.Visible = false;
|
|
tbSubID.Visible = false;
|
|
GridViewRadioGWList.Columns[5].IsVisible = false;
|
|
ckRepeaterGateway.Visible = true;
|
|
tbPeerID.Visible = true;
|
|
lbPeer.Visible = true;
|
|
GridViewGWList.Columns[2].IsVisible = true;
|
|
rbSlot1.Visible = true;
|
|
rbSlot1.IsChecked = true;
|
|
rbSlot2.Visible = true;
|
|
lbImei.Visible = false;
|
|
tbRadioIMEI.Visible = false;
|
|
isrepeaterSW = true;
|
|
tbRadioGWip.Text = "Repeater_IP";
|
|
break;
|
|
#endregion
|
|
|
|
case RADIOTYPE.CONECTPLUS:
|
|
|
|
case RADIOTYPE.MOTO:
|
|
case RADIOTYPE.LINX:
|
|
case RADIOTYPE.LINXB:
|
|
lbSubID.Visible = false;
|
|
tbSubID.Visible = false;
|
|
GridViewRadioGWList.Columns["subnetID"].IsVisible = false;
|
|
break;
|
|
|
|
case RADIOTYPE.TETRA:
|
|
case RADIOTYPE.LISF:
|
|
{
|
|
bool visible = false;
|
|
lbSubID.Visible = visible;
|
|
tbSubID.Visible = visible;
|
|
GridViewRadioGWList.Columns["subnetID"].IsVisible = visible;
|
|
cbGWType.Visible = visible;
|
|
lbGWType.Visible = visible;
|
|
rbSlot1.Visible = visible;
|
|
rbSlot2.Visible = visible;
|
|
checkBvoice.Visible = visible;
|
|
rlRadioIP.Text = "SDR IP";
|
|
lbImei.Text = "Gateway ISSI";
|
|
GridViewRadioGWList.Columns["Gw_voice"].IsVisible = visible;
|
|
GridViewRadioGWList.Columns["TypeDesc"].IsVisible = visible;
|
|
//GridViewRadioGWList.Columns["Name"].IsVisible = visible;
|
|
GridViewRadioGWList.Columns["Imei"].HeaderText = "Gateway ISSI";
|
|
splitPanel3.Visible = visible;
|
|
splitPanel4.Visible = visible;
|
|
radSplitContainer1.Size = new Size(radSplitContainer1.Size.Width / 2, radSplitContainer1.Height);
|
|
}
|
|
break;
|
|
#region SIMOCO
|
|
case RADIOTYPE.SIMOCO:
|
|
case RADIOTYPE.EXCERA:
|
|
lbSubID.Visible = false;
|
|
tbSubID.Visible = false;
|
|
checkBvoice.Visible = false;
|
|
GridViewRadioGWList.Columns["subnetID"].IsVisible = false;
|
|
GridViewRadioGWList.Columns["Gw_voice"].IsVisible = false;
|
|
break;
|
|
#endregion
|
|
case RADIOTYPE.HYT:
|
|
{
|
|
bool visibleHyt = false;
|
|
rbSlot1.Visible = visibleHyt;
|
|
rbSlot2.Visible = visibleHyt;
|
|
|
|
|
|
GridViewGWList.TableElement.CellSpacing = -1;
|
|
GridViewGWList.TableElement.RowSpacing = -1;
|
|
GridViewRadioGWList.TableElement.CellSpacing = -1;
|
|
GridViewRadioGWList.TableElement.RowSpacing = -1;
|
|
GridViewRadioZOnesList.TableElement.CellSpacing = -1;
|
|
GridViewRadioZOnesList.TableElement.RowSpacing = -1;
|
|
GridViewRadioChannelList.TableElement.CellSpacing = -1;
|
|
GridViewRadioChannelList.TableElement.RowSpacing = -1;
|
|
checkBvoice.Location = new Point(151, 71);
|
|
lbSubID.Location = new Point(btnRadioGWadd.Location.X, lbImei.Location.Y);
|
|
//lbAddRGW_text.Location = new Point(lbAddRGW_text.Location.X, lbAddRGW_text.Location.Y + 13);
|
|
//lbAddRGW.Location = new Point(lbAddRGW.Location.X + 1, lbAddRGW.Location.Y + 13);
|
|
GridViewRadioGWList.Columns[1].MinWidth = 100;
|
|
GridViewRadioGWList.Columns[1].Width = 100;
|
|
GridViewRadioGWList.Columns[1].MaxWidth = 100;
|
|
break;
|
|
}
|
|
case RADIOTYPE.HARRIS:
|
|
checkBvoice.Location = new Point(65, 69);
|
|
lbSubID.Location = new Point(btnRadioGWadd.Location.X, lbImei.Location.Y);
|
|
lbAddRGW_text.Location = new Point(lbAddRGW_text.Location.X, lbAddRGW_text.Location.Y + 13);
|
|
lbAddRGW.Location = new Point(lbAddRGW.Location.X+1, lbAddRGW.Location.Y + 13);
|
|
GridViewRadioGWList.Columns[1].MinWidth = 100;
|
|
GridViewRadioGWList.Columns[1].Width = 100;
|
|
GridViewRadioGWList.Columns[1].MaxWidth = 100;
|
|
radGroupBox1.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
radGroupBox2.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbAddNew.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbAddNewRadioGW.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
radLabel1.ForeColor = MainForm.HarTextColor;
|
|
rlRadioIP.ForeColor = MainForm.HarTextColor;
|
|
radLabel3.ForeColor = MainForm.HarTextColor;
|
|
radLabel4.ForeColor = MainForm.HarTextColor;
|
|
radLabel5.ForeColor = MainForm.HarTextColor;
|
|
radLabel6.ForeColor = MainForm.HarTextColor;
|
|
lbAddChannel.ForeColor = MainForm.HarTextColor;
|
|
lbAddChannel_text.ForeColor = MainForm.HarTextColor;
|
|
lbAddRGW.ForeColor = MainForm.HarTextColor;
|
|
lbAddRGW_text.ForeColor = MainForm.HarTextColor;
|
|
lbAddZone.ForeColor = MainForm.HarTextColor;
|
|
lbAddZone_text.ForeColor = MainForm.HarTextColor;
|
|
lbImei.ForeColor = MainForm.HarTextColor;
|
|
lbSubID.ForeColor = MainForm.HarTextColor;
|
|
checkBvoice.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
break;
|
|
case RADIOTYPE.ATLAS: //ATLASCHANGE
|
|
checkBvoice.Location = new Point(65, 69);
|
|
lbSubID.Location = new Point(btnRadioGWadd.Location.X, lbImei.Location.Y);
|
|
lbAddRGW_text.Location = new Point(lbAddRGW_text.Location.X, lbAddRGW_text.Location.Y + 13);
|
|
lbAddRGW.Location = new Point(lbAddRGW.Location.X + 1, lbAddRGW.Location.Y + 13);
|
|
GridViewRadioGWList.Columns[1].MinWidth = 100;
|
|
GridViewRadioGWList.Columns[1].Width = 100;
|
|
GridViewRadioGWList.Columns[1].MaxWidth = 100;
|
|
radGroupBox1.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
radGroupBox2.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbAddNew.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbAddNewRadioGW.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
radLabel1.ForeColor = MainForm.HarTextColor;
|
|
rlRadioIP.ForeColor = MainForm.HarTextColor;
|
|
radLabel3.ForeColor = MainForm.HarTextColor;
|
|
radLabel4.ForeColor = MainForm.HarTextColor;
|
|
radLabel5.ForeColor = MainForm.HarTextColor;
|
|
radLabel6.ForeColor = MainForm.HarTextColor;
|
|
lbAddChannel.ForeColor = MainForm.HarTextColor;
|
|
lbAddChannel_text.ForeColor = MainForm.HarTextColor;
|
|
lbAddRGW.ForeColor = MainForm.HarTextColor;
|
|
lbAddRGW_text.ForeColor = MainForm.HarTextColor;
|
|
lbAddZone.ForeColor = MainForm.HarTextColor;
|
|
lbAddZone_text.ForeColor = MainForm.HarTextColor;
|
|
lbImei.ForeColor = MainForm.HarTextColor;
|
|
lbSubID.ForeColor = MainForm.HarTextColor;
|
|
checkBvoice.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
break;
|
|
}
|
|
|
|
// set the row height
|
|
GridViewGWList.TableElement.RowHeight = 43;
|
|
this.GridViewGWList.EnableAlternatingRowColor = true;
|
|
this.GridViewGWList.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|
|
|
// remove border for grid
|
|
this.GridViewGWList.GridViewElement.DrawBorder = false;
|
|
this.GridViewGWList.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|
|
|
// set the row height
|
|
GridViewRadioChannelList.TableElement.RowHeight = 43;
|
|
this.GridViewRadioChannelList.EnableAlternatingRowColor = true;
|
|
this.GridViewRadioChannelList.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|
|
|
// remove border for grid
|
|
this.GridViewRadioChannelList.GridViewElement.DrawBorder = false;
|
|
this.GridViewRadioChannelList.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|
|
|
// set the row height
|
|
GridViewRadioGWList.TableElement.RowHeight = 43;
|
|
this.GridViewRadioGWList.EnableAlternatingRowColor = true;
|
|
this.GridViewRadioGWList.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|
|
|
// remove border for grid
|
|
this.GridViewRadioGWList.GridViewElement.DrawBorder = false;
|
|
this.GridViewRadioGWList.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|
|
|
|
|
// set the row height
|
|
GridViewRadioZOnesList.TableElement.RowHeight = 43;
|
|
this.GridViewRadioZOnesList.EnableAlternatingRowColor = true;
|
|
this.GridViewRadioZOnesList.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|
|
|
// remove border for grid
|
|
this.GridViewRadioZOnesList.GridViewElement.DrawBorder = false;
|
|
this.GridViewRadioZOnesList.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|
if (MainForm.radioType != RADIOTYPE.LINX)
|
|
{
|
|
if (MainForm.radioType != RADIOTYPE.SIMOCO && MainForm.radioType != RADIOTYPE.EXCERA)
|
|
cbGWType.Items.Add(GatewayType.Tier2Radio.ToString());
|
|
cbGWType.Items.Add(GatewayType.Tier3Radio.ToString());
|
|
}
|
|
//if (MainForm.radioType != RADIOTYPE.SIMOCO)
|
|
if (!MainForm.hideLinxFeatures && !DB.HasLinxGateway())
|
|
cbGWType.Items.Add(GatewayType.Broadband.ToString());
|
|
|
|
cbGWType.Items.Add(GatewayType.SMCBridge.ToString());
|
|
|
|
cbGWType.SelectedIndex = 0;
|
|
ShowGWs();
|
|
}
|
|
|
|
//safeDispatches funtions
|
|
#region safeDispatches
|
|
|
|
private void SetAvailableGW()
|
|
{
|
|
remainingGateways = totalGateways - regManager.gatewaysCount();
|
|
tbGateways.Text = remainingGateways.ToString();
|
|
btnAddGW.Enabled = !(remainingGateways < 1) || ModifyGWMode;
|
|
}
|
|
|
|
private void ShowGWs()
|
|
{
|
|
try
|
|
{
|
|
gwList = DB.getAllGateways(totalGateways);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("dberr"), MainForm.returnLNGString("err")); return;
|
|
}
|
|
|
|
SetAvailableGW();
|
|
GridViewGWList.DataSource = gwList;
|
|
|
|
selectedGW = null;
|
|
if (gwList.Count > 0)
|
|
{
|
|
selectedGW = gwList[0];
|
|
isrepeaterSW = (selectedGW.Peer_id != 0);
|
|
}
|
|
|
|
|
|
ShowRadioGWs();
|
|
}
|
|
|
|
private void btnAddGW_Click(object sender, EventArgs e)
|
|
{
|
|
addEditGatewayAsync();
|
|
}
|
|
|
|
private async void addEditGatewayAsync()
|
|
{
|
|
await Task.Run(() => addEditGateway());
|
|
}
|
|
|
|
|
|
private void addEditGateway()
|
|
{
|
|
TurnModifyOFF();
|
|
if (MainForm.TestIP(tbGwIP.Text))
|
|
{
|
|
if (tbGwIP.Text != "")
|
|
{
|
|
if (ModifyGWMode)
|
|
{
|
|
sqlResponse resp = DB.editGateway(tbGwIP.Text, (Int32)tbPeerID.Value, IdGWTochange, cbActive.Checked);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("radinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
else
|
|
TurnModifyGWOFF();
|
|
}
|
|
else
|
|
{
|
|
sqlResponse resp = DB.addGateway(tbGwIP.Text, (Int32)tbPeerID.Value, cbActive.Checked);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("gateinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
}
|
|
}
|
|
|
|
this.Invoke((MethodInvoker)delegate
|
|
{
|
|
ShowGWs();
|
|
});
|
|
|
|
ckRepeaterGateway.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off;
|
|
tbPeerID.Minimum = 0;
|
|
tbPeerID.Value = 0;
|
|
tbPeerID.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("errorIPFormat"), MainForm.returnLNGString("err"));
|
|
}
|
|
}
|
|
|
|
private void btnDelteGW_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if (selectedGW != null)
|
|
{
|
|
DialogResult dr = CustomMessageBox.Show(CustomMessageBoxType.exclamation, String.Format(MainForm.returnLNGString("aredelgw"), selectedGW.Ip), MainForm.returnLNGString("confdelete"), true, 50);
|
|
if (dr == DialogResult.Yes)
|
|
{
|
|
//DB.deletePC_IP_GatewayConnectionWithUser(selectedGW.Id);
|
|
DB.deleteGateway(selectedGW.Id);
|
|
}
|
|
}
|
|
ShowGWs();
|
|
}
|
|
|
|
private void GridViewGWList_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex > -1)
|
|
{
|
|
selectedGW = (Gateway)gwList[e.RowIndex];
|
|
if (selectedGW.Peer_id == 0)
|
|
isrepeaterSW = false;
|
|
else isrepeaterSW = true;
|
|
}
|
|
ShowRadioGWs();
|
|
}
|
|
#endregion
|
|
|
|
//radioGAteways functions
|
|
#region radio safeDispatches
|
|
private void ShowRadioGWs()
|
|
{
|
|
if (!cbGWType.Items.Contains(GatewayType.Broadband.ToString()))
|
|
{
|
|
if (!MainForm.hideLinxFeatures && !DB.HasLinxGateway())
|
|
cbGWType.Items.Add(GatewayType.Broadband.ToString());
|
|
}
|
|
else
|
|
{
|
|
if(DB.HasLinxGateway())
|
|
{
|
|
foreach (var item in cbGWType.Items.ToList())
|
|
{
|
|
if(item.Text.ToString() == GatewayType.Broadband.ToString())
|
|
cbGWType.Items.Remove(item);
|
|
}
|
|
}
|
|
|
|
}
|
|
if (isrepeaterSW)
|
|
{
|
|
rbSlot1.Visible = true;
|
|
rbSlot2.Visible = true;
|
|
lbImei.Visible = false;
|
|
tbRadioIMEI.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
rbSlot1.Visible = false;
|
|
rbSlot2.Visible = false;
|
|
lbImei.Visible = true;
|
|
tbRadioIMEI.Visible = true;
|
|
}
|
|
GridViewRadioGWList.Rows.Clear();
|
|
if (selectedGW != null)
|
|
{
|
|
radioGwList = DB.gelAllRadioGateways(selectedGW.Id);
|
|
GridViewRadioGWList.DataSource = radioGwList;
|
|
if (radioGwList.Count > 0)
|
|
selectedRadioGW = radioGwList[0];
|
|
else
|
|
{
|
|
selectedRadioGW = null;
|
|
selectedRadioZone = null;
|
|
selectedRadioChannel = null;
|
|
}
|
|
lbAddRGW.Text = selectedGW.Ip.ToString();
|
|
|
|
}
|
|
else lbAddRGW.Text = "";
|
|
ShowRadioZones();
|
|
}
|
|
|
|
private void GridViewRadioGWList_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex > -1)
|
|
{
|
|
selectedRadioGW = (RadioGateway)radioGwList[e.RowIndex];
|
|
}
|
|
ShowRadioZones();
|
|
}
|
|
|
|
internal static bool IsValidIP(string addr)
|
|
{
|
|
//create an IPAddress variable, TryParse
|
|
//requires an "out" value that is of
|
|
//the type IPAddress
|
|
IPAddress ip;
|
|
//boolean variable to hold the status
|
|
bool valid = false;
|
|
//check to make sure an ip address was provided
|
|
if (string.IsNullOrEmpty(addr))
|
|
{
|
|
//address wasnt provided so return false
|
|
valid = false;
|
|
}
|
|
else
|
|
{
|
|
//use TryParse to see if this is a
|
|
//valid ip address. TryParse returns a
|
|
//boolean based on the validity of the
|
|
//provided address, so assign that value
|
|
//to our boolean variable
|
|
valid = IPAddress.TryParse(addr, out ip);
|
|
}
|
|
//return the value
|
|
return valid;
|
|
}
|
|
|
|
private void btnRadioGWadd_Click(object sender, EventArgs e)
|
|
{
|
|
if(gwList.Count > 0)
|
|
addEditRadioGatewayAsync();
|
|
else
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("AddGatewayFirst"), MainForm.returnLNGString("err"));
|
|
}
|
|
|
|
private async void addEditRadioGatewayAsync()
|
|
{
|
|
await Task.Run(() => addEditRadioGateway());
|
|
}
|
|
private void addEditRadioGateway()
|
|
{
|
|
if(MainForm.radioType == RADIOTYPE.LINX)
|
|
{
|
|
if (DB.HasLinxGateway() && !ModifyMode)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("brbonly"), MainForm.returnLNGString("warning"));
|
|
return;
|
|
}
|
|
}
|
|
TurnModifyGWOFF();
|
|
if (MainForm.TestIP(tbGwIP.Text))
|
|
{
|
|
int test = 0;
|
|
int testSubID = 0;
|
|
if (!isrepeaterSW)
|
|
{
|
|
if (!Int32.TryParse(tbRadioIMEI.Text, out test))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("imeiInt"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
}
|
|
if (!Int32.TryParse(tbSubID.Text, out testSubID))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("subint"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
if (!IsValidIP(tbRadioGWip.Text))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Invalid IP address", MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
int radioImei = 1;
|
|
if (isrepeaterSW)
|
|
{
|
|
if (rbSlot2.IsChecked) radioImei = 2;
|
|
if (!ModifyMode)
|
|
{
|
|
if (radioGwList.Count > 0)
|
|
{
|
|
foreach (RadioGateway obj in radioGwList)
|
|
{
|
|
if (obj.Ip.CompareTo(tbRadioGWip.Text) != 0)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("sameip"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
if (obj.Imei == radioImei)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("slotneedtobeunique"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (radioGwList.Count > 0)
|
|
{
|
|
foreach (RadioGateway obj in radioGwList)
|
|
{
|
|
if ((obj.Ip.CompareTo(tbRadioGWip.Text) != 0) && (obj.Id != IdTochange))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("sameip"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
if ((obj.Imei == radioImei) && (obj.Id != IdTochange))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("slotneedtobeunique"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
radioImei = Convert.ToInt32(tbRadioIMEI.Text);
|
|
if (!ModifyMode)
|
|
{
|
|
if (radioGwList.Count > 0)
|
|
{
|
|
foreach (RadioGateway obj in radioGwList)
|
|
if (obj.Ip.CompareTo(tbRadioGWip.Text) == 0)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("uniqueIP"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (radioGwList.Count > 0)
|
|
{
|
|
foreach (RadioGateway obj in radioGwList)
|
|
if ((obj.Ip.CompareTo(tbRadioGWip.Text) == 0) && (obj.Id != IdTochange))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("uniqueIP"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int voice = (checkBvoice.Checked) ? 1 : 0;
|
|
if ((MainForm.radioType == RADIOTYPE.MOTO) || (MainForm.radioType == RADIOTYPE.TETRA) || (MainForm.radioType == RADIOTYPE.CONECTPLUS) || (MainForm.radioType == RADIOTYPE.REPEATER_TRBO)) testSubID = 12;
|
|
if (ModifyMode)
|
|
{
|
|
#region test gateway radio id is unique
|
|
//if (cbGWType.Text == GatewayType.Tier3Radio.ToString() || cbGWType.Text == GatewayType.Broadband.ToString())
|
|
//{
|
|
// if (DBcontact.isSipDuplicate(Convert.ToInt32(tbRadioIMEI.Text), (int)ContactType.GPS_ID, IdTochange))
|
|
// {
|
|
// CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("IdAlreadyUsed"), MainForm.returnLNGString("err"));
|
|
// return;
|
|
// }
|
|
//}
|
|
#endregion
|
|
sqlResponse resp = DB.editRadioGateway(tbRadioGWip.Text, radioImei, selectedGW.Id, voice, testSubID, IdTochange, tbRadioGWName.Text, (int)((GatewayType)(Enum.Parse(typeof(GatewayType), cbGWType.Text))));
|
|
//MainForm.CallWebServer(MainForm.RestartSipLink);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("radinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
else
|
|
{
|
|
if ((!OldVoiceStatus) && (voice == 1)) DB.addNewGatewayToAllUser();
|
|
if ((OldVoiceStatus) && (voice == 0)) DB.deleteRadioToAllUser(IdTochange);
|
|
TurnModifyOFF();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#region test gateway radio id is unique
|
|
//if (cbGWType.Text == GatewayType.Tier3Radio.ToString() || cbGWType.Text == GatewayType.Broadband.ToString())
|
|
//{
|
|
// if (DBcontact.isSipDuplicate(Convert.ToInt32(tbRadioIMEI.Text)))
|
|
// {
|
|
// CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("IdAlreadyUsed"), MainForm.returnLNGString("err"));
|
|
// return;
|
|
// }
|
|
//}
|
|
#endregion
|
|
sqlResponse resp = DB.addRadioGateway(tbRadioGWip.Text, radioImei, selectedGW.Id, voice, testSubID, tbRadioGWName.Text, (int)((GatewayType)(Enum.Parse(typeof(GatewayType), cbGWType.Text))));
|
|
//MainForm.CallWebServer(MainForm.RestartSipLink);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("radinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
else
|
|
{
|
|
if (voice == 1) DB.addNewGatewayToAllUser();
|
|
if (isrepeaterSW) DB.add_Zone_and_Channel_for_Repeater();
|
|
}
|
|
}
|
|
this.Invoke((MethodInvoker)delegate
|
|
{
|
|
((MainForm)this.Parent.Parent).setVisibleSipRestartNotification();
|
|
ShowRadioGWs();
|
|
});
|
|
}
|
|
else CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("errorIPFormat"), MainForm.returnLNGString("err"));
|
|
}
|
|
|
|
private void btnRadioGWDeleteSelected_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if (selectedRadioGW != null)
|
|
{
|
|
DialogResult dr = CustomMessageBox.Show(CustomMessageBoxType.exclamation, String.Format(MainForm.returnLNGString("aredelradgw"), selectedRadioGW.Ip), MainForm.returnLNGString("confdelete"), true);
|
|
if (dr == DialogResult.Yes && GridViewRadioGWList.Rows.Count() != 1)
|
|
{
|
|
//--DB.deleteRadioGatewayAndUserConection(selectedRadioGW.Id);
|
|
DB.deleteRadioGateway(selectedRadioGW.Id);
|
|
|
|
//--DB.deleteRadioGatewayAndVehicleConection(selectedRadioGW.Id);
|
|
//MainForm.CallWebServer(MainForm.RestartSipLink);
|
|
|
|
string rgwid = selectedGW.Id + "." + selectedRadioGW.Id;
|
|
dbpatch.deletePatchFromAdmin(1, rgwid);
|
|
|
|
}
|
|
else if(dr == DialogResult.Yes && GridViewRadioGWList.Rows.Count() == 1)
|
|
{
|
|
DialogResult dr2 = CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("aredelradgw2"), MainForm.returnLNGString("confdelete"), true);
|
|
if (dr2 == DialogResult.Yes)
|
|
{
|
|
DB.deleteRadioGateway(selectedRadioGW.Id);
|
|
string rgwid = selectedGW.Id + "." + selectedRadioGW.Id;
|
|
dbpatch.deletePatchFromAdmin(1, rgwid);
|
|
}
|
|
}
|
|
}
|
|
ShowRadioGWs();
|
|
}
|
|
#endregion
|
|
|
|
//zones function
|
|
#region zones
|
|
private void ShowRadioZones()
|
|
{
|
|
GridViewRadioZOnesList.Rows.Clear();
|
|
if (selectedRadioGW != null)
|
|
{
|
|
radioZonesList = DB.gelAllradioZones(selectedRadioGW.Id);
|
|
GridViewRadioZOnesList.DataSource = radioZonesList;
|
|
|
|
// highlight the last inserted row and select it
|
|
if (radioZonesList.Count > 0)
|
|
{
|
|
selectedRadioZone = radioZonesList[radioZonesList.Count - 1];
|
|
GridViewRadioZOnesList.ClearSelection();
|
|
GridViewRadioZOnesList.Rows[radioZonesList.Count - 1].IsCurrent = true;
|
|
GridViewRadioZOnesList.Rows[radioZonesList.Count - 1].IsSelected = true;
|
|
}
|
|
else
|
|
{
|
|
selectedRadioZone = null;
|
|
selectedRadioChannel = null;
|
|
}
|
|
lbAddZone.Text = selectedRadioGW.Ip.ToString();
|
|
}
|
|
else lbAddZone.Text = "";
|
|
|
|
/*
|
|
if (GridViewRadioZOnesList.RowCount > 0) {
|
|
GridViewRadioZOnesList.ClearSelection();
|
|
GridViewRadioZOnesList.row
|
|
= GridViewRadioZOnesList.RowCount - 1;
|
|
}*/
|
|
|
|
ShowRadioChannels();
|
|
}
|
|
|
|
|
|
private void btnAddZone_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if(selectedRadioGW !=null)
|
|
{
|
|
int zoneNR = -1;
|
|
if (!Int32.TryParse(tbZoneNR.Text, out zoneNR))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Zone Nr must be a number!", MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
if(zoneNR<1)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Zone Nr must be a positive number greater than 0!", MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
//int zoneNR = Convert.ToInt32(tbZoneNR.Text);
|
|
string zoneNAme = tbZoneName.Text;
|
|
sqlResponse resp = DB.addRadioZone(zoneNR,zoneNAme, selectedRadioGW.Id);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
// MainForm.returnLNGString("radinDB"), MainForm.returnLNGString("err")
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("zoneinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
ShowRadioZones();
|
|
}
|
|
}
|
|
|
|
private void btnRadioZoneDeleteSelected_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if (selectedRadioZone != null)
|
|
{
|
|
DialogResult dr = CustomMessageBox.Show(CustomMessageBoxType.exclamation, String.Format(MainForm.returnLNGString("aredelzn"), selectedRadioZone.Name), MainForm.returnLNGString("confdelete"), true);
|
|
if (dr == DialogResult.Yes)
|
|
DB.deleteRadioZone(selectedRadioZone.Id);
|
|
}
|
|
ShowRadioZones();
|
|
}
|
|
|
|
private void GridViewRadioZOnesList_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex > -1)
|
|
{
|
|
selectedRadioZone = (RadioZones)radioZonesList[e.RowIndex];
|
|
}
|
|
ShowRadioChannels();
|
|
}
|
|
|
|
#endregion
|
|
|
|
//channels funstions
|
|
#region channels
|
|
private void ShowRadioChannels()
|
|
{
|
|
GridViewRadioChannelList.Rows.Clear();
|
|
if (selectedRadioZone != null)
|
|
{
|
|
radioChannelsList = DB.gelAllradioChannels(selectedRadioZone.Id);
|
|
GridViewRadioChannelList.DataSource = radioChannelsList;
|
|
if (radioChannelsList.Count > 0)
|
|
selectedRadioChannel = radioChannelsList[0];
|
|
else
|
|
selectedRadioChannel = null;
|
|
lbAddChannel.Text = selectedRadioZone.Name;
|
|
}
|
|
else lbAddChannel.Text = "";
|
|
}
|
|
private void btnChannelAdd_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if (selectedRadioZone != null)
|
|
{
|
|
int channelNR = -1;
|
|
if (!Int32.TryParse(tbChannelNr.Text, out channelNR))
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Channel Nr must be a number!", MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
if (channelNR < 1)
|
|
{
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Channel Nr must be a number greater than 0!", MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
|
|
sqlResponse resp= DB.addRadioChannel(channelNR,tbChannelName.Text, selectedRadioZone.Id);
|
|
if (resp == sqlResponse.SQLerror)
|
|
{
|
|
SM.Debug("resp = " + resp.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("chinDB"), MainForm.returnLNGString("err"));
|
|
}
|
|
ShowRadioChannels();
|
|
}
|
|
}
|
|
|
|
private void btnRadioChannelDeleteSelected_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
if (selectedRadioChannel != null)
|
|
{
|
|
DialogResult dr = CustomMessageBox.Show(CustomMessageBoxType.exclamation, String.Format(MainForm.returnLNGString("aredelch"),selectedRadioChannel.Name) , MainForm.returnLNGString("confdelete"), true);
|
|
if (dr == DialogResult.Yes)
|
|
DB.deleteRadioChannel(selectedRadioChannel.Id);
|
|
}
|
|
ShowRadioChannels();
|
|
}
|
|
|
|
private void GridViewRadioChannelList_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex > -1)
|
|
{
|
|
selectedRadioChannel = (RadioChannels)radioChannelsList[e.RowIndex];
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void radSplitContainer1_Resize(object sender, EventArgs e)
|
|
{
|
|
splitPanel1.Size = new Size(radSplitContainer1.Width/4, splitPanel1.Height);
|
|
splitPanel2.Size = new Size(radSplitContainer1.Width / 4, splitPanel1.Height);
|
|
splitPanel3.Size = new Size(radSplitContainer1.Width / 4, splitPanel1.Height);
|
|
splitPanel4.Size = new Size(radSplitContainer1.Width / 4, splitPanel1.Height);
|
|
}
|
|
|
|
private void GridViewGWList_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
GridCellElement cellElement = e.CellElement;
|
|
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
|
|
|
|
if (cellElement == null || columnInfo == null)
|
|
return;
|
|
|
|
// do not draw border
|
|
cellElement.DrawBorder = false;
|
|
|
|
// do not highlight the cell on which was clicked
|
|
if (e.CellElement.IsCurrent)
|
|
{
|
|
e.CellElement.IsCurrent = false;
|
|
}
|
|
}
|
|
|
|
private void GridViewRadioGWList_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
/*
|
|
if (MainForm.radioType == RADIOTYPE.HYT)
|
|
{
|
|
e.CellElement.DrawBorder = true;
|
|
e.CellElement.BorderColor = Color.FromArgb(255, 207, 207, 207);
|
|
e.CellElement.BorderGradientStyle = Telerik.WinControls.GradientStyles.Solid;
|
|
e.CellElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
|
|
}*/
|
|
|
|
GridCellElement cellElement = e.CellElement;
|
|
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
|
|
|
|
if (cellElement == null || columnInfo == null)
|
|
return;
|
|
|
|
// do not draw border
|
|
cellElement.DrawBorder = false;
|
|
|
|
// do not highlight the cell on which was clicked
|
|
if (e.CellElement.IsCurrent)
|
|
{
|
|
e.CellElement.IsCurrent = false;
|
|
}
|
|
|
|
if (e.CellElement.ColumnInfo.Name == "Gw_voice")
|
|
{
|
|
cellElement.DrawText = true;
|
|
|
|
cellElement.ForeColor = Color.FromArgb(190, 36, 36);
|
|
|
|
if (e.CellElement.Text.Equals("1") || e.CellElement.Text.Equals("Yes"))
|
|
{
|
|
e.CellElement.Text = "Yes";
|
|
cellElement.ForeColor = Color.FromArgb(32, 136, 0);
|
|
}
|
|
else
|
|
e.CellElement.Text = "No";
|
|
}
|
|
}
|
|
|
|
private void GridViewRadioZOnesList_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
GridCellElement cellElement = e.CellElement;
|
|
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
|
|
|
|
if (cellElement == null || columnInfo == null)
|
|
return;
|
|
|
|
// do not draw border
|
|
cellElement.DrawBorder = false;
|
|
|
|
// do not highlight the cell on which was clicked
|
|
if (e.CellElement.IsCurrent)
|
|
{
|
|
e.CellElement.IsCurrent = false;
|
|
}
|
|
}
|
|
|
|
private void GridViewRadioChannelList_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
GridCellElement cellElement = e.CellElement;
|
|
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
|
|
|
|
if (cellElement == null || columnInfo == null)
|
|
return;
|
|
|
|
// do not draw border
|
|
cellElement.DrawBorder = false;
|
|
|
|
// do not highlight the cell on which was clicked
|
|
if (e.CellElement.IsCurrent)
|
|
{
|
|
e.CellElement.IsCurrent = false;
|
|
}
|
|
}
|
|
private Int32 IdTochange = -1;
|
|
private Boolean ModifyMode = false;
|
|
private Int32 IdGWTochange = -1;
|
|
private Boolean ModifyGWMode = false;
|
|
private Boolean OldVoiceStatus = false;
|
|
|
|
private void btEditSelected_Click(object sender, EventArgs e)
|
|
{
|
|
if (selectedRadioGW != null)
|
|
{
|
|
if (!cbGWType.Items.Contains(GatewayType.Broadband.ToString()))
|
|
{
|
|
if (DB.IsTheLinxGateway(selectedRadioGW.Id))
|
|
cbGWType.Items.Add(GatewayType.Broadband.ToString());
|
|
}
|
|
else
|
|
{
|
|
if (DB.HasLinxGateway())
|
|
{
|
|
foreach (var item in cbGWType.Items.ToList())
|
|
{
|
|
if (item.Text.ToString() == GatewayType.Broadband.ToString())
|
|
cbGWType.Items.Remove(item);
|
|
}
|
|
}
|
|
|
|
}
|
|
tbRadioGWip.Text = selectedRadioGW.Ip;
|
|
tbRadioIMEI.Text = selectedRadioGW.Imei.ToString();
|
|
tbSubID.Text = selectedRadioGW.Subnetwork.ToString();
|
|
IdTochange = selectedRadioGW.Id;
|
|
tbRadioGWName.Text = selectedRadioGW.Name;
|
|
cbGWType.SelectedIndex = selectedRadioGW.Type;
|
|
ModifyMode = true;
|
|
if (selectedRadioGW.Gw_voice == 1)
|
|
{
|
|
checkBvoice.Checked = true;
|
|
OldVoiceStatus = true;
|
|
}
|
|
else
|
|
{
|
|
checkBvoice.Checked = false;
|
|
OldVoiceStatus = false;
|
|
}
|
|
if (isrepeaterSW)
|
|
{
|
|
if (selectedRadioGW.Imei == 1) rbSlot1.IsChecked = true;
|
|
else rbSlot2.IsChecked = true;
|
|
}
|
|
btnRadioGWadd.Text = MainForm.returnLNGString("modify");
|
|
}
|
|
//ShowRadioGWs();
|
|
}
|
|
private void TurnModifyOFF()
|
|
{
|
|
ModifyMode = false;
|
|
this.Invoke((MethodInvoker)delegate
|
|
{
|
|
btnRadioGWadd.Text = MainForm.returnLNGString("add");
|
|
});
|
|
}
|
|
|
|
private void TurnModifyGWOFF()
|
|
{
|
|
ModifyGWMode = false;
|
|
this.Invoke((MethodInvoker)delegate
|
|
{
|
|
btnAddGW.Text = MainForm.returnLNGString("add");
|
|
});
|
|
}
|
|
|
|
private void GridViewRadioZOnesList_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
}
|
|
|
|
private void GridViewRadioChannelList_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
}
|
|
|
|
private void GridViewGWList_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
}
|
|
|
|
private void GridViewRadioGWList_Click(object sender, EventArgs e)
|
|
{
|
|
TurnModifyOFF();
|
|
TurnModifyGWOFF();
|
|
}
|
|
|
|
private void ckRepeaterGateway_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
if (ckRepeaterGateway.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
|
|
{
|
|
tbPeerID.Enabled = true;
|
|
if (tbPeerID.Value == 0) tbPeerID.Value = 1;
|
|
tbPeerID.Minimum = 1;
|
|
}
|
|
else
|
|
{
|
|
tbPeerID.Minimum = 0;
|
|
tbPeerID.Value = 0;
|
|
tbPeerID.Enabled = false;
|
|
}
|
|
}
|
|
|
|
private void btEditGateway_Click(object sender, EventArgs e)
|
|
{
|
|
if (selectedGW != null)
|
|
{
|
|
tbGwIP.Text = selectedGW.Ip;
|
|
if (selectedGW.Peer_id == 0)
|
|
{
|
|
ckRepeaterGateway.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off;
|
|
tbPeerID.Minimum = 0;
|
|
tbPeerID.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
ckRepeaterGateway.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
|
|
tbPeerID.Minimum = 1;
|
|
tbPeerID.Enabled = true;
|
|
}
|
|
tbPeerID.Value = selectedGW.Peer_id;
|
|
IdGWTochange = selectedGW.Id;
|
|
cbActive.Checked = selectedGW.Active;
|
|
ModifyGWMode = true;
|
|
|
|
btnAddGW.Text = MainForm.returnLNGString("modify");
|
|
SetAvailableGW();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Change background color for the row according to its state and theme
|
|
/// </summary>
|
|
private void grid_RowFormatting(object sender, RowFormattingEventArgs e)
|
|
{
|
|
e.RowElement.DrawFill = true;
|
|
e.RowElement.NumberOfColors = 1;
|
|
|
|
if (e.RowElement.IsSelected)
|
|
e.RowElement.BackColor = MainForm.GridSelectedRow;
|
|
else
|
|
e.RowElement.BackColor = (e.RowElement.RowInfo.Index % 2 == 0 ? Color.White : MainForm.GridAlternateRow);
|
|
}
|
|
|
|
private void ValidateNumericInput(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (char.IsNumber(e.KeyChar))
|
|
{ }
|
|
else
|
|
{
|
|
e.Handled = e.KeyChar != (char)Keys.Back;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|