public static List<ViewVehicleOverdue> GetAllVehicleNotCompleted() { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<ViewVehicleOverdue> data = db.ViewVehicleOverdues.Where(g => g.IsCompleted != true).ToList(); db.Connection.Close(); return data; }
public static List<tblPermission> GetPermissionByType(string type) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<tblPermission> list = db.tblPermissions.Where(g => g.TypeCode == type).ToList(); db.Connection.Close(); return list; }
public static ViewAllCheckResult SelectByID(int vehicleCheckID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); ViewAllCheckResult allCheckResult = db.ViewAllCheckResults.Where(g => g.VehicleCheckID == vehicleCheckID).FirstOrDefault(); db.Connection.Close(); return allCheckResult; }
public static List<tblUserInGroup> GetTblUserInGroupByGroupID(int groupID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var userGroups = db.tblUserInGroups.Where(g => g.GroupID == groupID).ToList(); db.Connection.Close(); return userGroups; }
public static int Update(tblVehicleType vehicletype) { var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); var _vehicletype = (from vt in _db.tblVehicleTypes where vt.VehicleTypeID == vehicletype.VehicleTypeID select vt).First(); _vehicletype.Name = vehicletype.Name; _vehicletype.Capacity = vehicletype.Capacity; _vehicletype.Description = vehicletype.Description; vehicletype.UpdatedDate = CommonFactory.GetCurrentDate(); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); _db.SaveChanges(); } catch (Exception ex) { return 1; } finally { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); _db.Connection.Close(); } return 0; }
/// <summary> /// Hien lên những xe đã hoàn thành thủ tục và đã trả hồ sơ của ngày hiện tại /// </summary> /// <returns></returns> public static List<ViewAllVehicleHasGood> GetAllAllVehicleCompleted() { DateTime today = CommonFactory.GetCurrentDate(); var startToday = new DateTime(today.Year, today.Month, today.Day, 0, 0, 0); var endToday = new DateTime(today.Year, today.Month, today.Day, 23, 59, 59); var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); //var data = db.ViewAllVehicleHasGoods.Where(g => g.ConfirmStatus != null && g.IsGoodsImported == true && g.IsCompleted == true && g.ConfirmDate >= startToday && g.ConfirmDate <= endToday).OrderByDescending(g => g.ImportDate).ToList(); //tim cac xe da nhap canh co hang, nhung chua vao noi dia, va co to khai da xac nhan tra ho so, chi hien thi theo ngay tra so so = ngay hien tai List<ViewAllVehicleHasGood> data = db.ViewAllVehicleHasGoods.Where(g => g.HasGoodsImported == true && g.IsCompleted != true && g.ConfirmStatus != null && g.ConfirmDate >= startToday && g.ConfirmDate <= endToday).OrderByDescending(g => g.ConfirmDate).ToList(); db.Connection.Close(); List<ViewAllVehicleHasGood> list = new List<ViewAllVehicleHasGood>(); HashSet<long> listVehicleId = new HashSet<long>(); if (data != null && data.Count > 0) { foreach (ViewAllVehicleHasGood obj in data) { if (listVehicleId.Add(obj.VehicleID)) { list.Add(obj); } } } return list; }
public static int Update(tblType typeObj) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); tblType originType = _db.tblTypes.Where(g => g.TypeCode == typeObj.TypeCode).FirstOrDefault(); if (originType == null) { return -1; } originType.TypeName = typeObj.TypeName; originType.Description = typeObj.Description; originType.ModifiedBy = typeObj.ModifiedBy; originType.ModifiedDate = CommonFactory.GetCurrentDate(); try { return _db.SaveChanges(); } catch (Exception ex) { return -1; } finally { _db.Connection.Close(); } }
public bool DeleteItem(string[] itemParams) { if (itemParams.Length < 3) return false; int id = itemParams[0].StringToInt(); int verhiceId = itemParams[1].StringToInt(); string branchId = itemParams[2]; var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { var deleteItem = _db.tblDeclarationVehicles.FirstOrDefault( item => item.DeclarationID == id && item.VehicleID == verhiceId && item.BranchId == branchId); if (deleteItem != null) { _db.DeleteDirectly(deleteItem); _db.SaveChanges(); } return true; } catch (Exception exception) { LogManager.GetLogger("ECustoms.DeclarationVehicleFactory").Error(exception.ToString()); throw; } 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(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(); }
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 DateTime GetCurrentDate() { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var objCurentDate = db.ViewGetCurrentDates.FirstOrDefault(); db.Connection.Close(); return objCurentDate.CurrentDateTime; }
public static tblVehicleCheck SelectVehicleCheckByID(int vehicleCheckID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); tblVehicleCheck vehicleCheck = db.tblVehicleChecks.Where(g => g.VehicleCheckID == vehicleCheckID).FirstOrDefault(); db.Connection.Close(); return vehicleCheck; }
public static string GetTypeNameById(int goodTypeId) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var typeName = db.tblGoodsTypes.Where(g => g.TypeId == goodTypeId).Select(g=>g.TypeName).FirstOrDefault(); db.Connection.Close(); return typeName; }
public static List<ViewUserGroup> GetByUserID(int userID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<ViewUserGroup> list= db.ViewUserGroups.Where(g => g.UserID == userID).ToList(); db.Connection.Close(); return list; }
public static List<tblPermissionType> GetAllPermissionType() { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List<tblPermissionType> list = db.tblPermissionTypes.ToList(); db.Connection.Close(); return list; }
public bool DeleteItem(string[] itemParams) { if (itemParams.Length < 2) return false; string id = itemParams[0]; string branchId = itemParams[1]; var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { var deleteItem = _db.tblPermissionTypes.FirstOrDefault( item => item.TypeCode == id && item.BranchId == branchId); if (deleteItem != null) { _db.DeleteDirectly(deleteItem); _db.SaveChanges(); } return true; } catch (Exception exception) { LogManager.GetLogger("ECustoms.PermissionTypeFactory").Error(exception.ToString()); throw; } finally { _db.Connection.Close(); } }
public bool BatchInsert(object[] items) { var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); try { _db.Connection.Open(); foreach (object item in items) { _db.AddObjectDirectly("tblProfileConfigs", item); } _db.SaveChanges(); return true; } catch (Exception ex) { LogManager.GetLogger("ECustoms.AllFactory").Error(ex.ToString()); throw; } finally { _db.Connection.Close(); } return false; }
public static List<ViewAllCheck> SelectAll() { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List < ViewAllCheck > list = db.ViewAllChecks.OrderByDescending(g => g.ModifedDate).ToList(); db.Connection.Close(); return list; }
public static List<tblGroup> SelectAll() { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List < tblGroup > list = db.tblGroups.ToList(); db.Connection.Close(); return list; }
/// <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(); }
/// <summary> /// Check if the group name is exsiting /// </summary> /// <param name="groupName"></param> /// <returns></returns> public static bool IsExistingName(string groupName) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var group = db.tblGroups.Where(g => g.GroupName == groupName).ToList(); db.Connection.Close(); return group.Count != 0; }
public static List<tblUserGroupPermission> GetByUserID(int userID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); List < tblUserGroupPermission > list = db.tblUserGroupPermissions.Where(g => g.UserID == userID && g.PermissionType == PERMISSION_TYPE_USER).ToList(); db.Connection.Close(); return list; }
public static tblGroup getGroupByID(int groupID) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var group = db.tblGroups.Where(g => g.GroupID == groupID).FirstOrDefault(); db.Connection.Close(); return group; }
public static int Insert(tblUserInGroup userGroup) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); db.AddTotblUserInGroups(userGroup); int re= db.SaveChanges(); db.Connection.Close(); return re; }
public static int Insert(tblVehicleCheck tblVehicleCheck) { var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); tblVehicleCheck.CreatedDate = CommonFactory.GetCurrentDate(); db.AddTotblVehicleChecks(tblVehicleCheck); int re = db.SaveChanges(); db.Connection.Close(); return re; }
/// <summary> /// Update Vehicle /// </summary> /// <param name="vehicle"></param> /// <returns></returns> public static int UpdateVehicle(tblVehicle vehicle ) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); // Get orgin vehicle var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault(); db.Attach(vehicleOrgin); db.ApplyPropertyChanges("tblVehicles", vehicle); return db.SaveChanges(); }
public static bool IsExisting(long vehicleID, long declarationID) { var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); var temp = db.tblDeclarationVehicles.Where(g => g.VehicleID == vehicleID && g.DeclarationID == declarationID). FirstOrDefault(); db.Connection.Close(); return temp != null; }
/// <summary> /// Insert User /// </summary> /// <param name="userInfo">UserInfo object</param> /// <returns>Number of rows are effected</returns> public static int Insert(tblUser userInfo) { // Encode password & username userInfo.Password = Common.Encode(userInfo.Password); var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); db.AddTotblUsers(userInfo); 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 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; }