1063 lines
45 KiB
C#
1063 lines
45 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.UI;
|
|||
|
using Telerik.WinControls;
|
|||
|
using System.Collections;
|
|||
|
using Telerik.WinControls.Primitives;
|
|||
|
using System.IO;
|
|||
|
using SafeMobileLib.DBmanagers;
|
|||
|
using System.Globalization;
|
|||
|
|
|||
|
namespace SubscriberAndUserManager
|
|||
|
{
|
|||
|
public partial class controlUser : UserControl
|
|||
|
{
|
|||
|
private SafeMobileLib.IconTheme crtUserIconTheme = SafeMobileLib.IconTheme.CLASSIC;
|
|||
|
private DBuserManager DBusr;
|
|||
|
private DBvehiclesManager DBveh;
|
|||
|
private DBgatewaysManager DBgateway;
|
|||
|
private DBsettingsManager DBsettings;
|
|||
|
private DBgroupsManager DBgrp;
|
|||
|
private DBiconsManager DBIcons;
|
|||
|
private List<User> users;
|
|||
|
public User selectedUser;
|
|||
|
private int selUSerId;
|
|||
|
private String setForuser = "";
|
|||
|
private String AssingTouser = "";
|
|||
|
private String AssingTogateway = "";
|
|||
|
private String Toword = "";
|
|||
|
public static int ticketingAdminCount = 0;
|
|||
|
public static DateTime ReportimeOldValue;
|
|||
|
private BindingList<DropListItem> iconThemesList;
|
|||
|
|
|||
|
private void setLanguage()
|
|||
|
{
|
|||
|
radPageUsers.Text = MainForm.returnLNGString("assunittouse");
|
|||
|
radPageGroups.Text = MainForm.returnLNGString("AssignedGroupsToUser");
|
|||
|
lblUsersAssignedGroups.Text = MainForm.returnLNGString("AssignedGroups");
|
|||
|
lblUsersOtherGroups.Text = MainForm.returnLNGString("UnassignedGroups");
|
|||
|
gbGatewayForUser.Text = MainForm.returnLNGString("assgwtouse");
|
|||
|
lbUserAssignedVehicles.Text = MainForm.returnLNGString("assignunits");
|
|||
|
AssingTouser = MainForm.returnLNGString("assignunits");
|
|||
|
lbUserOtherVehicles.Text = MainForm.returnLNGString("unassignunits");
|
|||
|
lbUserAssignedGateways.Text = MainForm.returnLNGString("assigngw");
|
|||
|
AssingTogateway = MainForm.returnLNGString("assigngw");
|
|||
|
lbUserOtherGateways.Text = MainForm.returnLNGString("unassigngw");
|
|||
|
GridViewUserList.Columns[0].HeaderText = MainForm.returnLNGString("usetype");
|
|||
|
GridViewUserList.Columns[1].HeaderText = MainForm.returnLNGString("usename");
|
|||
|
GridViewUserList.Columns[2].HeaderText = MainForm.returnLNGString("firstname");
|
|||
|
GridViewUserList.Columns[3].HeaderText = MainForm.returnLNGString("lastname");
|
|||
|
GridViewUserList.Columns["Id"].IsVisible = !MainForm.hideLinxFeatures;
|
|||
|
gbStartItems.Text = MainForm.returnLNGString("startitem");
|
|||
|
gbHistory.Text = MainForm.returnLNGString("hist");
|
|||
|
Toword = MainForm.returnLNGString("to");
|
|||
|
//Japan
|
|||
|
if (MainForm.Langidx == 6) Toword = "";
|
|||
|
|
|||
|
chBCheck.Text = MainForm.returnLNGString("disponly");
|
|||
|
lbTime.Text = "(" + MainForm.returnLNGString("min") + ")";
|
|||
|
chBDispName.Text = MainForm.returnLNGString("namedisp");
|
|||
|
|
|||
|
chBcomputeAdr.Text = MainForm.returnLNGString("compadd");
|
|||
|
lbHisPlayTIme.Text = MainForm.returnLNGString("playt");
|
|||
|
lbHisPauseTime.Text = MainForm.returnLNGString("pauset");
|
|||
|
radLabel1.Text = MainForm.returnLNGString("minspd");
|
|||
|
|
|||
|
lbStartLat.Text = MainForm.returnLNGString("stlat");
|
|||
|
lbStartLng.Text = MainForm.returnLNGString("stlng");
|
|||
|
lbStartZoom.Text = MainForm.returnLNGString("stzoom");
|
|||
|
lbUnitsType.Text = MainForm.returnLNGString("units");
|
|||
|
lbTimeFormat.Text = MainForm.returnLNGString("timeFormat");
|
|||
|
setForuser = MainForm.returnLNGString("setforUser");
|
|||
|
radRepTime.Text = MainForm.returnLNGString("reportTime");
|
|||
|
gbIconType.HeaderText = gbIconType.Text = MainForm.returnLNGString("IconsType");
|
|||
|
rbUnitPic.Text = MainForm.returnLNGString("UnitPictures");
|
|||
|
rbColor.Text = MainForm.returnLNGString("ColoredArrows");
|
|||
|
rbEmerg.Text = MainForm.returnLNGString("EmergencyPeople");
|
|||
|
radLabel4.Text = MainForm.returnLNGString("IconTheme");
|
|||
|
lbVehicleOtherUsers.Text = MainForm.returnLNGString("unassigngw");
|
|||
|
// gbUserInfo.Text = "";
|
|||
|
|
|||
|
cbUnits.Items.Clear();
|
|||
|
cbUnits.Items.Add(MainForm.returnLNGString("kmh"));
|
|||
|
cbUnits.Items.Add(MainForm.returnLNGString("mph"));
|
|||
|
cbTimeFormat.Items.Clear();
|
|||
|
cbTimeFormat.Items.Add(MainForm.returnLNGString("ampm"));
|
|||
|
cbTimeFormat.Items.Add(MainForm.returnLNGString("24h"));
|
|||
|
}
|
|||
|
|
|||
|
public controlUser(DBuserManager DBuser, DBvehiclesManager DBveh, DBiconsManager DBIcons, DBsettingsManager DBsettings, DBgatewaysManager DBgateway, DBgroupsManager DBgrp)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
//GridViewUserList.SelectionMode = GridViewSelectionMode.FullRowSelect;
|
|||
|
this.DBusr = DBuser;
|
|||
|
this.DBveh = DBveh;
|
|||
|
this.DBsettings = DBsettings;
|
|||
|
this.DBgrp = DBgrp;
|
|||
|
this.DBgateway = DBgateway;
|
|||
|
this.DBIcons = DBIcons;
|
|||
|
setLanguage();
|
|||
|
|
|||
|
ShowUsers();
|
|||
|
Utils.WriteLine("Loaded users");
|
|||
|
showCurrentVehicle(selectedUser);
|
|||
|
Utils.WriteLine("Loaded assigned units");
|
|||
|
showOtherVehicle(selectedUser);
|
|||
|
Utils.WriteLine("Loaded other units");
|
|||
|
showCurrentGateway(selectedUser);
|
|||
|
Utils.WriteLine("Loaded assigned gateways ");
|
|||
|
showOtherGateways(selectedUser);
|
|||
|
Utils.WriteLine("Loaded other gateways");
|
|||
|
rdtReportTime.Value = DateTime.Today;
|
|||
|
showCurrentGroups(selectedUser);
|
|||
|
showOtherGroups(selectedUser);
|
|||
|
UpdateFields();
|
|||
|
Utils.WriteLine("done updating fields");
|
|||
|
PopulateIconThemes(selectedUser);
|
|||
|
|
|||
|
gbGatewayForUser.Visible = MainForm.radioType != RADIOTYPE.LINX;
|
|||
|
// set the row height
|
|||
|
GridViewUserList.TableElement.RowHeight = 43;
|
|||
|
this.GridViewUserList.EnableAlternatingRowColor = true;
|
|||
|
this.GridViewUserList.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|||
|
|
|||
|
// remove border for grid
|
|||
|
this.GridViewUserList.GridViewElement.DrawBorder = false;
|
|||
|
this.GridViewUserList.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|||
|
radPageGroups.Item.Visibility = !MainForm.hideLinxFeatures ? ElementVisibility.Visible : ElementVisibility.Collapsed;
|
|||
|
}
|
|||
|
|
|||
|
private void ShowUsers()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
users = DBusr.getAllUsers();
|
|||
|
ticketingAdminCount = users.Count(item => item.UType == USERTYPE.TicketingAdmin);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("dberr"), MainForm.returnLNGString("err"));
|
|||
|
return;
|
|||
|
}
|
|||
|
GridViewUserList.DataSource = users;
|
|||
|
if (users.Count > 0)
|
|||
|
{
|
|||
|
selectedUser = users[0];
|
|||
|
selUSerId = users[0].Id;
|
|||
|
if (selectedUser.UType == USERTYPE.Admin /*|| selectedUser.UType == USERTYPE.TicketingAdmin*/) groupBoxesEnableManagement(false);
|
|||
|
else groupBoxesEnableManagement(true);
|
|||
|
|
|||
|
gbUserInfo.Text = setForuser + " " + ((User)users[0]).UserName.ToUpper();
|
|||
|
}
|
|||
|
}
|
|||
|
//show current vehicles for user
|
|||
|
private void showCurrentVehicle(User usr)
|
|||
|
{
|
|||
|
if (usr != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<Vehicles> vehs = DBveh.getAllVehiclesForCurrentUser(usr.Id.ToString());
|
|||
|
|
|||
|
listBoxCurentVehicles.DataSource = vehs;
|
|||
|
listBoxCurentVehicles.DisplayMember = "VehName";
|
|||
|
//int temp = lbUserAssignedVehicles.Text.IndexOf("to");
|
|||
|
//string text = (temp > 0) ? lbUserAssignedVehicles.Text.Remove(temp) : lbUserAssignedVehicles.Text;
|
|||
|
|
|||
|
//Toword
|
|||
|
radPageUsers.Text = AssingTouser + " " + Toword + " " + usr.UserName.ToUpper();
|
|||
|
/*if ((MainForm.culture.Name.StartsWith("en")))
|
|||
|
lbUserAssignedVehicles.Text = AssingTouser + " to " + usr.UserName;
|
|||
|
else lbUserAssignedVehicles.Text = AssingTouser + " " + usr.UserName;*/
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//show other vehicles
|
|||
|
private void showOtherVehicle(User usr)
|
|||
|
{
|
|||
|
if (usr != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
listBoxOtherVehicles.BeginUpdate();
|
|||
|
List<Vehicles> vehs = DBveh.getAllOtherVehiclesForCurrentUser(usr.Id.ToString());
|
|||
|
listBoxOtherVehicles.DataSource = vehs;
|
|||
|
listBoxOtherVehicles.DisplayMember = "VehName";
|
|||
|
listBoxOtherVehicles.EndUpdate();
|
|||
|
//lbUserOtherVehicles.Text = lbUserOtherVehicles.Text.Split('f')[0] + "for " + _selectedUser.getUserValue("userName");
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//show current vehicles for user
|
|||
|
private void showCurrentGateway(User usr)
|
|||
|
{
|
|||
|
if (usr != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<GatewayForUser> vehs = DBgateway.getAllGatewaysForCurrentUser(usr.Id.ToString());
|
|||
|
listBoxCurentGateways.DataSource = vehs;
|
|||
|
listBoxCurentGateways.DisplayMember = "Ip_Display";
|
|||
|
//Toword
|
|||
|
gbGatewayForUser.Text = AssingTogateway + " " + Toword + " " + usr.UserName.ToUpper();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//show other vehicles
|
|||
|
private void showOtherGateways(User usr)
|
|||
|
{
|
|||
|
if (usr != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<GatewayForUser> vehs = DBgateway.getAllOtherGatewaysForCurrentUser(usr.Id.ToString());
|
|||
|
listBoxOtherGateways.DataSource = vehs;
|
|||
|
listBoxOtherGateways.DisplayMember = "Ip_Display";
|
|||
|
//lbUserOtherVehicles.Text = lbUserOtherVehicles.Text.Split('f')[0] + "for " + _selectedUser.getUserValue("userName");
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnAddVehicle_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (listBoxOtherVehicles.SelectedIndex != -1)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<String> vehiclesIds = new List<string>();
|
|||
|
foreach (RadListDataItem tmp in listBoxOtherVehicles.SelectedItems)
|
|||
|
{
|
|||
|
Vehicles vehSelected = (Vehicles)tmp.Value;
|
|||
|
vehiclesIds.Add(vehSelected.Id.ToString());
|
|||
|
}
|
|||
|
|
|||
|
DBveh.assignVehiclesToUser(vehiclesIds, selectedUser.Id.ToString());
|
|||
|
|
|||
|
|
|||
|
showOtherVehicle(selectedUser);
|
|||
|
showCurrentVehicle(selectedUser);
|
|||
|
}
|
|||
|
catch (Exception ee)
|
|||
|
{
|
|||
|
//RadMessageBox.Show("error " + ee.ToString(), "error!", MessageBoxButtons.OK, RadMessageIcon.Error);
|
|||
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("adduniterr"), MainForm.returnLNGString("err"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnRemoveVehicle_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (listBoxCurentVehicles.SelectedIndex != -1)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<String> vehiclesIds = new List<string>();
|
|||
|
foreach (RadListDataItem tmp in listBoxCurentVehicles.SelectedItems)
|
|||
|
{
|
|||
|
Vehicles vehSelected = (Vehicles)tmp.Value;
|
|||
|
vehiclesIds.Add(vehSelected.Id.ToString());
|
|||
|
}
|
|||
|
|
|||
|
DBveh.removeVehiclesToUser(vehiclesIds, selectedUser.Id.ToString());
|
|||
|
|
|||
|
//add current vehicles for user
|
|||
|
showCurrentVehicle(selectedUser);
|
|||
|
//add vehicles that ar not asigned
|
|||
|
showOtherVehicle(selectedUser);
|
|||
|
}
|
|||
|
catch (Exception ee)
|
|||
|
{
|
|||
|
//RadMessageBox.Show("error " + ee.ToString(), "error!", MessageBoxButtons.OK, RadMessageIcon.Error);
|
|||
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("rmvunit"), MainForm.returnLNGString("err"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void GridViewUserList_CellClick(object sender, GridViewCellEventArgs e)
|
|||
|
{
|
|||
|
//if (e.RowIndex > -1)
|
|||
|
//{
|
|||
|
// // reset user icon type
|
|||
|
// crtUserIconTheme = IconType.CLASSIC;
|
|||
|
|
|||
|
// SetIconThemeComboBoxValue(crtUserIconTheme);
|
|||
|
|
|||
|
|
|||
|
// selectedUser = (User)users[e.RowIndex];
|
|||
|
// //add current vehicles for user
|
|||
|
// showCurrentVehicle(selectedUser);
|
|||
|
// //add vehicles that ar not asigned
|
|||
|
// showOtherVehicle(selectedUser);
|
|||
|
|
|||
|
// showCurrentGateway(selectedUser);
|
|||
|
// showOtherGateways(selectedUser);
|
|||
|
// showCurrentGroups(selectedUser);
|
|||
|
// showOtherGroups(selectedUser);
|
|||
|
// selUSerId = ((User)users[e.RowIndex]).Id;
|
|||
|
// UpdateFields();
|
|||
|
// if (selectedUser.UType == USERTYPE.Admin || selectedUser.UType == USERTYPE.TicketingAdmin) groupBoxesEnableManagement(false);
|
|||
|
// else groupBoxesEnableManagement(true);
|
|||
|
|
|||
|
// gbUserInfo.Text = setForuser + ": " + ((User)users[e.RowIndex]).UserName;
|
|||
|
//}
|
|||
|
}
|
|||
|
|
|||
|
private void ChangeGridIndex()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void groupBoxesEnableManagement(bool val)
|
|||
|
{
|
|||
|
gbHistory.Enabled = val;
|
|||
|
gbStartItems.Enabled = val;
|
|||
|
radPageUsers.Enabled = val;
|
|||
|
radPageGroups.Enabled = val;
|
|||
|
gbGatewayForUser.Enabled = val;
|
|||
|
}
|
|||
|
/////////////////
|
|||
|
///for settings
|
|||
|
///////////////////////
|
|||
|
|
|||
|
private void UpdateFields()
|
|||
|
{
|
|||
|
Hashtable values = null;
|
|||
|
try
|
|||
|
{
|
|||
|
values = DBsettings.getAllSettings(selUSerId);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
//CustomMessageBox.Show(CustomMessageBoxType.exclamation, "Database connection error!!!", "Error");
|
|||
|
return;
|
|||
|
}
|
|||
|
if (values != null)
|
|||
|
foreach (DictionaryEntry Item in values)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
switch ((string)Item.Key)
|
|||
|
{
|
|||
|
// start items
|
|||
|
case "startLar":
|
|||
|
tbStartLat.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "startLng":
|
|||
|
tbStartLng.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "startZoom":
|
|||
|
{
|
|||
|
decimal dec = 2;
|
|||
|
bool result = Decimal.TryParse(Item.Value+"", out dec);
|
|||
|
tbStartZoom.Value = Convert.ToInt32(dec / Program.GoogleZoomLevel * 100);
|
|||
|
}
|
|||
|
break;
|
|||
|
case "startUnits":
|
|||
|
cbUnits.SelectedIndex = Convert.ToInt32(Item.Value);
|
|||
|
break;
|
|||
|
case "startAddress":
|
|||
|
cbTimeFormat.SelectedIndex = Convert.ToInt32(Item.Value);
|
|||
|
break;
|
|||
|
|
|||
|
//history
|
|||
|
case "hisCompAddr":
|
|||
|
chBcomputeAdr.Checked = Convert.ToBoolean(Item.Value);
|
|||
|
break;
|
|||
|
case "hisPlayTime":
|
|||
|
tbPlayTime.Value = Convert.ToInt32(Item.Value);
|
|||
|
break;
|
|||
|
case "hisPauseTime":
|
|||
|
tbPauseTime.Value = Convert.ToInt32(Item.Value);
|
|||
|
break;
|
|||
|
case "hisMinSpeed":
|
|||
|
{
|
|||
|
Int32 val = Convert.ToInt32(Item.Value);
|
|||
|
tbHisMinSpeed.Value = val > tbHisMinSpeed.Maximum ? tbHisMinSpeed.Maximum : val;
|
|||
|
}
|
|||
|
break;
|
|||
|
/*
|
|||
|
//reports
|
|||
|
case "repDelta1":
|
|||
|
tbDelta1.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "repDelta2":
|
|||
|
tbDelta2.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "repTimer1":
|
|||
|
tbTimer1.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "repTimer2":
|
|||
|
tbTimer2.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "repIdleTime":
|
|||
|
tbIdleTime.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
*/
|
|||
|
|
|||
|
//live
|
|||
|
case "liveCheck":
|
|||
|
chBCheck.Checked = Convert.ToBoolean(Item.Value);
|
|||
|
break;
|
|||
|
case "liveIdleTime":
|
|||
|
tbLiveIdle.Value = Convert.ToInt32(Item.Value);
|
|||
|
break;
|
|||
|
case "liveNameDisplay":
|
|||
|
chBDispName.Checked = Convert.ToBoolean(Item.Value);
|
|||
|
break;
|
|||
|
case "liveMultiColor":
|
|||
|
//chBmultiColor.Checked = Convert.ToBoolean(Item.Value);
|
|||
|
try
|
|||
|
{
|
|||
|
if (Item.Value.ToString() == "0" || Item.Value.ToString() == "1")
|
|||
|
{
|
|||
|
if (Convert.ToBoolean(Convert.ToInt32(Item.Value))) rbColor.IsChecked = true;
|
|||
|
else rbUnitPic.IsChecked = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (Convert.ToBoolean(Item.Value)) rbColor.IsChecked = true;
|
|||
|
else rbUnitPic.IsChecked = true;
|
|||
|
}
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (Convert.ToBoolean(Item.Value)) rbColor.IsChecked = true;
|
|||
|
else rbUnitPic.IsChecked = true;
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (Convert.ToInt32(Item.Value) == 0) rbUnitPic.IsChecked = true;
|
|||
|
else if (Convert.ToInt32(Item.Value) == 1) rbColor.IsChecked = true;
|
|||
|
else rbEmerg.IsChecked = true;
|
|||
|
}
|
|||
|
catch (Exception exe)
|
|||
|
{
|
|||
|
SM.Debug("Error on convert livemulticolor NUMBERS:" + exe.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
break;
|
|||
|
/*
|
|||
|
//voice
|
|||
|
case "voiceSamePC":
|
|||
|
chBSamePC.Checked = Convert.ToBoolean(Item.Value);
|
|||
|
break;
|
|||
|
case "voiceGWip":
|
|||
|
tbVoiceIP.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "voiceGWport":
|
|||
|
tbVoicePort.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "voiceRecvPort":
|
|||
|
tbRecvPort.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "voiceSendPort":
|
|||
|
tbSendPort.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "voiceINdevice":
|
|||
|
tbSoundInDiv.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
case "voiceOUTdevice":
|
|||
|
tbSoundOutDiv.Text = (string)Item.Value;
|
|||
|
break;
|
|||
|
*/
|
|||
|
case "iconTheme":
|
|||
|
{
|
|||
|
crtUserIconTheme = SafeMobileLib.IconTheme.GetIconType(Item.Value.ToString());
|
|||
|
SetIconThemeComboBoxValue(crtUserIconTheme);
|
|||
|
}
|
|||
|
break;
|
|||
|
case "reportTime":
|
|||
|
rdtReportTime.Value = DateTime.Today.AddSeconds(Convert.ToInt64(Item.Value.ToString()));
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Utils.WriteLine("Error on updating fields : " + ex.ToString(), ConsoleColor.Red);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SetIconThemeComboBoxValue(SafeMobileLib.IconTheme iconType)
|
|||
|
{
|
|||
|
int selectedIndex = 0;
|
|||
|
int count = 0;
|
|||
|
if (iconThemesList == null)
|
|||
|
return;
|
|||
|
foreach (DropListItem theme in iconThemesList)
|
|||
|
{
|
|||
|
if (iconType.ToString().Equals(theme.Prefix))
|
|||
|
{
|
|||
|
selectedIndex = count;
|
|||
|
}
|
|||
|
count++;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (rcbIconThemes.Items.Count > selectedIndex)
|
|||
|
{
|
|||
|
rcbIconThemes.SelectedIndex = selectedIndex;
|
|||
|
}
|
|||
|
else if (rcbIconThemes.Items.Count > 0)
|
|||
|
rcbIconThemes.SelectedIndex = 0;
|
|||
|
}
|
|||
|
|
|||
|
public void SaveSettings()
|
|||
|
{
|
|||
|
Console.WriteLine("saving settings for user with id:" + selUSerId);
|
|||
|
Hashtable ht = new Hashtable();
|
|||
|
// start items
|
|||
|
ht.Add("startLar", tbStartLat.Text);
|
|||
|
ht.Add("startLng", tbStartLng.Text);
|
|||
|
ht.Add("startZoom", (tbStartZoom.Value / 100 * Program.GoogleZoomLevel).ToString(CultureInfo.InvariantCulture));
|
|||
|
ht.Add("startUnits", cbUnits.SelectedIndex.ToString());
|
|||
|
ht.Add("startAddress", cbTimeFormat.SelectedIndex.ToString());
|
|||
|
|
|||
|
ht.Add("iconTheme", crtUserIconTheme.ToString());
|
|||
|
TimeSpan span = rdtReportTime.Value - DateTime.Today;
|
|||
|
long nOfSeconds = (long)span.TotalSeconds;
|
|||
|
ht.Add("reportTime", nOfSeconds.ToString());
|
|||
|
//history
|
|||
|
//ht.Add("hisStyle", cbHisStyle.SelectedIndex.ToString());
|
|||
|
ht.Add("hisCompAddr", chBcomputeAdr.Checked.ToString());
|
|||
|
ht.Add("hisPlayTime", tbPlayTime.Value.ToString());
|
|||
|
ht.Add("hisPauseTime", tbPauseTime.Value.ToString());
|
|||
|
//ht.Add("hisTraceState", cbTraceState.SelectedIndex.ToString());
|
|||
|
ht.Add("hisMinSpeed", tbHisMinSpeed.Value.ToString());
|
|||
|
/*
|
|||
|
//reports
|
|||
|
ht.Add("repDelta1", tbDelta1.Text);
|
|||
|
ht.Add("repDelta2", tbDelta2.Text);
|
|||
|
ht.Add("repTimer1", tbTimer1.Text);
|
|||
|
ht.Add("repTimer2", tbTimer2.Text);
|
|||
|
ht.Add("repIdleTime", tbIdleTime.Text);
|
|||
|
*/
|
|||
|
|
|||
|
////live
|
|||
|
ht.Add("liveCheck", chBCheck.Checked.ToString());
|
|||
|
ht.Add("liveIdleTime", tbLiveIdle.Value.ToString());
|
|||
|
ht.Add("liveNameDisplay", chBDispName.Checked.ToString());
|
|||
|
//ht.Add("liveMultiColor", chBmultiColor.Checked.ToString());
|
|||
|
|
|||
|
if (rbUnitPic.IsChecked) ht.Add("liveMultiColor", "0");
|
|||
|
else if (rbColor.IsChecked) ht.Add("liveMultiColor", "1");
|
|||
|
else if (rbEmerg.IsChecked) ht.Add("liveMultiColor", "2");
|
|||
|
|
|||
|
/*
|
|||
|
//voice
|
|||
|
ht.Add("voiceSamePC", chBSamePC.Checked.ToString());
|
|||
|
ht.Add("voiceGWip", tbVoiceIP.Text);
|
|||
|
ht.Add("voiceGWport", tbVoicePort.Text);
|
|||
|
ht.Add("voiceRecvPort", tbRecvPort.Text);
|
|||
|
ht.Add("voiceSendPort", tbSendPort.Text);
|
|||
|
ht.Add("voiceINdevice", tbSoundInDiv.Text);
|
|||
|
ht.Add("voiceOUTdevice", tbSoundOutDiv.Text);
|
|||
|
*/
|
|||
|
|
|||
|
//save
|
|||
|
DBsettings.SaveSettingsForUser(selUSerId, ht);
|
|||
|
UpdateFields();
|
|||
|
Console.WriteLine("save settings done");
|
|||
|
}
|
|||
|
|
|||
|
private void GridViewUserList_CellFormatting(object sender, 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;
|
|||
|
}
|
|||
|
|
|||
|
if (e.CellElement.ColumnInfo.Name == "VehName")
|
|||
|
{
|
|||
|
cellElement.DrawText = true;
|
|||
|
Font font3 = new Font(
|
|||
|
"Segoe UI",
|
|||
|
13,
|
|||
|
FontStyle.Bold,
|
|||
|
GraphicsUnit.Pixel);
|
|||
|
|
|||
|
cellElement.ForeColor = Color.FromArgb(0, 0, 0);
|
|||
|
cellElement.Font = font3;
|
|||
|
}
|
|||
|
else if (e.CellElement.ColumnInfo.Name == "UType")
|
|||
|
{
|
|||
|
cellElement.DrawText = true;
|
|||
|
Font font = new Font(
|
|||
|
cellElement.Font.FontFamily,
|
|||
|
12,
|
|||
|
FontStyle.Bold,
|
|||
|
GraphicsUnit.Pixel);
|
|||
|
|
|||
|
if (e.CellElement.Text.Equals("Admin") || e.CellElement.Text.Equals(MainForm.returnLNGString("admin")))
|
|||
|
{
|
|||
|
cellElement.ForeColor = Color.FromArgb(190, 36, 36);
|
|||
|
cellElement.Font = font;
|
|||
|
cellElement.Text = MainForm.returnLNGString("admin");
|
|||
|
}
|
|||
|
else if (e.CellElement.Text.Equals("Dispatcher") || e.CellElement.Text.Equals(MainForm.returnLNGString("dispatcher")))
|
|||
|
{
|
|||
|
cellElement.ForeColor = Color.FromArgb(32, 136, 0);
|
|||
|
cellElement.Font = font;
|
|||
|
cellElement.Text = MainForm.returnLNGString("dispatcher");
|
|||
|
}
|
|||
|
else if (e.CellElement.Text.Equals("LiteDispatcher") || e.CellElement.Text.Equals(MainForm.returnLNGString("liteDispatcher")))
|
|||
|
{
|
|||
|
cellElement.ForeColor = Color.FromArgb(36, 134, 190);
|
|||
|
cellElement.Font = font;
|
|||
|
cellElement.Text = MainForm.returnLNGString("liteDispatcher");
|
|||
|
}
|
|||
|
else if (e.CellElement.Text.Equals("TicketingAdmin") || e.CellElement.Text.Equals(MainForm.returnLNGString("ticketAdmin")))
|
|||
|
{
|
|||
|
cellElement.ForeColor = Color.FromArgb(36, 134, 190);
|
|||
|
cellElement.Font = font;
|
|||
|
cellElement.Text = MainForm.returnLNGString("ticketAdmin");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cellElement.ForeColor = Color.FromArgb(36, 134, 190);
|
|||
|
cellElement.Font = font;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.CellElement.ColumnInfo.Name == "Icon")
|
|||
|
cellElement.Padding = new Padding(2, 0, 2, 0);
|
|||
|
else
|
|||
|
cellElement.Padding = new Padding(10, 0, 10, 0);
|
|||
|
}
|
|||
|
|
|||
|
private void btnRemoveGateway_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (listBoxCurentGateways.SelectedIndex != -1)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
foreach (RadListDataItem tmp in listBoxCurentGateways.SelectedItems)
|
|||
|
{
|
|||
|
GatewayForUser gwSelected = (GatewayForUser)tmp.Value;
|
|||
|
DBgateway.removeGatewayUserConnection(gwSelected.Id.ToString(), selectedUser.Id.ToString());
|
|||
|
}
|
|||
|
//add current vehicles for user
|
|||
|
showCurrentGateway(selectedUser);
|
|||
|
//add vehicles that ar not asigned
|
|||
|
showOtherGateways(selectedUser);
|
|||
|
}
|
|||
|
catch (Exception ee)
|
|||
|
{
|
|||
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("rmvunit"), MainForm.returnLNGString("err"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnAddGateway_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (listBoxOtherGateways.SelectedIndex != -1)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
foreach (RadListDataItem tmp in listBoxOtherGateways.SelectedItems)
|
|||
|
{
|
|||
|
GatewayForUser vehSelected = (GatewayForUser)tmp.Value;
|
|||
|
DBgateway.addGatewayUserConnection(vehSelected.Id.ToString(), selectedUser.Id.ToString());
|
|||
|
}
|
|||
|
showOtherGateways(selectedUser);
|
|||
|
showCurrentGateway(selectedUser);
|
|||
|
}
|
|||
|
catch (Exception ee)
|
|||
|
{
|
|||
|
//RadMessageBox.Show("error " + ee.ToString(), "error!", MessageBoxButtons.OK, RadMessageIcon.Error);
|
|||
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("adduniterr"), MainForm.returnLNGString("err"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void PopulateIconThemes(User usr)
|
|||
|
{
|
|||
|
|
|||
|
// save which icon should be selected
|
|||
|
int selectedIndex = 0;
|
|||
|
int count = 0;
|
|||
|
iconThemesList = new BindingList<DropListItem>();
|
|||
|
try
|
|||
|
{
|
|||
|
List<SafeMobileLib.DBmanagers.IconTheme> ret = DBIcons.GetIconThemes();
|
|||
|
foreach (SafeMobileLib.DBmanagers.IconTheme theme in ret)
|
|||
|
{
|
|||
|
if (crtUserIconTheme.ToString().Equals(theme.Prefix))
|
|||
|
{
|
|||
|
selectedIndex = count;
|
|||
|
}
|
|||
|
count++;
|
|||
|
|
|||
|
byte[] iconBytes = null;
|
|||
|
|
|||
|
// get unknown image from the resources
|
|||
|
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
|||
|
|
|||
|
using (Stream resFilestream = a.GetManifestResourceStream("SubscriberAndUserManager.Resources." + theme.Prefix + "_default.png"))
|
|||
|
{
|
|||
|
byte[] buffer = new byte[1024];
|
|||
|
using (MemoryStream ms = new MemoryStream())
|
|||
|
{
|
|||
|
while (true)
|
|||
|
{
|
|||
|
int read = resFilestream.Read(buffer, 0, buffer.Length);
|
|||
|
if (read <= 0)
|
|||
|
{
|
|||
|
// reached the end of the resource file
|
|||
|
iconBytes = ms.ToArray();
|
|||
|
break;
|
|||
|
}
|
|||
|
// add read buffer into the memory stream
|
|||
|
ms.Write(buffer, 0, read);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// save the image received from the database to a png file
|
|||
|
Bitmap bmp = new Bitmap(new MemoryStream(iconBytes));
|
|||
|
Image tmp2 = bmp;
|
|||
|
|
|||
|
DropListItem item = new DropListItem()
|
|||
|
{
|
|||
|
ID = theme.Id,
|
|||
|
Name = MainForm.returnLNGString(theme.Name),
|
|||
|
Prefix = theme.Prefix,
|
|||
|
Image = tmp2
|
|||
|
};
|
|||
|
|
|||
|
iconThemesList.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
// add the datasource for the vehicles ComboBox
|
|||
|
rcbIconThemes.DataSource = iconThemesList;
|
|||
|
|
|||
|
//cbVehName.DataSource = vehicleListNames;
|
|||
|
//cbVehName.DisplayMember = "Name";
|
|||
|
if (rcbIconThemes.Items.Count > selectedIndex)
|
|||
|
{
|
|||
|
rcbIconThemes.SelectedIndex = selectedIndex;
|
|||
|
}
|
|||
|
else if (rcbIconThemes.Items.Count > 0)
|
|||
|
rcbIconThemes.SelectedIndex = 0;
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Utils.WriteLine(" POPULATE ICON THEMES" + ex.ToString(), ConsoleColor.Red);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Bind the icon and the name to the combobox
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="args"></param>
|
|||
|
private void rcbIconThemes_ItemDataBound(object sender, ListItemDataBoundEventArgs args)
|
|||
|
{
|
|||
|
// display the text and image for each item in the comboBox
|
|||
|
DropListItem item = (DropListItem)args.NewItem.DataBoundItem;
|
|||
|
args.NewItem.Text = item.Name;
|
|||
|
args.NewItem.Image = Utils.ScaleImage(item.Image, 16, 16);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Execute this method every time the combobox value had changed
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
private void rcbIconThemes_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
|
|||
|
{
|
|||
|
if (iconThemesList.Count > e.Position)
|
|||
|
{
|
|||
|
DropListItem item = (DropListItem)iconThemesList[e.Position];
|
|||
|
crtUserIconTheme = SafeMobileLib.IconTheme.GetIconType(item.Prefix);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void cbTimeFormat_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
|
|||
|
{
|
|||
|
rdtReportTime.CustomFormat = (cbTimeFormat.Text == "AM / PM") ? "hh:mm tt" : "HH:mm";
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Change background color for the row according to its state and theme
|
|||
|
/// </summary>
|
|||
|
private void GridViewUserList_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 listBoxCurentVehicles_ItemDataBound(object sender, ListItemDataBoundEventArgs args)
|
|||
|
{
|
|||
|
Vehicles view = (Vehicles)args.NewItem.DataBoundItem;
|
|||
|
args.NewItem.Text = "<html>" +
|
|||
|
"<b>" + view.VehName + "</b>" +
|
|||
|
"<br>" + "<i>" +
|
|||
|
" " + view.Imei + "</i>";
|
|||
|
|
|||
|
if (MainForm.carImages.ContainsKey(view.ImgID))
|
|||
|
args.NewItem.Image = MainForm.carImages[view.ImgID];//Utils.ScaleImage(MainForm.carImages[view.ImgID], 32, 32);
|
|||
|
}
|
|||
|
|
|||
|
int countListBoxOtherVehicle = 0;
|
|||
|
int countListBoxCurrentVehicle = 0;
|
|||
|
private void listBoxCurentVehicles_CreatingVisualListItem(object sender, CreatingVisualListItemEventArgs args)
|
|||
|
{
|
|||
|
RadListVisualItem visualItem = new RadListVisualItem();
|
|||
|
visualItem.Padding = new Padding(5, 5, 0, 5);
|
|||
|
args.VisualItem = visualItem;
|
|||
|
args.VisualItem.Tag = (sender == listBoxCurentVehicles ? countListBoxCurrentVehicle++ : countListBoxOtherVehicle++);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Remove a vehicle from the assigned vehicles when an item is double
|
|||
|
/// clicked inside the listcontrol
|
|||
|
/// </summary>
|
|||
|
private void listBoxCurentVehicles_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
RadListVisualItem clickedItem = listBoxCurentVehicles.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
|
|||
|
if (clickedItem != null)
|
|||
|
{
|
|||
|
RadListDataItem dataItem = clickedItem.Data;
|
|||
|
btnRemoveVehicle.PerformClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Add a vehicle from the assigned vehicles when an item is double
|
|||
|
/// clicked inside the listcontrol
|
|||
|
/// </summary>
|
|||
|
private void listBoxOtherVehicles_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
RadListVisualItem clickedItem = listBoxOtherVehicles.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
|
|||
|
if (clickedItem != null)
|
|||
|
{
|
|||
|
RadListDataItem dataItem = clickedItem.Data;
|
|||
|
btnAddVehicle.PerformClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Add or remove a gateway when an item is double clicked
|
|||
|
/// </summary>
|
|||
|
private void listBoxGateways_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
RadListVisualItem clickedItem = listBoxCurentVehicles.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
|
|||
|
if (clickedItem != null)
|
|||
|
{
|
|||
|
RadListDataItem dataItem = clickedItem.Data;
|
|||
|
if (sender == listBoxCurentGateways)
|
|||
|
btnRemoveGateway.PerformClick();
|
|||
|
else
|
|||
|
btnAddGateway.PerformClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void listBoxCurentVehicles_VisualItemFormatting(object sender, VisualItemFormattingEventArgs e)
|
|||
|
{
|
|||
|
e.VisualItem.DrawFill = true;
|
|||
|
e.VisualItem.NumberOfColors = 1;
|
|||
|
|
|||
|
if (e.VisualItem.Selected)
|
|||
|
e.VisualItem.BackColor = MainForm.GridSelectedRow;
|
|||
|
else
|
|||
|
e.VisualItem.BackColor = Color.White;
|
|||
|
}
|
|||
|
|
|||
|
private void GridViewUserList_CellDoubleClick(object sender, GridViewCellEventArgs e)
|
|||
|
{
|
|||
|
((MainForm)this.Parent.Parent).btnUserEdit.PerformClick();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#region USER GROUP RELATION
|
|||
|
|
|||
|
private void showCurrentGroups(User user)
|
|||
|
{
|
|||
|
listBoxCurrentGroups.DataSource = null;
|
|||
|
if (user != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<Group> grpList = DBgrp.getAllGroupsForCurrentUser(user.Id.ToString());
|
|||
|
|
|||
|
listBoxCurrentGroups.DataSource = grpList;
|
|||
|
|
|||
|
listBoxCurrentGroups.DisplayMember = "Name";
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void showOtherGroups(User user)
|
|||
|
{
|
|||
|
listBoxOtherGroup.DataSource = null;
|
|||
|
if (user != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
List<Group> grpList = DBgrp.getAllOtherGroupsForCurrentUser(user.Id.ToString());
|
|||
|
listBoxOtherGroup.DataSource = grpList;
|
|||
|
listBoxOtherGroup.DisplayMember = "Name";
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Console.WriteLine(ex.ToString());
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnRemoveGroupFromUser_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
foreach (RadListDataItem tmp in listBoxCurrentGroups.SelectedItems)
|
|||
|
{
|
|||
|
Group grpSelected = (Group)tmp.Value;
|
|||
|
DBgrp.removeUserGroupConnection(selectedUser.Id.ToString(), grpSelected.Id.ToString());
|
|||
|
}
|
|||
|
showCurrentGroups(selectedUser);
|
|||
|
showOtherGroups(selectedUser);
|
|||
|
((MainForm)this.Parent.Parent).setVisibleSipRestartNotification();
|
|||
|
}
|
|||
|
|
|||
|
private void btnAddGroupToUser_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
foreach (RadListDataItem tmp in listBoxOtherGroup.SelectedItems)
|
|||
|
{
|
|||
|
Group grpSelected = (Group)tmp.Value;
|
|||
|
DBgrp.addUserGroupConnection(selectedUser.Id.ToString(), grpSelected.Id.ToString());
|
|||
|
}
|
|||
|
showCurrentGroups(selectedUser);
|
|||
|
showOtherGroups(selectedUser);
|
|||
|
((MainForm)this.Parent.Parent).setVisibleSipRestartNotification();
|
|||
|
}
|
|||
|
|
|||
|
private Image groupImage = Utils.ScaleImage(Properties.Resources.i_group, 32, 32);
|
|||
|
private void groups_ItemDataBound(object sender, ListItemDataBoundEventArgs args)
|
|||
|
{
|
|||
|
Group view = (Group)args.NewItem.DataBoundItem;
|
|||
|
args.NewItem.Text = "<html>" +
|
|||
|
"<b>" + view.Name + "</b>";
|
|||
|
args.NewItem.Image = groupImage;
|
|||
|
}
|
|||
|
|
|||
|
private void listBoxCurrentGroups_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
RadListVisualItem clickedItem = listBoxCurrentGroups.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
|
|||
|
if (clickedItem != null)
|
|||
|
{
|
|||
|
RadListDataItem dataItem = clickedItem.Data;
|
|||
|
btnRemoveGroupFromUser.PerformClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void listBoxOtherGroup_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
RadListVisualItem clickedItem = listBoxOtherGroup.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
|
|||
|
if (clickedItem != null)
|
|||
|
{
|
|||
|
RadListDataItem dataItem = clickedItem.Data;
|
|||
|
btnAddGroupToUser.PerformClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
private void GridViewUserList_SelectionChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (GridViewUserList.SelectedRows.Count > 0)
|
|||
|
{
|
|||
|
// reset user icon type
|
|||
|
crtUserIconTheme = SafeMobileLib.IconTheme.CLASSIC;
|
|||
|
|
|||
|
SetIconThemeComboBoxValue(crtUserIconTheme);
|
|||
|
|
|||
|
int userid = (int)GridViewUserList.SelectedRows[0].Cells["id"].Value;
|
|||
|
|
|||
|
selectedUser = users.Where(x => x.Id == userid).FirstOrDefault();
|
|||
|
//add current vehicles for user
|
|||
|
showCurrentVehicle(selectedUser);
|
|||
|
//add vehicles that ar not asigned
|
|||
|
showOtherVehicle(selectedUser);
|
|||
|
|
|||
|
showCurrentGateway(selectedUser);
|
|||
|
showOtherGateways(selectedUser);
|
|||
|
showCurrentGroups(selectedUser);
|
|||
|
showOtherGroups(selectedUser);
|
|||
|
selUSerId = selectedUser.Id;
|
|||
|
UpdateFields();
|
|||
|
if (selectedUser.UType == USERTYPE.Admin /*|| selectedUser.UType == USERTYPE.TicketingAdmin*/) groupBoxesEnableManagement(false);
|
|||
|
else groupBoxesEnableManagement(true);
|
|||
|
|
|||
|
gbUserInfo.Text = setForuser + ": " + selectedUser.UserName;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|