Here are the examples of the csharp api System.Convert.ToInt32(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2928 Examples
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setname")]
public void EditPropertySetName(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.PropertyName = (string)arguments[1];
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Name of Property #{id} was changed to: '{arguments[1]}'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_settype")]
public void EditPropertySetType(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
PropertyTypes type;
if (Enum.TryParse((string)arguments[1], out type))
{
prop.Type = type;
ItemManager.SetDefaultPrices(prop);
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Type of Property #{id} was changed to: '{prop.Type}'");
}
else
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Type Entered.");
}
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setsupplies")]
public void EditPropertySetSupplies(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
int sup;
if (int.TryParse((string)arguments[1], out sup))
{
prop.Supplies = sup;
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Supplies of Property #{id} was changed to: '{sup}'");
}
else
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Supplies Entered.");
}
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setentrancepos")]
public void EditPropertySetEntrancePos(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.EntrancePos = sender.Position;
prop.EntranceRot = sender.Rotation;
prop.EntranceDimension = (int)sender.Dimension;
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Entrance Position of property #{id} was changed.");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_gotoentrance")]
public void EditPropertyGotoEntrance(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
sender.Position = prop.EntrancePos;
sender.Rotation = prop.EntranceRot;
sender.Dimension = 0;
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setmaindoor")]
public void EditPropertySetMainDoor(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
int doorid;
if (int.TryParse((string)arguments[1], out doorid))
{
if (Door.Doors.Exists(x => x.Id == doorid))
{
prop.MainDoorId = doorid;
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Main Door of Property #{id} was changed to: '{doorid}'");
}
else
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid DoorId Entered.");
}
}
else
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid DoorId Entered.");
}
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_toggleteleportable")]
public void EditPropertyToggleTeleportable(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.IsTeleportable = !prop.IsTeleportable;
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Property #{id} was made to be '" +
(prop.IsTeleportable ? "Teleportable" : "UnTeleportable") + "'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setteleportpos")]
public void EditPropertySetTeleportPos(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
if (!prop.IsTeleportable)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Property isn't teleportable.");
return;
}
prop.TargetPos = sender.Position;
prop.TargetRot = sender.Rotation;
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Interior TP Position of property #{id} was changed.");
}
}
19
Source : VehicleEditor.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("vehicle_edit_save")]
public void VehicleEditSave(Player player, params object[] arguments)
{
GameVehicle veh = NAPI.Data.GetEnreplacedyData(player, "EDIT_VEH");
if (veh == null)
{
NAPI.Chat.SendChatMessageToPlayer(player, "~r~Vehicle editor error. Null vehicle.");
return;
}
var vehId = Convert.ToInt32(arguments[0]);
var model = Convert.ToString(arguments[1]);
var owner = Convert.ToString(arguments[2]);
var licensePlate = Convert.ToString(arguments[3]);
var color1 = (string)arguments[4];
var color2 = (string)arguments[5];
var respawnDelay = Convert.ToInt32(arguments[6]);
var jobId = Convert.ToInt32(arguments[7]);
var groupId = Convert.ToInt32(arguments[8]);
if (veh.Id != vehId)
{
NAPI.Chat.SendChatMessageToPlayer(player, "~r~Vehicle editor error. Vehicle edit IDs are not equal.");
return;
}
var modelHash = NAPI.Util.VehicleNameToModel(model);
if (modelHash == 0)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid vehicle model entered!");
return;
}
if (!Character.IsCharacterRegistered(owner) && owner != "NONE")
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error",
"Invalid owner entered. (Character name does not exist.)");
return;
}
if (JobManager.GetJobById(jobId) == null && jobId != 0)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid job ID entered!");
return;
}
if (GroupManager.GetGroupById(groupId) == null && groupId != 0)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_veh_edit_error", "Invalid group ID entered!");
return;
}
if (owner == "NONE")
{
veh.OwnerId = 0;
}
else
{
veh.OwnerId = PlayerManager.Players.Single(x => x.CharacterName == owner).Id;
}
veh.VehModel = modelHash;
veh.LicensePlate = licensePlate;
veh.VehMods[ModdingManager.PrimaryColorId.ToString()] = color1;
veh.VehMods[ModdingManager.SecondryColorId.ToString()] = color2;
veh.RespawnDelay = TimeSpan.FromMinutes(respawnDelay);
veh.JobId = jobId;
veh.Job = JobManager.GetJobById(veh.JobId);
veh.Group = GroupManager.GetGroupById(veh.GroupId);
veh.GroupId = groupId;
VehicleManager.respawn_vehicle(veh, NAPI.Enreplacedy.GetEnreplacedyPosition(veh.Enreplacedy));
NAPI.Player.SetPlayerIntoVehicle(player, veh.Enreplacedy, -1);
veh.Save();
NAPI.Chat.SendChatMessageToPlayer(player, "Vehicle editor changes saved!");
NAPI.ClientEvent.TriggerClientEvent(player, "finish_veh_edit");
}
19
Source : VehicleOwnership.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("myvehicles_locatecar")]
public void MyVehiclesLocateCar(Player sender, params object[] arguments)
{
Character character = sender.GetCharacter();
GameVehicle lcVeh =
VehicleManager.Vehicles.Single(
x => x.Enreplacedy.Value == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
Vector3 loc = NAPI.Enreplacedy.GetEnreplacedyPosition(lcVeh.Enreplacedy);
NAPI.ClientEvent.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", loc.X, loc.Y, loc.Z);
NAPI.Chat.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
}
19
Source : VehicleOwnership.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("myvehicles_sellcar")]
public void MyVehiclesSellCar(Player sender, params object[] arguments)
{
Character character = sender.GetCharacter();
GameVehicle scVeh =
VehicleManager.Vehicles.Single(
x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
var tid = (string)arguments[1];
var target = PlayerManager.ParseClient(tid);
if (target == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "That player isn't online or doesn't exist.");
return;
}
var targetChar = target.GetCharacter();
var targetAccount = target.GetAccount();
var price = 0;
if (!int.TryParse((string)arguments[2], out price))
{
NAPI.Chat.SendChatMessageToPlayer(sender, "Invalid price entered.");
return;
}
if (price < 0)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "Price cannot be negative.");
return;
}
if (targetChar.OwnedVehicles.Count >= VehicleManager.GetMaxOwnedVehicles(targetChar.Player))
{
NAPI.Chat.SendChatMessageToPlayer(sender, "This player cannot own any more vehicles.");
return;
}
NAPI.Chat.SendChatMessageToPlayer(sender,
$"Are you sure you would like to sell the ~r~{returnCorrDisplayName(scVeh.VehModel)}~w~ for ~r~${price}~w~ to the player ~r~{targetChar.rp_name()}~w~?");
NAPI.Chat.SendChatMessageToPlayer(sender, "Use /confirmsellvehicle to sell.");
NAPI.Data.SetEnreplacedyData(sender, "sellcar_selling", new dynamic[] { scVeh, targetChar, price });
}
19
Source : VehicleOwnership.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("groupvehicles_locatecar")]
public void GroupVehiclesLocateCar(Player sender, params object[] arguments)
{
Character character = sender.GetCharacter();
GameVehicle gVeh =
VehicleManager.Vehicles.Single(
x => x.Enreplacedy.Value == Convert.ToInt32(arguments[0]) && x.GroupId == character.GroupId);
Vector3 location = NAPI.Enreplacedy.GetEnreplacedyPosition(gVeh.Enreplacedy);
NAPI.ClientEvent.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", location.X, location.Y, location.Z);
NAPI.Chat.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("saveMappingRequest")]
public void SaveMappingRequest(Player player, params object[] arguments)
{
var mappingId = Convert.ToInt32(arguments[0]);
var newPropLink = Convert.ToInt32(arguments[1]);
var newDim = Convert.ToInt32(arguments[2]);
var newDesc = Convert.ToString(arguments[3]);
var editingRequest = player.GetAccount().ViewingMappingRequest;
if (editingRequest.Id != mappingId)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_error", "The mapping ID you are saving does not match the one you are viewing. Please hit search first.");
return;
}
editingRequest.PropertyLinkId = newPropLink;
editingRequest.Dimension = newDim;
editingRequest.Description = newDesc;
editingRequest.Save();
player.SendChatMessage("You saved mapping request #" + mappingId);
LogManager.Log(LogManager.LogTypes.MappingRequests, player.GetAccount().AccountName + " has saved mapping request #" + mappingId);
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("deleteMappingRequest")]
public void DeleteMappingRequest(Player player, params object[] arguments)
{
var mappingId = Convert.ToInt32(arguments[0]);
var editingRequest = player.GetAccount().ViewingMappingRequest;
if (editingRequest.Id != mappingId)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_error", "The mapping ID you are saving does not match the one you are viewing. Please hit search first.");
return;
}
player.SendChatMessage("You have deleted mapping request #" + mappingId + ". This cannot be undone.");
LogManager.Log(LogManager.LogTypes.MappingRequests, player.GetAccount().AccountName + " has deleted mapping request #" + mappingId);
Mapping.Remove(editingRequest);
editingRequest.Unload();
editingRequest.Delete();
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("toggleMappingLoaded")]
public void ToggleMappingLoaded(Player player, params object[] arguments)
{
var mappingId = Convert.ToInt32(arguments[0]);
var editingRequest = player.GetAccount().ViewingMappingRequest;
if (editingRequest.Id != mappingId)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_error", "The mapping ID you are saving does not match the one you are viewing. Please hit search first.");
return;
}
editingRequest.IsSpawned = !editingRequest.IsSpawned;
if (editingRequest.IsSpawned == true)
{
editingRequest.Load();
}
else
{
editingRequest.Unload();
}
editingRequest.Save();
player.SendChatMessage("You have " + ((editingRequest.IsSpawned == true) ? ("loaded") : ("unloaded")) + " mapping request #" + mappingId);
LogManager.Log(LogManager.LogTypes.MappingRequests, player.GetAccount().AccountName + "has " + ((editingRequest.IsSpawned == true) ? ("loaded") : ("unloaded")) + " mapping request #" + mappingId);
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("toggleMappingActive")]
public void ToggleMappingActive(Player player, params object[] arguments)
{
var mappingId = Convert.ToInt32(arguments[0]);
var editingRequest = player.GetAccount().ViewingMappingRequest;
if (editingRequest.Id != mappingId)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_error", "The mapping ID you are saving does not match the one you are viewing. Please hit search first.");
return;
}
editingRequest.IsActive = !editingRequest.IsActive;
if (editingRequest.IsActive == true)
{
editingRequest.Load();
}
editingRequest.Save();
player.SendChatMessage("You have " + ((editingRequest.IsActive == true) ? ("actived") : ("deactivated")) + " mapping request #" + mappingId + ". Deactived mapping does not spawn on server load.");
LogManager.Log(LogManager.LogTypes.MappingRequests, player.GetAccount().AccountName + "has " + ((editingRequest.IsActive == true) ? ("activated") : ("deactived")) + " mapping request #" + mappingId);
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("requestMappingCode")]
public void RequestMappingCode(Player player, params object[] arguments)
{
var mappingId = Convert.ToInt32(arguments[0]);
var editingRequest = player.GetAccount().ViewingMappingRequest;
if (editingRequest.Id != mappingId)
{
NAPI.ClientEvent.TriggerClientEvent(player, "send_error", "The mapping ID you are saving does not match the one you are viewing. Please hit search first.");
return;
}
var mappingString = "";
foreach (var o in editingRequest.Objects)
{
if (o.Type == MappingObject.ObjectType.CreateObject)
{
//NAPI.Object.CreateObject(int model, Vector3 pos, Vector3 rot, int dimension = 0);
mappingString += string.Format("NAPI.Object.CreateObject({0}, new Vector3({1}, {2}, {3}), new Vector3({4}, {5}, {6}, {7});\n", o.Model, o.Pos.X, o.Pos.Y, o.Pos.Z, o.Rot.X, o.Rot.Y, o.Rot.Z, editingRequest.Dimension);
}
else
{
//API.DeleteObject(Player client, Vector3 position, int modelHash);
mappingString += string.Format("API.DeleteObject(player, new Vector3({0}, {1}, {2}), {4});\n", o.Pos.X, o.Pos.Y, o.Pos.Z, o.Model);
}
}
NAPI.ClientEvent.TriggerClientEvent(player, "showRequestCode", mappingString);
}
19
Source : MappingManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("requestMappingPage")]
public void RequestMappingPage(Player player, params object[] arguments)
{
var page = Convert.ToInt32(arguments[0]);
NAPI.ClientEvent.TriggerClientEvent(player, "emptyMappingTable");
var count = 0;
foreach (var o in Mapping.Skip(page * 10))
{
NAPI.ClientEvent.TriggerClientEvent(player, "addMappingRequest", o.Id, o.Description, o.CreatedBy, o.IsActive);
count++;
if (count == 10)
break;
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_toggleinteractable")]
public void EditPropertyToggleInteractable(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.IsInteractable = !prop.IsInteractable;
if (!prop.IsInteractable) { prop.UpdateMarkers(); }
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Property #{id} was made to be '" +
(prop.IsInteractable ? "Interactable" : "UnInteractable") + "'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setinteractpos")]
public void EditPropertySetInteractPos(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
if (!prop.IsInteractable)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Property isn't interactable.");
return;
}
prop.InteractionPos = sender.Position;
prop.InteractionRot = sender.Rotation;
prop.InteractionDimension = (int)sender.Dimension;
prop.UpdateMarkers();
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Interaction Position of property #{id} was changed.");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_togglelock")]
public void EditPropertyToggleLock(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.IsLocked = !prop.IsLocked;
prop.UpdateLockStatus();
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Property #{id} was made to be '" +
(prop.IsLocked ? "Locked" : "UnLocked") + "'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_deleteproperty")]
public void EditPropertyDeleteProperty(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.Delete();
NAPI.Chat.SendChatMessageToPlayer(sender, $"[Property Manager] Property #{id} was deleted.");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setprice")]
public void EditPropertySetPrice(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
int price;
if (int.TryParse((string)arguments[1], out price))
{
prop.PropertyPrice = price;
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Price of Property #{id} was changed to: '{price}'");
}
else
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Price Entered.");
}
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setowner")]
public void EditPropertySetOwner(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
var player = PlayerManager.ParseClient((string)arguments[1]);
if (player == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Player Entered.");
return;
}
prop.OwnerId = player.GetCharacter().Id;
prop.Save();
prop.UpdateMarkers();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Owner of Property #{id} was changed to: '{player.GetCharacter().CharacterName}'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_togglehasgarbage")]
public void EditPropertyToggleHasGarbage(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.HasGarbagePoint = !prop.HasGarbagePoint;
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Property #{id} was made to '" +
(prop.HasGarbagePoint ? "have garbage" : "have no garbage") + "'");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_setgarbagepoint")]
public void EditPropertySetGarbagePoint(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
if (!prop.HasGarbagePoint)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Property cannot have a garbage point.");
return;
}
prop.GarbagePoint = sender.Position;
prop.GarbageRotation = sender.Rotation;
prop.GarbageDimension = (int)sender.Dimension;
prop.UpdateMarkers();
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Garbage point of property #{id} was changed.");
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_addipl")]
public void EditPropertyAddIpl(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
prop.IPLs.Add(arguments[1].ToString());
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Added IPL {arguments[1]} to property #{id}.");
NAPI.ClientEvent.TriggerClientEvent(sender, "editproperty_showmenu", prop.Id, NAPI.Util.ToJson(prop.IPLs.ToArray()));
}
}
19
Source : PropertyManager.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("editproperty_deleteipl")]
public void EditPropertyDeleteIpl(Player sender, params object[] arguments)
{
if (sender.GetAccount().AdminLevel >= 5)
{
var id = Convert.ToInt32(arguments[0]);
var prop = Properties.SingleOrDefault(x => x.Id == id);
if (prop == null)
{
NAPI.Chat.SendChatMessageToPlayer(sender, "[Property Manager] Invalid Property Id.");
return;
}
var ipl = arguments[1].ToString();
if (prop.IPLs.RemoveAll(x => x == ipl) > 0)
{
prop.Save();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"[Property Manager] Removed IPL {ipl} from property #{id}.");
NAPI.ClientEvent.TriggerClientEvent(sender, "editproperty_showmenu", prop.Id, NAPI.Util.ToJson(prop.IPLs.ToArray()));
}
}
}
19
Source : VehicleOwnership.cs
with MIT License
from Battlerax
with MIT License
from Battlerax
[RemoteEvent("myvehicles_abandoncar")]
public void MyVehiclesAbandonCar(Player sender, params object[] arguments)
{
Character character = sender.GetCharacter();
GameVehicle acVeh =
VehicleManager.Vehicles.Single(
x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
VehicleManager.despawn_vehicle(acVeh);
VehicleManager.delete_vehicle(acVeh);
acVeh.Delete();
NAPI.Chat.SendChatMessageToPlayer(sender,
$"You have sucessfully abandoned your ~r~{returnCorrDisplayName(acVeh.VehModel)}~w~");
}
19
Source : ObjectToBoolHandler.cs
with MIT License
from bcssov
with MIT License
from bcssov
public bool Get(object input, ClreplacedProperty property)
{
// The ORM now is officially giving me headaches... it just can't resolve a proper type, and I cannot target it with a specific type either.
if (input == null)
{
return false;
}
if (input is long || input is int || input is short)
{
return Convert.ToInt32(input) > 0;
}
else if (input is bool boolean)
{
return boolean;
}
else if (int.TryParse(input.ToString(), out var intResult))
{
return intResult > 0;
}
else if (bool.TryParse(input.ToString(), out var boolresult))
{
return boolresult;
}
return false;
}
19
Source : MetroTabItemCloseButtonWidthConverter.cs
with Apache License 2.0
from beckzhu
with Apache License 2.0
from beckzhu
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return System.Convert.ToInt32(value)*0.5;
}
19
Source : NumericUpDown.cs
with Apache License 2.0
from beckzhu
with Apache License 2.0
from beckzhu
private static bool ValidateDelay(object value)
{
return Convert.ToInt32(value) >= 0;
}
19
Source : EnumUtil.cs
with GNU General Public License v3.0
from berichan
with GNU General Public License v3.0
from berichan
private static string GetSummary<T>(T z) where T : Enum
{
int x = Convert.ToInt32(z);
return $"{z} = {x}";
}
19
Source : ObjectPlacement.cs
with MIT License
from Big-Endian-32
with MIT License
from Big-Endian-32
public override void Save(Stream stream)
{
BINAWriter writer = new(stream);
writer.WriteNulls(0x0C);
// Write the name, but default to 'test', because Sonic Team.
writer.WriteNullPaddedString(string.Concat(Data.Name == null ? "test".Take(0x20) : Data.Name.Take(0x20)), 0x20);
// Write data table information.
writer.Write(Data.Objects.Count);
writer.AddOffset("objectTableOffset");
writer.Write(Data.Groups.Count);
writer.AddOffset("groupTableOffset");
writer.FillOffset("objectTableOffset", true);
// Set up objects.
for (int o = 0; o < Data.Objects.Count; o++)
{
// If the object's name is empty, add an offset to a null entry.
if (string.IsNullOrEmpty(Data.Objects[o].Name))
{
writer.AddOffset($"object{o}NullName");
}
else
{
writer.AddString($"object{o}Name", Data.Objects[o].Name);
}
writer.AddString($"object{o}Type", Data.Objects[o].Type);
writer.Write((byte)0x40);
writer.WriteNulls(0x02);
writer.Write(Data.Objects[o].StartInactive);
writer.WriteNulls(0x0C);
writer.Write(Data.Objects[o].Position);
writer.Write(Data.Objects[o].DrawDistance);
writer.Write(Data.Objects[o].Rotation);
writer.Write(Data.Objects[o].Parameters.Count);
writer.AddOffset($"object{o}Offsets");
}
// Set up object parameters.
for (int o = 0; o < Data.Objects.Count; o++)
{
// Skip this loop if this object has no parameters.
if (Data.Objects[o].Parameters.Count == 0)
continue;
writer.FillOffset($"object{o}Offsets", true);
for (int p = 0; p < Data.Objects[o].Parameters.Count; p++)
{
ObjectDataType type = Data.Objects[o].Parameters[p].Type;
// Write object data type.
writer.Write((uint)type);
switch (type)
{
case ObjectDataType.Boolean:
writer.WriteBoolean32((bool)Data.Objects[o].Parameters[p].Data);
writer.WriteNulls(0x0C);
break;
case ObjectDataType.Int32:
writer.Write(Convert.ToInt32(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;
case ObjectDataType.Single:
writer.Write(Convert.ToSingle(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;
case ObjectDataType.String:
{
// If the parameter's string is empty, add an offset to a null entry.
if (string.IsNullOrEmpty(Data.Objects[o].Parameters[p].Data.ToString()))
{
writer.AddOffset($"object{o}Parameter{p}NullString");
}
else
{
writer.AddString($"object{o}Parameter{p}String", Data.Objects[o].Parameters[p].Data.ToString());
}
writer.Write(1u);
writer.Write(0u);
writer.Write(Data.Objects[o].Parameters[p].Data.ToString().Length + 1);
break;
}
case ObjectDataType.Vector3:
writer.Write(VectorHelper.ParseVector3(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x04);
break;
case ObjectDataType.UInt32:
writer.Write(Convert.ToUInt32(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;
default:
throw new InvalidSetParameterType(Data.Objects[o].Parameters[p].Type.ToString(), writer.BaseStream.Position);
}
}
}
// Set up groups.
if (Data.Groups.Count != 0)
{
writer.FillOffset("groupTableOffset", true);
for (int g = 0; g < Data.Groups.Count; g++)
{
writer.AddString($"group{g}Name", Data.Groups[g].Name);
// If the group doesn't have a function, add an offset to a null entry.
if (string.IsNullOrEmpty(Data.Groups[g].Function))
{
writer.AddOffset($"group{g}NullFunction");
}
else
{
writer.AddString($"group{g}Function", Data.Groups[g].Function);
}
writer.Write(Data.Groups[g].Objects.Count);
writer.AddOffset($"group{g}ObjectList");
}
for (int g = 0; g < Data.Groups.Count; g++)
{
/* Skip this loop if this group has no objects
replacedociated with it (because that can happen apparently) */
if (Data.Groups[g].Objects.Count == 0)
continue;
writer.FillOffset($"group{g}ObjectList", true);
foreach (ulong ObjectID in Data.Groups[g].Objects)
writer.Write(ObjectID);
}
}
// Process null object strings.
for (int o = 0; o < Data.Objects.Count; o++)
{
if (string.IsNullOrEmpty(Data.Objects[o].Name))
writer.FillOffset($"object{o}NullName", true);
for (int p = 0; p < Data.Objects[o].Parameters.Count; p++)
{
if (Data.Objects[o].Parameters[p].Type == ObjectDataType.String)
{
if (string.IsNullOrEmpty(Data.Objects[o].Parameters[p].Data.ToString()))
{
writer.FillOffset($"object{o}Parameter{p}NullString", true);
writer.WriteNulls(0x4);
}
}
}
}
// Process null group strings.
for (int g = 0; g < Data.Groups.Count; g++)
{
if (string.IsNullOrEmpty(Data.Groups[g].Function))
{
writer.FillOffset($"group{g}NullFunction", true);
writer.WriteNulls(0x4);
}
}
writer.FinishWrite();
}
19
Source : AdapterGX.cs
with MIT License
from BigBigZBBing
with MIT License
from BigBigZBBing
internal static void EmitValue(this EmitBasic basic, Object value, Type type)
{
if (type == typeof(String))
{
basic.Emit(OpCodes.Ldstr, Convert.ToString(value));
}
else if (type == typeof(Boolean))
{
switch (Convert.ToBoolean(value))
{
case true: basic.Emit(OpCodes.Ldc_I4_1); break;
case false: basic.Emit(OpCodes.Ldc_I4_0); break;
default: throw new Exception("boolean to error!");
}
}
else if (type == typeof(SByte))
{
basic.IntegerMap(Convert.ToSByte(value));
}
else if (type == typeof(Byte))
{
basic.IntegerMap((SByte)Convert.ToByte(value));
}
else if (type == typeof(Int16))
{
basic.IntegerMap(Convert.ToInt16(value));
}
else if (type == typeof(UInt16))
{
basic.IntegerMap((Int16)Convert.ToUInt16(value));
}
else if (type == typeof(Int32))
{
basic.IntegerMap(Convert.ToInt32(value));
}
else if (type == typeof(UInt32))
{
basic.IntegerMap((Int32)Convert.ToUInt32(value));
}
else if (type == typeof(Int64))
{
basic.IntegerMap(Convert.ToInt64(value));
}
else if (type == typeof(UInt64))
{
basic.IntegerMap((Int64)Convert.ToUInt64(value));
}
else if (type == typeof(Single))
{
basic.Emit(OpCodes.Ldc_R4, Convert.ToSingle(value));
}
else if (type == typeof(Double))
{
basic.Emit(OpCodes.Ldc_R8, Convert.ToDouble(value));
}
else if (type == typeof(Decimal))
{
Int32[] bits = Decimal.GetBits(Convert.ToDecimal(value));
basic.IntegerMap(bits[0]);
basic.IntegerMap(bits[1]);
basic.IntegerMap(bits[2]);
basic.Emit((bits[3] & 0x80000000) != 0 ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
basic.IntegerMap((bits[3] >> 16) & 0x7f);
basic.Emit(OpCodes.Newobj, typeof(Decimal)
.GetConstructor(new Type[] { typeof(Int32), typeof(Int32), typeof(Int32), typeof(Boolean), typeof(Byte) }));
}
else if (type == typeof(DateTime))
{
basic.Emit(OpCodes.Ldc_I8, Convert.ToDateTime(value).Ticks);
basic.Emit(OpCodes.Newobj, typeof(DateTime).GetConstructor(new Type[] { typeof(Int64) }));
}
else
{
throw new Exception("not exist datatype!");
}
}
19
Source : AdapterGX.cs
with MIT License
from BigBigZBBing
with MIT License
from BigBigZBBing
internal static void EmitValue<T>(this EmitBasic basic, T value)
{
if (value == null)
{
basic.Emit(OpCodes.Ldnull);
}
else if (value.GetType() == typeof(String))
{
basic.Emit(OpCodes.Ldstr, Convert.ToString(value));
}
else if (value.GetType() == typeof(Boolean))
{
switch (Convert.ToBoolean(value))
{
case true: basic.Emit(OpCodes.Ldc_I4_1); break;
case false: basic.Emit(OpCodes.Ldc_I4_0); break;
default: throw new Exception("boolean to error!");
}
}
else if (value.GetType() == typeof(SByte))
{
basic.IntegerMap(Convert.ToSByte(value));
}
else if (value.GetType() == typeof(Byte))
{
basic.IntegerMap((SByte)Convert.ToByte(value));
}
else if (value.GetType() == typeof(Int16))
{
basic.IntegerMap(Convert.ToInt16(value));
}
else if (value.GetType() == typeof(UInt16))
{
basic.IntegerMap((Int16)Convert.ToUInt16(value));
}
else if (value.GetType() == typeof(Int32))
{
basic.IntegerMap(Convert.ToInt32(value));
}
else if (value.GetType() == typeof(UInt32))
{
basic.IntegerMap((Int32)Convert.ToUInt32(value));
}
else if (value.GetType() == typeof(Int64))
{
basic.IntegerMap(Convert.ToInt64(value));
}
else if (value.GetType() == typeof(UInt64))
{
basic.IntegerMap((Int64)Convert.ToUInt64(value));
}
else if (value.GetType() == typeof(Single))
{
basic.Emit(OpCodes.Ldc_R4, Convert.ToSingle(value));
}
else if (value.GetType() == typeof(Double))
{
basic.Emit(OpCodes.Ldc_R8, Convert.ToDouble(value));
}
else if (value.GetType() == typeof(Decimal))
{
Int32[] bits = Decimal.GetBits(Convert.ToDecimal(value));
basic.IntegerMap(bits[0]);
basic.IntegerMap(bits[1]);
basic.IntegerMap(bits[2]);
basic.Emit((bits[3] & 0x80000000) != 0 ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
basic.IntegerMap((bits[3] >> 16) & 0x7f);
basic.Emit(OpCodes.Newobj, typeof(Decimal)
.GetConstructor(new Type[] { typeof(Int32), typeof(Int32), typeof(Int32), typeof(Boolean), typeof(Byte) }));
}
else if (value.GetType() == typeof(DateTime))
{
basic.Emit(OpCodes.Ldc_I8, Convert.ToDateTime(value).Ticks);
basic.Emit(OpCodes.Newobj, typeof(DateTime).GetConstructor(new Type[] { typeof(Int64) }));
}
else if (value is Enum)
{
basic.IntegerMap(Convert.ToInt32(value));
}
else if (value.GetType().IsClreplaced)
{
basic.Emit(OpCodes.Newobj, value.GetType().GetConstructor(Type.EmptyTypes));
}
else
{
throw new Exception("not exist datatype!");
}
}
19
Source : Return.cs
with MIT License
from bilalmehrban
with MIT License
from bilalmehrban
private void btnsave_Click(object sender, EventArgs e)
{
if(Validation1())
{
string inv_no = txtsearch.Text;
DataTable dt1 = dal1.Search(inv_no);
//Show user based on keywords
DataTable dt = dal.Search(inv_no);
if (dgvinvoice.Rows.Count == 0)
{
for (int i = 0; i < dt1.Rows.Count; i++)
{
bll1.id = Convert.ToInt32(dt1.Rows[i][0]);
}
bool x = false;
x = dal1.delete(bll1);
if(x == true)
{
MessageBox.Show("Data Deleted Succesfully");
//Celar the Data Grid View and Clear all the TExtboxes
dgvinvoice.DataSource = null;
dgvinvoice.Rows.Clear();
txttotal.Text = "";
txtdiscount.Text = "";
txtsubtotal.Text = "";
txtpaidamount.Text = "";
txtdueamount.Text = "";
txtchangeamount.Text = "";
cmbcustomer.Text = "";
}
else
{
MessageBox.Show("Error in deleting data");
}
}
else
{
for (int i = 0; i < dt1.Rows.Count; i++)
{
bll1.id = Convert.ToInt32(dt1.Rows[i][0]);
bll1.added_by =Convert.ToInt32( dt1.Rows[i][8]);
bll1.inv_no = Convert.ToInt32(dt1.Rows[i][9]);
}
bll1.customer_name = cmbcustomer.Text;
bll1.total_payable = txtsubtotal.Text;
bll1.paid_amount = txtpaidamount.Text;
bll1.discount = txtdiscount.Text;
bll1.due_amount = txtdueamount.Text;
bll1.change_amount = txtchangeamount.Text;
bll1.sales_date =Convert.ToDateTime( dtsalesdate.Text);
//Inserting Data into DAtabase
bool w = dal1.update(bll1);
for (int i = 0; i < dt.Rows.Count; i++)
{
//Get the Product name and convert it to id
bll.id =Convert.ToInt32( dt.Rows[i][0]) ;
bll.product_id = Convert.ToInt32(dt.Rows[i][1]);
bll.product_name = dt.Rows[i][3].ToString();
bll.price = dt.Rows[i][4].ToString();
bll.quanreplacedy = dt.Rows[i][5].ToString();
bll.discount = txtdiscount.Text;
bll.inv_no = dt.Rows[i][2].ToString();
bll.type = dt.Rows[i][9].ToString();
quanreplacedy11 = Convert.ToDecimal(bll.quanreplacedy);
q = Convert.ToDouble(dt.Rows[i][5]);
//Method to get purchase price an multiply it with quanreplacedy
Manage_Productsbll price = dal2.GetProductpriceFromId((dt.Rows[i][1]).ToString());
p = Convert.ToDouble ((Convert.ToDouble(price.purchase_price)) * q);
bll.purchase_price = p.ToString();
//Getting total value by calculating discount
t1 = Convert.ToDouble(txtdiscount.Text);
t2 = Convert.ToDouble(dt.Rows[i][4]) * q;
bll.total = (t2 - (t2 * t1) / 100).ToString();
bll.added_by =Convert.ToInt32( dt.Rows[i][10]);
bll.added_date = Convert.ToDateTime(dtsalesdate.Text);
// Inserting Data into DAtabase
x = dal.update(bll);
//sucess1 = w && x;
}
if (w == true && x == true)
{
MessageBox.Show("Data Updated Succesfullay");
//Celar the Data Grid View and Clear all the TExtboxes
dgvinvoice.DataSource = null;
dgvinvoice.Rows.Clear();
txttotal.Text = "";
txtdiscount.Text = "";
txtsubtotal.Text = "";
txtpaidamount.Text = "";
txtdueamount.Text = "";
txtchangeamount.Text = "";
cmbcustomer.Text = "";
}
else
{
//Transaction Failed
MessageBox.Show("Failed to update");
}
}
}
}
19
Source : Sale Register.cs
with MIT License
from bilalmehrban
with MIT License
from bilalmehrban
private void btnsave_Click(object sender, EventArgs e)
{
if (Validation1())
{
//printPreviewDialog1.Doreplacedent = printDoreplacedent1;
//printPreviewDialog1.ShowDialog();
//Gettting Data FRom UI
inbll.inv_no = Convert.ToInt32(lblinvoiceno.Text);
inbll.customer_name = cmbcustomer.Text;
inbll.total_payable = txtsubtotal.Text;
inbll.paid_amount = txtpaidamount.Text;
inbll.discount = txtdiscount.Text;
inbll.due_amount = txtdueamount.Text;
inbll.change_amount = txtchangeamount.Text;
inbll.sales_date = DateTime.Now;
//Getting Username of the logged in user
string loggedUser = Login.loggedIn;
usersbll usr = user.GetIDFromUsername(loggedUser);
inbll.added_by = usr.id;
//Inserting Data into DAtabase
bool w = indal.insert(inbll);
bool sucess = false;
for (int i = 0; i < table.Rows.Count; i++)
{
bool x = false;
//Get the Product name and convert it to id
string ProductName = table.Rows[i][0].ToString();
string type1 = table.Rows[i][2].ToString();
string ccode = table.Rows[i][1].ToString();
Manage_Productsbll p = dal.GetProductIDFromName(ProductName, type1, ccode);
prbll.product_id = p.id;
prbll.product_name = table.Rows[i][0].ToString();
prbll.type = table.Rows[i][2].ToString();
prbll.price = table.Rows[i][3].ToString();
prbll.quanreplacedy = table.Rows[i][4].ToString();
prbll.code = Convert.ToInt32(table.Rows[i][1]);
prbll.discount = txtdiscount.Text;
//prbll.total = table.Rows[i][3].ToString();
//Getting total value by calculating discount
t1 = Convert.ToDouble(txtdiscount.Text);
t2 = Convert.ToDouble(table.Rows[i][5]);
prbll.total = (t2 - (t2 * t1) / 100).ToString();
//Method to get purchase price an multiply it with quanreplacedy
Manage_Productsbll pr = dal.GetProductpriceFromId(p.id.ToString());
purchaseprice = Convert.ToDouble(pr.purchase_price);
prbll.purchase_price = ((Convert.ToDouble(table.Rows[i][4])) * purchaseprice).ToString();
prbll.inv_no = lblinvoiceno.Text;
prbll.added_by = usr.id;
prbll.added_date = DateTime.Now;
quanreplacedy1 = Convert.ToDecimal(prbll.quanreplacedy);
// Decreasing product quanreplacedy in DAtabase
bool y = false;
y = dal.DecreaseProduct(prbll.product_id, quanreplacedy1);
// Inserting Data into DAtabase
x = prdal.insert(prbll);
sucess = w && x && y;
}
if (sucess == true)
{
MessageBox.Show("Transaction Completed Sucessfully");
//Celar the Data Grid View and Clear all the TExtboxes
dgvinvoice.DataSource = null;
dgvinvoice.Rows.Clear();
txttotal.Text = "";
txtdiscount.Text = "";
txtsubtotal.Text = "";
txtpaidamount.Text = "";
txtdueamount.Text = "";
txtchangeamount.Text = "";
cmbcustomer.Text = "";
txtcomment.Text = "0";
//To refresh stock in Data grid view
DataTable dt = dal.select();
dgvstock.DataSource = dt;
ToGetInvoiceID();
}
else
{
//Transaction Failed
MessageBox.Show("Transaction Failed");
}
}
}
19
Source : Sale Register.cs
with MIT License
from bilalmehrban
with MIT License
from bilalmehrban
private void btncomplete_Click(object sender, EventArgs e)
{
if(Validation1())
{
//printPreviewDialog1.Doreplacedent = printDoreplacedent1;
//printPreviewDialog1.ShowDialog();
//Gettting Data FRom UI
inbll.inv_no = Convert.ToInt32( lblinvoiceno.Text);
inbll.customer_name = cmbcustomer.Text;
inbll.total_payable = txtsubtotal.Text;
inbll.paid_amount = txtpaidamount.Text;
inbll.discount = txtdiscount.Text;
inbll.due_amount = txtdueamount.Text;
inbll.change_amount = txtchangeamount.Text;
inbll.sales_date = DateTime.Now;
//Getting Username of the logged in user
string loggedUser = Login.loggedIn;
usersbll usr = user.GetIDFromUsername(loggedUser);
inbll.added_by = usr.id;
//Inserting Data into DAtabase
bool w = indal.insert(inbll);
bool sucess = false;
for (int i = 0; i < table.Rows.Count; i++)
{
bool x = false;
//Get the Product name and convert it to id
string ProductName = table.Rows[i][0].ToString();
string type1 = table.Rows[i][2].ToString();
string ccode = table.Rows[i][1].ToString();
Manage_Productsbll p = dal.GetProductIDFromName(ProductName, type1, ccode);
prbll.product_id = p.id;
prbll.product_name = table.Rows[i][0].ToString();
prbll.type = table.Rows[i][2].ToString();
prbll.price = table.Rows[i][3].ToString();
prbll.quanreplacedy = table.Rows[i][4].ToString();
prbll.code = Convert.ToInt32( table.Rows[i][1]);
prbll.discount = txtdiscount.Text;
//prbll.total = table.Rows[i][3].ToString();
//Getting total value by calculating discount
t1 = Convert.ToDouble(txtdiscount.Text);
t2 = Convert.ToDouble(table.Rows[i][5]);
prbll.total = (t2 - (t2 * t1) / 100).ToString();
//Method to get purchase price an multiply it with quanreplacedy
Manage_Productsbll pr = dal.GetProductpriceFromId(p.id.ToString());
purchaseprice = Convert.ToDouble(pr.purchase_price);
prbll.purchase_price = ((Convert.ToDouble(table.Rows[i][4])) * purchaseprice).ToString();
prbll.inv_no = lblinvoiceno.Text;
prbll.added_by = usr.id;
prbll.added_date = DateTime.Now;
quanreplacedy1 = Convert.ToDecimal(prbll.quanreplacedy);
// Decreasing product quanreplacedy in DAtabase
bool y = false;
y = dal.DecreaseProduct(prbll.product_id, quanreplacedy1);
// Inserting Data into DAtabase
x = prdal.insert(prbll);
sucess = w && x && y;
}
if (sucess == true)
{
//code to print Bill
DGVPrinter printer = new DGVPrinter();
printer.replacedle = "\r \r Time Paint & Hardware Store";
printer.Subreplacedle = "Khokhar Plaza, Near Alied Bank, Main Behria Enclave Road \r \n Phone: 031659007044 \r \r \r \r \r \r Invoice #:" + lblinvoiceno.Text + "\r";
printer.SubreplacedleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "Grand Total: " + txtsubtotal.Text + " \r \r \r \r \r \r \r \r \r \r \r \r" + "Total Paid:" + txtpaidamount.Text + " \r \n" + "Thank You, for doing business with us. \n";
printer.FooterSpacing = 15;
printer.PrintDataGridView(dgvinvoice);
MessageBox.Show("Transaction Completed Sucessfully");
//Celar the Data Grid View and Clear all the TExtboxes
dgvinvoice.DataSource = null;
dgvinvoice.Rows.Clear();
txttotal.Text = "";
txtdiscount.Text = "";
txtsubtotal.Text = "";
txtpaidamount.Text = "";
txtdueamount.Text = "";
txtchangeamount.Text = "";
cmbcustomer.Text = "";
txtcomment.Text = "0";
//To refresh stock in Data grid view
DataTable dt = dal.select();
dgvstock.DataSource = dt;
ToGetInvoiceID();
}
else
{
//Transaction Failed
MessageBox.Show("Transaction Failed");
}
}
}
19
Source : EntityHelper.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
private static bool IsDefaultKeyValue(object value)
{
if (value == null)
return true;
var type = value.GetType();
if (type == typeof(int))
return Convert.ToInt32(value) <= 0;
if (type == typeof(long))
return Convert.ToInt64(value) <= 0;
return Types.IsDefaultValue(value);
}
19
Source : LDAPHelper.cs
with BSD 3-Clause "New" or "Revised" License
from bitsadmin
with BSD 3-Clause "New" or "Revised" License
from bitsadmin
private static bool IsActive(SearchResult de)
{
if (de.Properties["ObjectGUID"] == null)
return false;
int flags = Convert.ToInt32(de.Properties["userAccountControl"][0]);
return !Convert.ToBoolean(flags & 0x0002);
}
19
Source : SSOConfigManager.cs
with MIT License
from BizTalkCommunity
with MIT License
from BizTalkCommunity
public static void CreateConfigStoreApplication(string appName, string description, string contactInfo, string uAccountName, string adminAccountName, SSOPropBag propertiesBag, ArrayList maskArray)
{
int appFlags = 0;
//bitwise operation for flags
appFlags |= SSOFlag.SSO_FLAG_APP_CONFIG_STORE;
appFlags |= SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL;
appFlags |= SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL;
ISSOAdmin ssoAdmin = new ISSOAdmin();
//create app
if (propertiesBag.PropertyCount > 0)
ssoAdmin.CreateApplication(appName, description, contactInfo, uAccountName, adminAccountName, appFlags, propertiesBag.PropertyCount);
else
{
ssoAdmin.CreateApplication(appName, description, contactInfo, uAccountName, adminAccountName, appFlags, 1);
}
//create property fields
int counter = 0;
//create dummy field in first slot
ssoAdmin.CreateFieldInfo(appName, "dummy", 0);
//create real fields
foreach (DictionaryEntry de in propertiesBag.properties)
{
string propName = de.Key.ToString();
int fieldFlags = 0;
fieldFlags |= Convert.ToInt32(maskArray[counter]);
//create property
ssoAdmin.CreateFieldInfo(appName, propName, fieldFlags);
counter++;
}
//enable application
ssoAdmin.UpdateApplication(appName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED);
}
19
Source : System_EnumWrap.cs
with MIT License
from bjfumac
with MIT License
from bjfumac
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
static int ToInt(IntPtr L)
{
try
{
object arg0 = ToLua.CheckObject<System.Enum>(L, 1);
int ret = Convert.ToInt32(arg0);
LuaDLL.lua_pushinteger(L, ret);
return 1;
}
catch (Exception e)
{
return LuaDLL.toluaL_exception(L, e);
}
}
19
Source : LuaMisc.cs
with MIT License
from bjfumac
with MIT License
from bjfumac
public static double ToDouble(object obj)
{
Type t = obj.GetType();
if (t == typeof(double) || t == typeof(float))
{
double d = Convert.ToDouble(obj);
return d;
}
else if (t == typeof(int))
{
int n = Convert.ToInt32(obj);
return (double)n;
}
else if (t == typeof(uint))
{
uint n = Convert.ToUInt32(obj);
return (double)n;
}
else if (t == typeof(long))
{
long n = Convert.ToInt64(obj);
return (double)n;
}
else if (t == typeof(ulong))
{
ulong n = Convert.ToUInt64(obj);
return (double)n;
}
else if (t == typeof(byte))
{
byte b = Convert.ToByte(obj);
return (double)b;
}
else if (t == typeof(sbyte))
{
sbyte b = Convert.ToSByte(obj);
return (double)b;
}
else if (t == typeof(char))
{
char c = Convert.ToChar(obj);
return (double)c;
}
else if (t == typeof(short))
{
Int16 n = Convert.ToInt16(obj);
return (double)n;
}
else if (t == typeof(ushort))
{
UInt16 n = Convert.ToUInt16(obj);
return (double)n;
}
return 0;
}
19
Source : StringLimitConverter.cs
with GNU General Public License v2.0
from BlackTasty
with GNU General Public License v2.0
from BlackTasty
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int maxLength = System.Convert.ToInt32(parameter);
if (value is string text)
{
if (text.Length > maxLength)
{
return text.Substring(0, maxLength - 3) + "...";
}
else
{
return text;
}
}
else
return value;
}
19
Source : ShellSubMenuDialog.cs
with MIT License
from BluePointLilac
with MIT License
from BluePointLilac
public void LoadItems()
{
this.AddItem(subNewItem);
subNewItem.AddNewItem += () => AddNewItem();
subNewItem.AddSeparator += () => AddSeparator();
subNewItem.AddExisting += () => AddFromParentMenu();
string sckValue = Microsoft.Win32.Registry.GetValue(this.ParentPath, "ExtendedSubCommandsKey", null)?.ToString();
if(!sckValue.IsNullOrWhiteSpace())
{
this.ShellPath = $@"{RegistryEx.CLreplacedES_ROOT}\{sckValue}\shell";
}
else
{
this.ShellPath = $@"{this.ParentPath}\shell";
}
using(var shellKey = RegistryEx.GetRegistryKey(ShellPath))
{
if(shellKey == null) return;
RegTrustedInstaller.TakeRegTreeOwnerShip(shellKey.Name);
foreach(string keyName in shellKey.GetSubKeyNames())
{
string regPath = $@"{ShellPath}\{keyName}";
int value = Convert.ToInt32(Microsoft.Win32.Registry.GetValue(regPath, "CommandFlags", 0));
if(value % 16 >= 8)
{
this.AddItem(new SeparatorItem(this, regPath));
}
else
{
this.AddItem(new SubShellItem(this, regPath));
}
}
}
}
19
Source : ThemeColor.cs
with MIT License
from BluePointLilac
with MIT License
from BluePointLilac
public static Color GetThemeColor() {
RegistryKey currentUser = Registry.CurrentUser;
RegistryKey registryKey = currentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", true);
object value = registryKey.GetValue("AccentColorMenu");
int value2 = Convert.ToInt32(value);
string text = Convert.ToString(value2, 16);
string str = text.Substring(6, 2);
string str2 = text.Substring(4, 2);
string str3 = text.Substring(2, 2);
text = "#" + str + str2 + str3;
return ColorTranslator.FromHtml(text);
}
19
Source : MessageBox.cs
with MIT License
from BoltBait
with MIT License
from BoltBait
private string GetButtonText(ButtonID buttonID)
{
var buttonTextArrayIndex = Convert.ToInt32(buttonID);
switch (this.languageID)
{
case TwoLetterISOLanguageID.de: return BUTTON_TEXTS_GERMAN_DE[buttonTextArrayIndex];
case TwoLetterISOLanguageID.es: return BUTTON_TEXTS_SPANISH_ES[buttonTextArrayIndex];
case TwoLetterISOLanguageID.it: return BUTTON_TEXTS_ITALIAN_IT[buttonTextArrayIndex];
case TwoLetterISOLanguageID.ru: return BUTTON_TEXTS_RUSSIAN_RU[buttonTextArrayIndex];
default: return BUTTON_TEXTS_ENGLISH_EN[buttonTextArrayIndex];
}
}
19
Source : SchemaBuilder.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
private static List<SelectOption> GetSelectOptions(Type selectOptions)
{
if (selectOptions == null || selectOptions == typeof(Profile))
{
return new List<SelectOption>();
}
if (selectOptions == typeof(Quality))
{
var qOptions = from Quality q in selectOptions.GetProperties(BindingFlags.Static | BindingFlags.Public)
select new SelectOption {Name = q.Name, Value = q.Id};
return qOptions.OrderBy(o => o.Value).ToList();
}
var options = from Enum e in Enum.GetValues(selectOptions)
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
return options.OrderBy(o => o.Name).ToList();
}
19
Source : Int32Converter.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public object FromDB(ColumnMap map, object dbValue)
{
if (dbValue == DBNull.Value)
{
return DBNull.Value;
}
if (dbValue is int)
{
return dbValue;
}
return Convert.ToInt32(dbValue);
}
See More Examples