/// <summary> /// Delete Decleration by ID /// </summary> /// <param name="declerationID">DeclerationID</param> /// <returns>Number of rows are effected</returns> public static int DeleteByID(int declerationID) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var declaration = db.tblDeclarations.Where(g => g.DeclarationID == declerationID).FirstOrDefault(); db.DeleteObject(declaration); return db.SaveChanges(); }
/// <summary> /// Delete vehicle by ID /// </summary> /// <param name="vehicleID">Vehicle ID</param> /// <returns>Number of rows are effected</returns> public static int DeleteByID(int vehicleID) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var vehicle = db.tblVehicles.Where(g => g.VehicleID == vehicleID).FirstOrDefault(); db.DeleteObject(vehicle); return db.SaveChanges(); }
public static int DeleteUserInGroup(int groupID, int userID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); tblUserInGroup tblUserInGroup = db.tblUserInGroups.Where(g => g.GroupID == groupID && g.UserID == userID).FirstOrDefault(); if(tblUserInGroup != null) db.DeleteObject(tblUserInGroup); int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static int Delete(long checkID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var check = db.tblChecks.Where(g => g.CheckID == checkID).FirstOrDefault(); if (check == null) return -1; db.DeleteObject(check); int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static int DeleteUserInGroupByGroupID(Int32 groupID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<tblUserInGroup> listTblUserInGroup = db.tblUserInGroups.Where(g => g.GroupID == groupID).ToList(); foreach (tblUserInGroup userInGroup in listTblUserInGroup) { db.DeleteObject(userInGroup); } int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static int DeleteUserGroupPermissionByUserID(int userID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<tblUserGroupPermission> listUserGroupPermission = db.tblUserGroupPermissions.Where(g => g.UserID == userID && g.PermissionType == PERMISSION_TYPE_USER).ToList(); foreach (tblUserGroupPermission userGroupPermission in listUserGroupPermission) { db.DeleteObject(userGroupPermission); } int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static void DeleteVehicleByDecarationID(long declarationID) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var declarationVehicles = db.tblDeclarationVehicles.Where((g => g.DeclarationID == declarationID)).ToList(); foreach (var tblDeclarationVehicle in declarationVehicles) { db.DeleteObject(tblDeclarationVehicle); db.SaveChanges(); } db.Connection.Close(); }
public static int DeleteByVehicleDeclarationID(long vehicleID, long declarationID) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var declarationVehicle = db.tblDeclarationVehicles.Where((g => g.DeclarationID == declarationID && g.VehicleID == vehicleID)). FirstOrDefault(); if (declarationVehicle != null) { db.DeleteObject(declarationVehicle); int re = db.SaveChanges(); db.Connection.Close(); return re; } return -1; }
public static int Delete(long trainId) { var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); var train = _db.tblTrains.FirstOrDefault(g => g.TrainID == trainId); _db.DeleteObject(train); return _db.SaveChanges(); } catch { return -1; } finally { _db.Connection.Close(); } }
public static void DeleteVehicleType(int vehicleTypeID) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); var tblVehicleTypes = _db.tblVehicleTypes.FirstOrDefault(vt => vt.VehicleTypeID == vehicleTypeID); _db.DeleteObject(tblVehicleTypes); _db.SaveChanges(); } catch { } finally { _db.Connection.Close(); } }
/// <summary> /// Delete Decleration by ID /// </summary> /// <param name="declerationID">DeclerationID</param> /// <returns>Number of rows are effected</returns> public static int DeleteByID(long declerationID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var declaration = db.tblDeclarations.Where(g => g.DeclarationID == declerationID).FirstOrDefault(); db.DeleteObject(declaration); // Delete all record in VehicleDeclerat Table var vehicleDeclere = db.tblDeclarationVehicles.Where(g => g.DeclarationID == declerationID).ToList(); db.SaveChanges(); foreach (var item in vehicleDeclere) { var vehicleDeclereTemp = db.tblDeclarationVehicles.Where(g => g.DeclarationID == declerationID).FirstOrDefault(); if (vehicleDeclereTemp != null) db.DeleteObject(vehicleDeclereTemp); db.SaveChanges(); } int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static int DeleteVehicleChangeByVehicleId(long vehicleId) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var list = db.tblVehicleChanges.Where(x => x.VehicleFromID == vehicleId || x.VehicleToID == vehicleId); foreach (var vehicleChange in list) { db.DeleteObject(vehicleChange); } return db.SaveChanges(); }
/// <summary> /// Delete vehicle by ID /// </summary> /// <param name="vehicleID">Vehicle ID</param> /// <returns>Number of rows are effected</returns> public static int DeleteByID(long vehicleID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var vehicle = db.tblVehicles.Where(g => g.VehicleID == vehicleID).FirstOrDefault(); if (vehicle != null) db.DeleteObject(vehicle); db.SaveChanges(); // Revmove from vehicleDecleration var vehicleDeclere = db.tblDeclarationVehicles.Where(g => g.VehicleID == vehicleID).ToList(); foreach (var item in vehicleDeclere) { var vehicleDeclereTemp = db.tblDeclarationVehicles.Where(g => g.VehicleID == vehicleID).FirstOrDefault(); if (vehicleDeclereTemp != null) db.DeleteObject(vehicleDeclereTemp); db.SaveChanges(); } // TODO: db.Connection.Close(); return 1; }
public static int DeleteGroupByGroupID(int groupID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var group = db.tblGroups.Where(g => g.GroupID == groupID).FirstOrDefault(); if (group == null) { return 0; } //delete group db.DeleteObject(group); //delete group's users in tblUserInGroup List<tblUserInGroup> listTblUserInGroup = db.tblUserInGroups.Where(g => g.GroupID == groupID).ToList(); foreach (tblUserInGroup userInGroup in listTblUserInGroup) { db.DeleteObject(userInGroup); } //delete group's permission in tblUserGroupPermistion List<tblUserGroupPermission> listUserGroupPermission = db.tblUserGroupPermissions.Where(g => g.GroupID == groupID && g.PermissionType == UserGroupPermissionFactory.PERMISSION_TYPE_GROUP).ToList(); foreach (tblUserGroupPermission userGroupPermission in listUserGroupPermission) { db.DeleteObject(userGroupPermission); } int re = db.SaveChanges(); db.Connection.Close(); return re; }
public static int Delete (tblVehicleFeeSetting vehicleFee) { var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); var _vehicleFee = _db.tblVehicleFeeSettings.Where(g => g.VehicleTypeId == vehicleFee.VehicleTypeId && g.GoodsTypeId == vehicleFee.GoodsTypeId).FirstOrDefault(); if (vehicleFee != null) { try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); _db.DeleteObject(_vehicleFee); return _db.SaveChanges(); } catch (Exception ex) { return 0; } finally { _db.Connection.Close(); } } return 0; }
public static int DeleteType(String typeCode) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); var type = _db.tblTypes.FirstOrDefault(vt => vt.TypeCode == typeCode); _db.DeleteObject(type); return _db.SaveChanges(); } catch { return -1; } finally { _db.Connection.Close(); } }
public static int Delete(String customsCode) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); var customs = _db.tblCustoms.FirstOrDefault(g => g.CustomsCode == customsCode); _db.DeleteObject(customs); return _db.SaveChanges(); } catch { return -1; } finally { _db.Connection.Close(); } }