public tblAccountSubType GetAccountSubTypeById(long Id, long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblAccountSubTypes where data.Id == Id && data.CompanyId == CompanyId select data).FirstOrDefault()); } }
public tblCompany GetCompanyById(long Id) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblCompanies where data.Id == Id select data).FirstOrDefault()); } }
public void UpdateCompany(long id, tblCompany company) { using (OriginatorEntities db = new OriginatorEntities()) { tblCompany found = db.tblCompanies.Find(id); if (!string.IsNullOrWhiteSpace(company.Name)) { found.Name = company.Name; } if (!string.IsNullOrWhiteSpace(company.Street)) { found.Street = company.Street; } if (!string.IsNullOrWhiteSpace(company.City)) { found.City = company.City; } if (!string.IsNullOrWhiteSpace(company.Country)) { found.Country = company.Country; } if (!string.IsNullOrWhiteSpace(company.Landline)) { found.Landline = company.Landline; } if (!string.IsNullOrWhiteSpace(company.Mobile)) { found.Mobile = company.Mobile; } if (!string.IsNullOrWhiteSpace(company.FaxNo)) { found.FaxNo = company.FaxNo; } if (!string.IsNullOrWhiteSpace(company.Website)) { found.Website = company.Website; } if (!string.IsNullOrWhiteSpace(company.NTN.ToString())) { found.NTN = company.NTN; } if (!string.IsNullOrWhiteSpace(company.STN.ToString())) { found.STN = company.STN; } if (company.ModifiedBy != null && company.ModifiedBy > 0) { found.ModifiedBy = company.ModifiedBy; } if (!string.IsNullOrWhiteSpace(company.ModifiedDate.ToString())) { found.ModifiedDate = company.ModifiedDate; } db.SaveChanges(); } }
public List <tblAccountSubType> GetAccountSubTypes(long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblAccountSubTypes where data.IsDeleted != true && data.CompanyId == CompanyId select data).ToList()); } }
public List <ORViewEmployeeData> GetEmployees(long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.ORViewEmployeeDatas where data.CompanyId == CompanyId && data.IsDeleted != true select data).ToList()); } }
public DAL.Employee GetEmployee(long Id) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.Employees where data.ID == Id select data).FirstOrDefault()); } }
public List <ORViewMonthlyHRData> GetMonthlyHR(string Month, string CurrentYear) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.ORViewMonthlyHRDatas where data.Monthh == Month && data.Yearr == CurrentYear select data).ToList()); } }
public ORViewMonthlyHRData GetMonthlyHRAttandace(long EmployeeId) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.ORViewMonthlyHRDatas where data.EmployeeId == EmployeeId select data).FirstOrDefault()); } }
public List <tblCompany> GetCompanies() { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblCompanies where data.IsDeleted != true select data).ToList()); } }
public List <tblRole> GetRoles() { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblRoles where data.RoleName != "SuperAdmin" select data).ToList()); } }
public tblSalary GetSalaryOfEmployee(long EmployeeId) { using (OriginatorEntities db = new OriginatorEntities()) { return((from data in db.tblSalaries where data.EmployeeId == EmployeeId //orderby data.CreatedDate select data).FirstOrDefault()); } }
public void DeleteEmployee(long Employeeid, long DeletedBy) { using (OriginatorEntities db = new OriginatorEntities()) { DAL.Employee found = db.Employees.Find(Employeeid); found.DeletedDate = DateTime.Now; found.IsDeleted = true; found.DeletedBy = DeletedBy; db.SaveChanges(); } }
public void AddEmployee(DAL.Employee e, tblSalary s) { using (OriginatorEntities db = new OriginatorEntities()) { db.Employees.Add(e); db.SaveChanges(); s.EmployeeId = e.ID; db.tblSalaries.Add(s); db.SaveChanges(); } }
public void DeleteCompany(long Id, long DeletedBy) { using (OriginatorEntities db = new OriginatorEntities()) { tblCompany found = db.tblCompanies.Find(Id); found.DeletedBy = DeletedBy; found.DeletedDate = DateTime.Now; found.IsDeleted = true; db.SaveChanges(); } }
public void DeleteUser(long Id, long DeletedBy, DateTime DeletedDate) { using (OriginatorEntities db = new OriginatorEntities()) { tblUser found = db.tblUsers.Find(Id); found.DeletedBy = DeletedBy; found.DeletedDate = DeletedDate; found.IsDeleted = true; db.SaveChanges(); } }
public void AddSubAccount(tblSubAccount subaccount) { using (OriginatorEntities db = new OriginatorEntities()) { db.tblSubAccounts.Add(subaccount); var InitialCashSubAccount = (from data in db.tblSubAccounts where data.CompanyId == subaccount.CompanyId && data.SubAccountName == "Initial Cash" select data).FirstOrDefault(); InitialCashSubAccount.Amount = InitialCashSubAccount.Amount - subaccount.Amount; db.SaveChanges(); } }
public string GetDefaultFromAccountNumber(long id, long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { var SubAccountId = (from data in db.tblUserSubAccounts where data.UserId == id && data.CompanyId == CompanyId select data.DefaultFromId).FirstOrDefault(); var DefaultFromAccountNumber = (from data in db.tblSubAccounts where data.Id == SubAccountId select data.AccountNumber).FirstOrDefault(); return(DefaultFromAccountNumber); } }
public void UpdateUser(long id, tblUser user) { using (OriginatorEntities db = new OriginatorEntities()) { tblUser found = db.tblUsers.Find(id); if (!string.IsNullOrWhiteSpace(user.UserName)) { found.UserName = user.UserName; } if (!string.IsNullOrWhiteSpace(user.Email)) { found.Email = user.Email; } if (!string.IsNullOrWhiteSpace(user.Password)) { found.Password = user.Password; } if (!string.IsNullOrWhiteSpace(user.PhoneNo)) { found.PhoneNo = user.PhoneNo; } if (!string.IsNullOrWhiteSpace(user.Address)) { found.Address = user.Address; } if (!string.IsNullOrWhiteSpace(user.CNIC)) { found.CNIC = user.CNIC; } if (user.RoleId != null && user.RoleId > 0) { found.RoleId = user.RoleId; } if (user.CompanyId != null && user.CompanyId > 0) { found.CompanyId = user.CompanyId; } if (user.ModifiedBy != null && user.ModifiedBy > 0) { found.ModifiedBy = user.ModifiedBy; } if (!string.IsNullOrWhiteSpace(user.ModifiedDate.ToString())) { found.ModifiedDate = user.ModifiedDate; } db.SaveChanges(); } }
public void AddCompany(tblCompany company) { using (OriginatorEntities db = new OriginatorEntities()) { db.tblCompanies.Add(company); db.SaveChanges(); tblAccount Account = new tblAccount { AccountName = "Initial Cash", CompanyId = company.Id, Description = "Initial Cash Account", Source = "Cash", CreatedDate = DateTime.Now, CreatedBy = company.CreatedBy }; db.tblAccounts.Add(Account); db.SaveChanges(); tblSubAccount SubAccount = new tblSubAccount { SubAccountName = "Initial Cash", Description = "Initial Cash SubAccount", Amount = 0, AccountId = Account.Id, AccountNumber = "Initial Cash " + company.Name, CompanyId = company.Id, CreatedBy = company.CreatedBy, CreatedDate = DateTime.Now, TypeId = 8 }; db.tblSubAccounts.Add(SubAccount); db.SaveChanges(); } }
public void UpdateSubAccount(long id, tblSubAccount SubAccount) { using (OriginatorEntities db = new OriginatorEntities()) { tblSubAccount found = db.tblSubAccounts.Find(id); if (!string.IsNullOrWhiteSpace(SubAccount.SubAccountName)) { found.SubAccountName = SubAccount.SubAccountName; } if (!string.IsNullOrWhiteSpace(SubAccount.Description)) { found.Description = SubAccount.Description; } if (!string.IsNullOrWhiteSpace(SubAccount.Amount.ToString())) { found.Amount = SubAccount.Amount; } if (!string.IsNullOrWhiteSpace(SubAccount.AccountNumber)) { found.AccountNumber = SubAccount.AccountNumber; } if (SubAccount.CompanyId != null && SubAccount.CompanyId > 0) { found.CompanyId = SubAccount.CompanyId; } if (SubAccount.TypeId != null && SubAccount.TypeId > 0) { found.TypeId = SubAccount.TypeId; } if (SubAccount.AccountId != null && SubAccount.AccountId > 0) { found.AccountId = SubAccount.AccountId; } if (SubAccount.ModifiedBy != null && SubAccount.ModifiedBy > 0) { found.ModifiedBy = SubAccount.ModifiedBy; } if (!string.IsNullOrWhiteSpace(SubAccount.ModifiedDate.ToString())) { found.ModifiedDate = SubAccount.ModifiedDate; } db.SaveChanges(); } }
public void AddTransaction(tblAccountTransaction AccountTransaction) { using (OriginatorEntities db = new OriginatorEntities()) { tblSubAccount FoundFromAccount = (from data in db.tblSubAccounts where data.AccountNumber == AccountTransaction.DefaultFrom select data).FirstOrDefault(); tblSubAccount FoundToAccount = (from data in db.tblSubAccounts where data.AccountNumber == AccountTransaction.DefaultTo select data).FirstOrDefault(); FoundFromAccount.Amount = FoundFromAccount.Amount - AccountTransaction.Amount; FoundFromAccount.ModifiedBy = AccountTransaction.CreatedBy; FoundFromAccount.ModifiedDate = DateTime.Now; FoundToAccount.Amount = FoundToAccount.Amount + AccountTransaction.Amount; FoundToAccount.ModifiedBy = AccountTransaction.CreatedBy; FoundToAccount.ModifiedDate = DateTime.Now; db.tblAccountTransactions.Add(AccountTransaction); db.SaveChanges(); } }
public List <tblSubAccount> GetToAssociatedOfCurrentUser(long id, long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { var ToAssociatedIds = (from data in db.tblUserSubAccounts where data.UserId == id && data.CompanyId == CompanyId select data.ToAssociatedId).FirstOrDefault(); List <tblSubAccount> List = new List <tblSubAccount>(); var TestIds = ToAssociatedIds.Split(','); var Ids = TestIds.Where(x => !string.IsNullOrEmpty(x)).ToArray(); foreach (var item in Ids) { var SubId = Convert.ToInt64(item); var d = (from data in db.tblSubAccounts where data.Id == SubId select data).FirstOrDefault(); List.Add(d); } return(List); } }
public void UpdateEmployee(long EmployeeId, DAL.Employee e, tblSalary s) { using (OriginatorEntities db = new OriginatorEntities()) { DAL.Employee found = db.Employees.Find(EmployeeId); if (!string.IsNullOrWhiteSpace(e.FirstName)) { found.FirstName = e.FirstName; } if (!string.IsNullOrWhiteSpace(e.LastName)) { found.LastName = e.LastName; } if (!string.IsNullOrWhiteSpace(e.Designation)) { found.Designation = e.Designation; } if (!string.IsNullOrWhiteSpace(e.ImageUrl)) { found.ImageUrl = e.ImageUrl; } if (e.ModifiedBy != null && e.ModifiedBy > 0) { found.ModifiedBy = e.ModifiedBy; } if (!string.IsNullOrWhiteSpace(e.ModifiedDate.ToString())) { found.ModifiedDate = e.ModifiedDate; } // Get Latest Salary // If Latest salary is equal to parameter wali salary then then you dont want to change anything // other wise add new entry to salary table db.SaveChanges(); } }
public void UpdateUserSubAccount(long UserId, string DTaccount, string DFaccount, List <string> TAaccount, List <string> FAaccount, long CurrentUser, long CompanyId) { using (OriginatorEntities db = new OriginatorEntities()) { long GetDefaultToAccount = (from data in db.tblSubAccounts where data.AccountNumber == DTaccount select data.Id).FirstOrDefault(); long GetDefaultFromAccount = (from data in db.tblSubAccounts where data.AccountNumber == DFaccount select data.Id).FirstOrDefault(); List <long> IdsOfToAssociatedAccounts = new List <long>(); List <long> IdsOfFromAssociatedAccounts = new List <long>(); foreach (var item in TAaccount) { long Id = (from data in db.tblSubAccounts where data.AccountNumber == item select data.Id).FirstOrDefault(); IdsOfToAssociatedAccounts.Add(Id); } foreach (var a in FAaccount) { long Id = (from data in db.tblSubAccounts where data.AccountNumber == a select data.Id).FirstOrDefault(); IdsOfFromAssociatedAccounts.Add(Id); } List <long> NewIdsOfToAssociated = IdsOfToAssociatedAccounts.Distinct().ToList(); List <long> NewIdsOfFromAssociated = IdsOfFromAssociatedAccounts.Distinct().ToList(); string FinalToAssociatedAccounts = string.Join(",", NewIdsOfToAssociated.Select(n => n.ToString()).ToArray()); string FinalFromAssociatedAccounts = string.Join(",", NewIdsOfFromAssociated.Select(n => n.ToString()).ToArray()); string ToAssociatedId = ',' + FinalToAssociatedAccounts + ','; string FromAssociatedId = ',' + FinalFromAssociatedAccounts + ','; tblUserSubAccount found = (from data in db.tblUserSubAccounts where data.UserId == UserId && data.CompanyId == CompanyId select data).FirstOrDefault(); if (found != null) { if (!string.IsNullOrWhiteSpace(GetDefaultToAccount.ToString())) { found.DefaultToId = GetDefaultToAccount; } if (!string.IsNullOrWhiteSpace(GetDefaultFromAccount.ToString())) { found.DefaultFromId = GetDefaultFromAccount; } if (!string.IsNullOrWhiteSpace(ToAssociatedId)) { found.ToAssociatedId = ToAssociatedId; } if (!string.IsNullOrWhiteSpace(FromAssociatedId)) { found.FromAssociatedId = FromAssociatedId; } if (CompanyId > 0) { found.CompanyId = CompanyId; } if (CurrentUser > 0) { found.ModifiedBy = CurrentUser; } found.ModifiedDate = DateTime.Now; } else { tblUserSubAccount table = new tblUserSubAccount { UserId = UserId, DefaultToId = GetDefaultToAccount, DefaultFromId = GetDefaultFromAccount, ToAssociatedId = ToAssociatedId, FromAssociatedId = FromAssociatedId, CreatedBy = CurrentUser, CreatedDate = DateTime.Now, CompanyId = CompanyId }; db.tblUserSubAccounts.Add(table); } db.SaveChanges(); } }
public void UpdateAttandance() { using (OriginatorEntities db = new OriginatorEntities()) { } }