public void loadDefault(string claimId) { Session["employeeID"] = ""; ViewBag.typeClaim = ccm.typeClaimEmployee(string.Empty); ViewBag.employeeList = db.employees.AsNoTracking().ToList(); string sql = string.Empty; #region oldProcess // sql = "SELECT "; // sql += "a.employeeID, a.employeeNIK, a.employeeName, "; // sql += "d.deptID, d.deptName "; // sql += "FROM [dbo].[Employees] a "; // sql += "INNER JOIN "; // sql += "(SELECT a.employeeID, b.positionId "; // sql += "FROM [dbo].[EmployeeResigns] a "; // sql += "INNER JOIN [dbo].[EmployeePositions] b ON (b.employeeID = a.employeeID AND b.positionDate > a.resignDate) "; // sql += "UNION "; // sql += "SELECT employeeID, "; // sql += "(SELECT positionId FROM [dbo].[EmployeePositions] WHERE employeeID = a.employeeID)positionId "; // sql += "FROM [dbo].[Employees] a "; // sql += "WHERE a.employeeID NOT IN (SELECT employeeID "; // sql += " FROM [dbo].[EmployeeResigns]) "; // sql += ") b ON b.employeeID = a.employeeID "; // sql += "LEFT JOIN [dbo].[EmployeePositions] c ON c.employeeID = b.employeeID AND c.positionId = b.positionId "; // sql += "LEFT JOIN [dbo].[Departments] d ON d.deptID = c.deptID "; #endregion #region newProcess sql += "SELECT * "; sql += "FROM [dbo].[v_employee] b "; sql += "LEFT JOIN [dbo].[EmployeePositions] c ON c.employeeID = b.employeeID AND c.positionId = b.positionId "; sql += "LEFT JOIN [dbo].[Departments] d ON d.deptID = c.deptID "; sql += "WHERE b.resignDate IS NULL "; #endregion DataTable dtEmployee = cd.executeReader(sql); var model = new employeeLoan(); foreach(DataRow dr in dtEmployee.Rows) { var editor = new employeeLoan.employeePOPUp() { employeeID = int.Parse(dr["employeeID"].ToString()), employeeNIK = dr["employeeNIK"].ToString(), employeeName = dr["employeeName"].ToString(), deptID = int.Parse(dr["deptID"].ToString()), deptName = dr["deptName"].ToString() }; model.popUpEmployee.Add(editor); } ViewBag.EmpPopUp = model.popUpEmployee.ToList(); if (claimId != string.Empty) { var id = int.Parse(claimId); var dataSaved = db.employeeClaimMedicals.AsNoTracking().Where(x => x.klaimID == id) .Join(db.employees, q => q.employeeID, r => r.employeeID, (q, r) => new { q, r }) .Join(db.employeePositions, s => s.q.employeeID, t => t.employeeID, (s, t) => new { s, t }) .Join(db.departments, u => u.t.deptID, v => v.deptID, (u, v) => new { u, v }) .Select(c => new { c.u.s.r.employeeName, c.u.s.r.employeeNIK, c.u.t.deptID, c.v.deptName, c.u.s.q.proposedBy }).ToList(); ViewBag.empName = dataSaved[0].employeeName; ViewBag.empDeptName = dataSaved[0].deptName; //lvm = Session["sessionUserLogin"] as LoginViewModel.userLogin; //var a = db.departments.Where(x => x.deptID == lvm.deptID).Select(x => new { x.deptName }).ToList(); //ViewBag.Dept = a[0].deptName; var userID = dataSaved[0].proposedBy; var b = db.Users.Where(x => x.userID == userID).Select(x => new { x.userName }).ToList(); ViewBag.UserName = b[0].userName; ViewBag.UserID = userID; } }
public void loadDefaultData(string fixAssetId) { ViewBag.typeCode = "Generated"; ViewBag.codeManual = ""; ViewBag.employeeList = db.employees.AsNoTracking().ToList(); var popUp = db.employees.AsNoTracking() .Join(db.employeePositions, x => x.employeeID, y => y.employeeID, (x, y) => new { x, y }) .Join(db.departments, q => q.y.deptID, r => r.deptID, (q, r) => new { q, r }) .Select(c => new { c.q.x.employeeID, c.q.x.employeeNIK, c.q.x.employeeName, c.q.y.deptID, c.r.deptName }).ToList(); var model = new employeeLoan(); for (int i = 0; i < popUp.Count; i++) { var editor = new employeeLoan.employeePOPUp() { employeeID = popUp[i].employeeID, employeeNIK = popUp[i].employeeNIK, employeeName = popUp[i].employeeName, deptID = popUp[i].deptID, deptName = popUp[i].deptName }; model.popUpEmployee.Add(editor); } ViewBag.EmpPopUp = model.popUpEmployee.ToList(); ViewBag.StatusfixedAsset = ccm.ddlStatusFixedAsset(string.Empty); ViewBag.ddlPeriodDepreciation = ccm.ddlPeriodDepreciation(string.Empty); if (fixAssetId != string.Empty) { var id = int.Parse(fixAssetId); var dataDetailSaved = db.fixedAssetPersons.AsNoTracking().Where(x => x.fixedAssetID == id) .Join(db.employees, c => c.employeeID, d => d.employeeID, (c, d) => new { c, d }) .Join(db.employeePositions, f => f.d.employeeID, g => g.employeeID, (f, g) => new { f, g }) .Join(db.departments, e => e.g.deptID, h => h.deptID, (e, h) => new { e, h }) .Select(z => new { z.e.f.c.startDate, z.e.f.c.endDate, z.e.f.c.employeeID, z.e.f.d.employeeName, z.h.deptName, z.e.f.c.remarks }).ToList(); var headerFix = new fixedAsset(); for (int i = 0; i < dataDetailSaved.Count; i++ ) { var editor = new fixedAsset.detailSavedFixedAssetPerson() { startDate = dataDetailSaved[i].startDate, endDate = dataDetailSaved[i].endDate, employeeID = dataDetailSaved[i].employeeID, employeeName = dataDetailSaved[i].employeeName, deptName = dataDetailSaved[i].deptName, remarks = dataDetailSaved[i].remarks }; headerFix.fixAssetPersonDetail.Add(editor); } ViewBag.dataDetail = headerFix.fixAssetPersonDetail.ToList(); ViewBag.dataDetailMaint = db.fixedAssetMaintenances.AsNoTracking().Where(x => x.fixedAssetID == id).ToList(); var headerSaved = db.fixedAssets.AsNoTracking().Where(x => x.fixedAssetID == id).ToList(); var userID = headerSaved[0].createdUser; var s = db.Users.Where(x => x.userID == userID).Select(x => new { x.userName }).ToList(); if (s.Count > 0) ViewBag.UserName = s[0].userName; else { var modifuserID = headerSaved[0].modifiedUser; var mod = db.Users.Where(x => x.userID == modifuserID).Select(x => new { x.userName }).ToList(); if (mod.Count > 0) ViewBag.UserName = mod[0].userName; else ViewBag.UserName = ""; } ViewBag.UserID = userID; ViewBag.StatusfixedAsset = ccm.ddlStatusFixedAsset(headerSaved[0].fixedAssetStatus); ViewBag.ddlPeriodDepreciation = ccm.ddlPeriodDepreciation(headerSaved[0].depreciationPeriod); } }
public void loadDefault(string pinjamanID) { ViewBag.employeeList = db.employees.AsNoTracking().ToList(); string sql = string.Empty; #region oldProcess //sql = "SELECT "; //sql += "a.employeeID, a.employeeNIK, a.employeeName, "; //sql += "d.deptID, d.deptName "; //sql += "FROM [dbo].[Employees] a "; //sql += "INNER JOIN "; //sql += "(SELECT a.employeeID, b.positionId "; //sql += "FROM [dbo].[EmployeeResigns] a "; //sql += "INNER JOIN [dbo].[EmployeePositions] b ON (b.employeeID = a.employeeID AND b.positionDate > a.resignDate) "; //sql += "UNION "; //sql += "SELECT employeeID, "; //sql += "(SELECT positionId FROM [dbo].[EmployeePositions] WHERE employeeID = a.employeeID)positionId "; //sql += "FROM [dbo].[Employees] a "; //sql += "WHERE a.employeeID NOT IN (SELECT employeeID "; //sql += " FROM [dbo].[EmployeeResigns]) "; //sql += ") b ON b.employeeID = a.employeeID "; //sql += "LEFT JOIN [dbo].[EmployeePositions] c ON c.employeeID = b.employeeID AND c.positionId = b.positionId "; //sql += "LEFT JOIN [dbo].[Departments] d ON d.deptID = c.deptID "; #endregion #region newProcess ////output: ////employeeID, employeeName, employeeNIK, email, npwp, ktp, address, city, bankName, ////rekening, tempatLahir, tanggalLahir, linkFilePhoto, positionDate, positionId, resignDate, gapok sql += "SELECT * "; sql += "FROM [dbo].[v_employee] b "; sql += "LEFT JOIN [dbo].[EmployeePositions] c ON c.employeeID = b.employeeID AND c.positionId = b.positionId "; sql += "LEFT JOIN [dbo].[Departments] d ON d.deptID = c.deptID "; sql += "WHERE b.resignDate IS NULL "; #endregion DataTable dtEmployee = cd.executeReader(sql); var model = new employeeLoan(); foreach (DataRow dr in dtEmployee.Rows) { var editor = new employeeLoan.employeePOPUp() { employeeID = int.Parse(dr["employeeID"].ToString()), employeeNIK = dr["employeeNIK"].ToString(), employeeName = dr["employeeName"].ToString(), deptID = int.Parse(dr["deptID"].ToString()), deptName = dr["deptName"].ToString(), gapok = decimal.Parse(dr["gapok"].ToString()) }; model.popUpEmployee.Add(editor); } ViewBag.EmpPopUp = model.popUpEmployee.ToList(); ViewBag.LoanCategory = cm.ddlLoanCategory(string.Empty); if(pinjamanID != string.Empty) { var id = int.Parse(pinjamanID); var dataSaved = db.employeeLoans.AsNoTracking().Where(x => x.pinjamanID == id) .Join(db.employees, q => q.employeeID, r => r.employeeID, (q, r) => new { q, r }) .Join(db.employeePositions, s => s.q.employeeID, t => t.employeeID, (s, t) => new { s, t }) .Join(db.departments, u => u.t.deptID, v => v.deptID, (u, v) => new { u, v }) .Select(c => new { c.u.s.r.employeeName, c.u.s.r.employeeNIK, c.u.t.deptID, c.v.deptName, c.u.s.q.proposedBy, c.u.s.q.loanCategory, c.u.s.r.gapok }).ToList(); ViewBag.empName = dataSaved[0].employeeName; ViewBag.empDeptName = dataSaved[0].deptName; ViewBag.empGapok = dataSaved[0].gapok; //lvm = Session["sessionUserLogin"] as LoginViewModel.userLogin; //var a = db.departments.Where(x => x.deptID == lvm.deptID).Select(x => new { x.deptName }).ToList(); //ViewBag.Dept = a[0].deptName; var userID = dataSaved[0].proposedBy; var b = db.Users.Where(x => x.userID == userID).Select(x => new { x.userName }).ToList(); ViewBag.UserName = b[0].userName; ViewBag.UserID = userID; ViewBag.LoanCategory = cm.ddlLoanCategory(dataSaved[0].loanCategory); } }