/// <summary> /// To Show the Existing Role of User /// </summary> /// <param name="objAdminUserProp"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>Apr-22,2016</createdOn> public List <string> EixstingRoleList(AdminUserProp objAdminUserProp) { List <string> objlstExistsRole = new List <string>(); CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { int userId = (from T in objAppWorksEntities.Users where T.UserCode == objAdminUserProp.UserCode && (T.Password == objAdminUserProp.Password || T.PIN == objAdminUserProp.Password) select T.UserID).FirstOrDefault(); if (userId != 0) { objlstExistsRole = (from tblList in objAppWorksEntities.UserRoles where tblList.UserID == userId select tblList.RoleName).ToList(); } } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(objlstExistsRole); }
/// <summary> /// Update table for next batch id /// </summary> /// <param name="BatchId"></param> /// <returns></returns> public bool SetPortStorageVehiclesNextBatchId(int BatchId) { bool Result = false; try { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { SettingTable settingTable = objAppWorksEntities.SettingTables.Where(v => v.ValueKey.Equals("NextPortStorageVehicleImportBatchID")).FirstOrDefault(); settingTable.ValueDescription = Convert.ToString(BatchId + 1); objAppWorksEntities.SaveChanges(); /// Check the Chenges in Table After Record update. Result = true; } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(Result); }
/// <summary> /// This method is used to get batch id /// </summary> /// <returns></returns> public int GetPortStorageVehiclesBatchId() { int BatchId = 0; try { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var query = (from qry in objAppWorksEntities.SettingTables where qry.ValueKey.Equals("NextPortStorageVehicleImportBatchID") select new { BatchId = qry.ValueDescription }).FirstOrDefault(); BatchId = Convert.ToInt32(query.BatchId); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(BatchId); }
/// <summary> /// This method is used to get Import File Name /// </summary> /// <returns>string</returns> public string GetPortStorageLocationImportFileName() { string ImportFileName = string.Empty; try { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var query = (from qry in objAppWorksEntities.SettingTables where qry.ValueKey.Equals("PortStorageLocationImportFileName") select new { ImportFileName = qry.ValueDescription }).FirstOrDefault(); ImportFileName = query.ImportFileName; } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(ImportFileName); }
/// <summary> /// Function to check the Login Credentials. /// </summary> /// <param name="objAdminUserProp"></param> /// <returns>Bool</returns> /// <createdBy></createdBy> /// <createdOn>Apr-18,2016</createdOn> public bool IsUserExists(AdminUserProp objAdminUserProp, List <RoleList> lstRoles) { using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { bool result = false; CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { // Count Existance of User var count = (from list in objAppWorksEntities.Users where list.UserCode == objAdminUserProp.UserCode select list).Count(); if (Convert.ToInt32(count) == 0) { result = true; AddAdminUser(objAdminUserProp, lstRoles); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(result); } }
/// <summary> /// function to get edit the Damage Code /// </summary> /// <param name="portStorageVehiclesId"></param> /// <returns>Int<returns> /// <createdBy></createdBy> /// <createdOn>May-6,2016</createdOn> public int EditDamageCode(PortStorageDamageDetailsProp objPortStorageDamageDetailsProp) { int value = 0; try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var tblPSVehicalDamageDetails = (from qry in objAppWorksEntities.PSVehicleDamageDetails where qry.PSVehicleDamageDetailID == objPortStorageDamageDetailsProp.PSVehicleDamageDetailID select qry).FirstOrDefault(); //Sta: UPDATE PSVehicleDamageDetail //Sta: SET DamageCode = @[lNewDamageCode] //Sta: WHERE PSVehicleDamageDetailID = @[iInspectionsAndDamageList.iVehicleDamageDetailID] if (tblPSVehicalDamageDetails != null) { tblPSVehicalDamageDetails.DamageCode = objPortStorageDamageDetailsProp.DamageCode; value = objAppWorksEntities.SaveChanges(); } } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(value); }
/// <summary> /// This method is used to check duplicate code and codetype values. /// </summary> /// <param name="objCodeProp"></param> /// <returns></returns> /// <createdOn>May-24-2016</createdon> public bool CheckDuplicateCodeAndType(string code, string codeType) { bool result = false; try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities psEntities = new PortStorageEntities()) { var codeChk = psEntities.Codes.Where(c => c.Code1 == code && c.CodeType == codeType).ToList().FirstOrDefault(); if (codeChk == null) { result = true; } else { result = false; } return(result); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function To Get The Record Status. /// </summary> /// <param></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>Apr-26,2016</createdOn> public List <string> RecordStatus() { List <string> lstRecordStatus = new List <string>(); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { //lstRecordStatus.Add("All"); lstRecordStatus.Add("Active"); lstRecordStatus.Add("Inactive"); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(lstRecordStatus); } }
/// <summary> /// This method is used to get message from storeprocedure. /// </summary> /// <param name="BatchId"></param> /// <param name="User"></param> /// <returns></returns> public PortStorageVehicleImportProp ImportPortStorageLocation(int BatchId, string User) { PortStorageVehicleImportProp portStorageVehicleImportProp = new PortStorageVehicleImportProp(); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { //int result = 0; CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { ((IObjectContextAdapter)objAppWorksEntities).ObjectContext.CommandTimeout = 1800; /// Calling The Stored Procedure var result = objAppWorksEntities.spImportPortStorageLocations(BatchId, User).FirstOrDefault(); if (result != null) { portStorageVehicleImportProp.ReturnCode = result.ReturnCode; portStorageVehicleImportProp.ReturnMessage = result.ReturnMessage; } return(portStorageVehicleImportProp); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } } }
/// <summary> /// function to Add the Inspection Type Only /// </summary> /// <param name="portStorageVehiclesId"></param> /// <returns>List<returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public List <string> InspectionTypeOnly() { List <string> lstInspectionType = new List <string>(); try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { //var list = (from qrycode in objAppWorksEntities.Codes select qrycode.CodeDescription).ToList(); var list = (from qry in objAppWorksEntities.Codes where qry.RecordStatus == "Active" && qry.CodeType == "PSInspectionType" orderby qry.CodeType, qry.SortOrder, qry.Code1 select qry.CodeDescription).ToList(); return(list.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(lstInspectionType); }
/// <summary> /// function to Load the Location History /// </summary> /// <param name="portStorageVehiclesId"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public List <PortStorageLocationHistoryProp> GetLocationHistory(int portStorageVehicalID) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var list = (from tblPortStorageLocationHistory in objAppWorksEntities.PortStorageVehiclesLocationHistories where tblPortStorageLocationHistory.PortStorageVehiclesID == portStorageVehicalID select new PortStorageLocationHistoryProp { PortStorageVehiclesLocationHistoryID = tblPortStorageLocationHistory.PortStorageVehiclesLocationHistoryID, BayLocation = tblPortStorageLocationHistory.BayLocation, LocationDate = tblPortStorageLocationHistory.LocationDate, CreationDate = tblPortStorageLocationHistory.CreationDate, Createdby = tblPortStorageLocationHistory.CreatedBy, UpdatedDate = tblPortStorageLocationHistory.UpdatedDate, Updatedby = tblPortStorageLocationHistory.CreatedBy // Set UpdatedbyInfo }).ToList().OrderByDescending(x => x.PortStorageVehiclesLocationHistoryID); return(list.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Delete system settings /// </summary> /// <param name="setting"></param> /// <returns></returns> public bool DeleteSystemSettings(AdminUserProp setting) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); bool result = false; using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var settingData = objAppWorksEntities.SettingTables.Where(x => x.ValueKey == setting.ValueKey).FirstOrDefault(); objAppWorksEntities.SettingTables.Remove(settingData); objAppWorksEntities.SaveChanges(); result = true; } return(result); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// add system settings /// </summary> /// <param name="setting"></param> /// <returns></returns> public bool InsertSystemSettings(AdminUserProp setting) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); bool result = false; using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { SettingTable newSetting = new SettingTable(); newSetting.ValueKey = setting.ValueKey; newSetting.ValueDescription = setting.ValueDescription; objAppWorksEntities.SettingTables.Add(newSetting); objAppWorksEntities.SaveChanges(); result = true; } return(result); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This method is used to Get Port Storage Vehicle List /// </summary> /// <param name="BatchId"></param> /// <returns></returns> public List <PortStorageVehicleImportProp> GetPortStorageLocationImportList(int BatchId) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var query = (from qry in objAppWorksEntities.PortStorageVehicleLocationImports where qry.BatchID == BatchId orderby qry.PortStorageVehicleLocationImportID select new PortStorageVehicleImportProp { PortStorageVehiclesLocationImportID = qry.PortStorageVehicleLocationImportID, BatchId = qry.BatchID, Vin = qry.VIN, Location = qry.Location, RecordStatus = qry.RecordStatus, } ).AsQueryable(); return(query.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// To Remove the Record of existing User /// </summary> /// <param name="AdminUserProp"></param> /// <returns>void</returns> /// <createdBy></createdBy> /// <createdOn>Apr-28,2016</createdOn> public void RemoveUserDetails(AdminUserProp objAdminUserProp) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { int userId = (from T in objAppWorksEntities.Users where T.UserCode == objAdminUserProp.UserCode && (T.Password == objAdminUserProp.Password || T.PIN == objAdminUserProp.Password) select T.UserID).FirstOrDefault(); if (userId != 0) { var x = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userId && tblUser.Password == objAdminUserProp.Password select tblUser).FirstOrDefault(); objAppWorksEntities.Users.Remove(x); objAppWorksEntities.SaveChanges(); } } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Get All Customer list from dataabse /// </summary> /// <returns></returns> public List <PortStorageRequestsReportProp> LoadCustomerList() { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities psEntities = new PortStorageEntities()) { var query = (from cust in psEntities.Customers where cust.PortStorageCustomerInd == 1 orderby cust.CustomerName ascending select new PortStorageRequestsReportProp { CustomerName = !string.IsNullOrEmpty(cust.ShortName) ? cust.ShortName : cust.CustomerName, CustomerId = cust.CustomerID } ); return(query.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } //return lstCust; }
/// <summary> /// This method is used to delete code details from database /// </summary> /// <param name="CodeID"></param> /// <returns></returns> /// <createdOn>May-24-2016</createdon> public bool DeleteCodeAdminDetails(int CodeID) { bool result = false; try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities psEntities = new PortStorageEntities()) { var CodeData = psEntities.Codes.Where(C => C.CodeID == CodeID).FirstOrDefault(); if (CodeData != null) { psEntities.Codes.Remove(CodeData); psEntities.SaveChanges(); result = true; } return(result); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function to check the User Role of Logged User. /// </summary> /// <param name="objLoginProp"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>Apr-19,2016</createdOn> public List <string> GetUserRole(LoginProperties objLoginProp) { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { List <string> userRolelist = new List <string>(); CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { int userId = (from T in objAppWorksEntities.Users where T.UserCode == objLoginProp.Username && (T.Password == objLoginProp.Password || T.PIN == objLoginProp.Password) select T.UserID).FirstOrDefault(); if (userId != 0) { userRolelist = (from userRole in objAppWorksEntities.UserRoles where userRole.UserID == userId select userRole.RoleName).ToList(); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(userRolelist); } }
/// <summary> /// For getting Lane Summary list /// </summary> /// <returns></returns> public List <PortStorageInventoryList> GetPortStorageLaneSummaryList() { // creating the object of PortStorageEntities Database using (PortStorageEntities psEntities = new PortStorageEntities()) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { var sqlQuery = psEntities.Database.SqlQuery <PortStorageInventoryList>(SqlConstants.LANE_SUMMARY_QUERY); var selectedResult = sqlQuery.Select(x => new PortStorageInventoryList { Baylocation = x.Baylocation, CustomerName = x.CustomerName, RecordsCount = x.RecordsCount }).ToList(); return(selectedResult); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } } }
/// <summary> /// To get list of all customer with their selection status coressponding to UserID /// </summary> /// <param name="userID"></param> /// <returns></returns> public List <UserCustomerList> GetCustomers(int userID) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortalDbEntities objAppWorksEntitiesPortal = new PortalDbEntities()) { using (PortStorageEntities portalEntities = new PortStorageEntities()) { var LstCUstomers = objAppWorksEntitiesPortal.spGetSelectedUserCustomerList(userID).Select(x => new UserCustomerList { CustomerID = x.CustomerID, CustomerName = x.CustomerName, IsSelected = x.IsSelected == 0 ? false : true }); List <UserCustomerList> lstUserCustomers = new List <UserCustomerList>(); lstUserCustomers = LstCUstomers.ToList(); return(lstUserCustomers); } } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// function to get the vehicle Per Diem details /// </summary> /// <param name="portStorageVehiclesId"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>May-5,2016</createdOn> public List <PerDiemProp> GetPerDiemVehicalDetails(int portStorageVehiclesId) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { // query to get details from database var query = (from qry in objAppWorksEntities.PortStoragePerDiems where qry.PortStorageVehiclesID == portStorageVehiclesId select new PerDiemProp { PortStoragePerDiemID = SqlFunctions.StringConvert((double)qry.PortStoragePerDiemID), PerDiemDate = qry.PerDiemDate, PerDiemVal = qry.PerDiem, PortStorageVehiclesID = qry.PortStorageVehiclesID, } ).ToList(); return(query.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// /// </summary> /// <param name="objLoginProp"></param> /// <returns></returns> public LoginProperties GetLoggedInUserDetails(LoginProperties loginProps) { // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var userDetails = (from user in objAppWorksEntities.Users where user.UserCode == loginProps.Username && (user.Password == loginProps.Password || user.PIN == loginProps.Password) select user).FirstOrDefault(); if (userDetails != null) { //if FirstName OR LastName is empty then show same Username on Main window if (string.IsNullOrEmpty(userDetails.FirstName) || string.IsNullOrEmpty(userDetails.LastName)) { loginProps.FullUserName = loginProps.Username; } else { loginProps.FullUserName = string.Format("{0} {1}", userDetails.FirstName, userDetails.LastName); } loginProps.UserRoles = (from userRole in objAppWorksEntities.UserRoles where userRole.UserID == userDetails.UserID select userRole.RoleName).ToList(); } } return(loginProps); }
/// <summary> /// To get list of system settings /// </summary> /// <param name="userID"></param> /// <returns></returns> public List <AdminUserProp> GetSystemSettings() { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var lstSystemSettings = (from settings in objAppWorksEntities.SettingTables orderby settings.ValueKey select new AdminUserProp { ValueKey = settings.ValueKey, ValueDescription = settings.ValueDescription } ).Distinct().ToList(); return(lstSystemSettings); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This method is used to update code details /// </summary> /// <param name="objCodeProp"></param> /// <returns></returns> /// <createdOn>May-24-2016</createdon> public bool UpdateCodeAdminDetails(CodeProp objCodeProp) { bool result = false; try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities psEntities = new PortStorageEntities()) { Code code = psEntities.Codes.Where(c => c.CodeID == objCodeProp.CodeID).FirstOrDefault(); code.Code1 = objCodeProp.Code1; code.CodeType = objCodeProp.CodeType; code.RecordStatus = objCodeProp.RecordStatus; code.CodeDescription = objCodeProp.CodeDescription; code.Value1 = objCodeProp.Value1; code.Value1Description = objCodeProp.Value1Description; code.Value2 = objCodeProp.Value2; code.Value2Description = objCodeProp.Value2Description; code.SortOrder = objCodeProp.SortOrder; code.UpdatedDate = objCodeProp.UpdatedDate; code.UpdatedBy = objCodeProp.UpdatedBy; psEntities.SaveChanges(); result = true; return(result); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// To Remove the Record of existing User /// </summary> /// <param name="AdminUserProp"></param> /// <returns>int</returns> /// <createdBy></createdBy> /// <createdOn>Apr-29,2016</createdOn> public int RemoveUserDetails(FindUserProp objFindUserProp) { int value = 0; try { int userID = Convert.ToInt32(objFindUserProp.UserID); CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { string userName = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.UserCode).FirstOrDefault(); string password = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.Password).FirstOrDefault(); if (userID != 0) { var userRecord = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID && tblUser.Password == password && tblUser.UserCode == userName select tblUser).FirstOrDefault(); User user = objAppWorksEntities.Users.Where(U => U.UserID == userID).FirstOrDefault(); user.RecordStatus = objFindUserProp.RecordStatus; objAppWorksEntities.Users.Remove(userRecord); objAppWorksEntities.SaveChanges(); value = objAppWorksEntities.SaveChanges(); } } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(value); }
/// <summary> /// function to Add the Damage Code /// </summary> /// <param name="portStorageVehiclesId"></param> /// <returns>Int<returns> /// <createdBy></createdBy> /// <createdOn>May-10,2016</createdOn> public int AddDamageCode(DamageCodeProp objDamageCodeProp) { int value = 0; try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { //Sta: SELECT TOP 1 PSVehicleInspectionID //Sta: FROM PSVehicleInspection //Sta: WHERE PortStorageVehiclesID = @[iVehicleID] //Sta: AND InspectionType = @[iInspectionType] //Sta: ORDER BY PSVehicleInspectionID DESC var getInspectioDetails = (from qry in objAppWorksEntities.PSVehicleInspections where qry.PortStorageVehiclesID == objDamageCodeProp.PortStorageVehiclesID && qry.InspectionType == objDamageCodeProp.PSVehicleInspectionID orderby qry.PSVehicleInspectionID descending select qry).FirstOrDefault(); if (getInspectioDetails == null) { System.Data.Entity.Core.Objects.ObjectParameter objReturnId = new System.Data.Entity.Core.Objects.ObjectParameter("rRecordID", typeof(int)); System.Data.Entity.Core.Objects.ObjectParameter objReturnCode = new System.Data.Entity.Core.Objects.ObjectParameter("rReturnCode", 0); var getResult = objAppWorksEntities.spCreatePortStorageVehicleInspectionRecord(objDamageCodeProp.PortStorageVehiclesID, objDamageCodeProp.PSVehicleInspectionID, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, 0, 0, 0, "", objReturnId, objReturnCode); } if (getInspectioDetails == null) { getInspectioDetails = (from qry in objAppWorksEntities.PSVehicleInspections where qry.PortStorageVehiclesID == objDamageCodeProp.PortStorageVehiclesID && qry.InspectionType == objDamageCodeProp.PSVehicleInspectionID orderby qry.PSVehicleInspectionID descending select qry).FirstOrDefault(); } // add damagecode System.Data.Entity.Core.Objects.ObjectParameter rReturnCode = new System.Data.Entity.Core.Objects.ObjectParameter("rReturnCode", typeof(int)); var result = objAppWorksEntities.spProcessPortStorageDamageCode(objDamageCodeProp.PortStorageVehiclesID, getInspectioDetails.PSVehicleInspectionID, objDamageCodeProp.DamageCode, objDamageCodeProp.DamageDescription, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, rReturnCode); //objAppWorksEntities.Database.ExecuteSqlCommand("spProcessPortStorageDamageCode", objDamageCodeProp.PortStorageVehiclesID, getInspectioDetails.PSVehicleInspectionID, objDamageCodeProp.DamageCode, objDamageCodeProp.DamageDescription, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, rReturnCode); if (rReturnCode != null && rReturnCode.Value != null) { value = Convert.ToInt32(rReturnCode); } } } catch (Exception) { //throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(value); }
/// <summary> /// For getting Invoice list coressponding to a billingID and time period /// </summary> /// <param name="billinID"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public List <InvoiceListProp> LoadInvoiceList(int?billinID, DateTime?startDate, DateTime?endDate) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { var lstInvoiceList = new List <InvoiceListProp>(); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { if (endDate != null) { endDate = Convert.ToDateTime(endDate).AddDays(1); } string internalQuery = SqlConstants.VEHICLE_INVOICE_SUMMARY; var parameters = new object[3]; var paramBillingId = new SqlParameter("BillingIDString", System.Data.SqlDbType.VarChar); paramBillingId.Value = billinID.ToString(); var paramStartDate = new SqlParameter("startDate", System.Data.SqlDbType.DateTime); paramStartDate.Value = startDate ?? (object)DBNull.Value; var paramEndDate = new SqlParameter("endDate", System.Data.SqlDbType.DateTime); paramEndDate.Value = endDate ?? (object)DBNull.Value; var sqlQuery = objAppWorksEntities.Database.SqlQuery <InvoiceListProp>(internalQuery, new object[] { paramBillingId, paramStartDate, paramEndDate }); lstInvoiceList = sqlQuery.ToList <InvoiceListProp>(); } return(lstInvoiceList.ToList()); //var lstInvoiceList = (from billing in psEntities.Billings // join customer in psEntities.Customers // on billing.CustomerID equals customer.CustomerID // where billing.InvoiceType == "StorageCharge" && billing.InvoiceAmount > 0 // select new InvoiceListProp // { // CustomerNumber = customer.CustomerCode, // InvoiceNumber = billing.InvoiceNumber, // CustomerName = string.IsNullOrEmpty(customer.ShortName) ? customer.CustomerName : customer.ShortName, // InvoiceDate = billing.InvoiceDate, // InvoiceAmount = (double)billing.InvoiceAmount, // Units = (((from psvehicle in psEntities.PortStorageVehicles where psvehicle.BillingID == billinID select psvehicle)).Count()) // }).AsQueryable(); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// To get list of all roles with their selection status coressponding to UserID /// </summary> /// <param name="userID"></param> /// <returns></returns> public List <RoleList> GetRolesSelection(int userID) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { var lstSelectedRoles = (from userroles in objAppWorksEntities.Codes join role in objAppWorksEntities.UserRoles on userroles.Code1 equals role.RoleName where role.UserID == userID select new RoleList { RoleName = role.RoleName, IsSelected = true } ).Distinct(); var lstRoles = (from userroles in objAppWorksEntities.Codes where userroles.CodeType == "UserRole" select new RoleList { RoleName = userroles.Code1, IsSelected = true } ).Distinct(); var lstexclude = lstRoles.Select(x => new RoleList { RoleName = x.RoleName, IsSelected = false }) .Except(lstSelectedRoles.Select(x => new RoleList { RoleName = x.RoleName, IsSelected = false })); var lstMerge = lstexclude.Union(lstSelectedRoles); return(lstMerge.OrderBy(x => x.RoleName).ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// To Modify the Record of existing User /// </summary> /// <param name="AdminUserProp"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>Apr-28,2016</createdOn> public AdminUserDeatils GetModificationRecord(AdminUserProp objAdminUserProp) { AdminUserDeatils objAdminUserDeatils = new AdminUserDeatils(); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { objAdminUserDeatils = (from tblUsers in objAppWorksEntities.Users where tblUsers.UserCode == objAdminUserProp.UserCode select new AdminUserDeatils { UserIDInfo = tblUsers.UserID, UserCodeInfo = tblUsers.UserCode, FirstNameInfo = tblUsers.FirstName, LastNameInfo = tblUsers.LastName, PhoneInfo = tblUsers.Phone, ExtentionInfo = tblUsers.PhoneExtension, CellPhoneInfo = tblUsers.CellPhone, FaxNumberInfo = tblUsers.FaxNumber, EmailInfo = tblUsers.EmailAddress, PasswordInfo = tblUsers.Password, PortPassIdInfo = tblUsers.PortPassIDNumber, PinInfo = tblUsers.PIN, LblXOffsetInfo = (decimal)tblUsers.LabelXOffset, LblYOffsetInfo = (decimal)tblUsers.LabelYOffset, EmployeeInfo = tblUsers.EmployeeNumber, RecordStatusInfo = tblUsers.RecordStatus, CreationDateInfo = tblUsers.CreationDate, CreatedByInfo = tblUsers.CreatedBy }).FirstOrDefault(); //= list.ToList(); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(objAdminUserDeatils); } }
/// <summary> /// This method is used to Load Batch list from database/ /// </summary> /// <returns></returns> public List <PortStorageRequestsReportProp> LoadBatchList() { List <PortStorageRequestsReportProp> lstBatch = new List <PortStorageRequestsReportProp>(); try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); // creating the object of PortStorageEntities Database using (PortStorageEntities psEntities = new PortStorageEntities()) { var query = (from cust in psEntities.PortStorageVehicles where cust.RequestPrintedInd == 1 && cust.RequestPrintedBatchID != null group cust by new { cust.RequestPrintedBatchID, DateRequestPrinted = DbFunctions.TruncateTime(cust.DateRequestPrinted) } into data let rawData = new { RequestPrintedBatchID = data.Key.RequestPrintedBatchID, DateRequestPrinted = data.Key.DateRequestPrinted, BatchCount = data.Count() } orderby rawData.RequestPrintedBatchID descending select new PortStorageRequestsReportProp { RequestPrintedBatchID = rawData.RequestPrintedBatchID, DateRequestPrinted = rawData.DateRequestPrinted, BatchCount = rawData.BatchCount } );//.OrderByDescending(x => x.RequestPrintedBatchID); return(query.ToList()); } } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } //return lstBatch; }