示例#1
0
        public ActionResult GetListCertificationGrid(string certificationName)
        {
            #region JQGrid Params
            string sortColumn = (Request.Params[GridConstants.SORT_COLUMN]).ToString();
            string sortOrder = (Request.Params[GridConstants.SORT_ORDER]).ToString();
            int pageIndex = Convert.ToInt32(Request.Params[GridConstants.PAGE_INDEX]);
            int rowCount = Convert.ToInt32(Request.Params[GridConstants.ROW_COUNT]);
            #endregion
            SetSessionFilter(certificationName, sortColumn, sortOrder, pageIndex, rowCount);
            string name = string.Empty;
            if (certificationName != Constants.TRAINING_CERTIFICATION_MASTER_SEARCH_NAME && !string.IsNullOrEmpty(certificationName))
            {
                name = certificationName;
            }
            List<sp_GetTrainingCertificationResult> trainingCerList = new TrainingCertificationDao().GetTrainingCertificationList(name).Where(p => p.IsActive == true).ToList();

            int totalRecords = trainingCerList.Count();
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rowCount);
            int currentPage = CommonFunc.SetJqGridPageIndex(totalRecords, pageIndex, rowCount);

            //List<sp_GetTrainingCertificationResult> finalList = trainingCerDao.Sort(trainingCerList, sortColumn, sortOrder).Skip((currentPage - 1) * rowCount)
            //                       .Take(rowCount).ToList<sp_GetTrainingCertificationResult>();
            var finalList = trainingCerList.Skip((currentPage - 1) * rowCount).Take(rowCount);
            var jsonData = new
            {
                total = totalPages,
                page = currentPage,
                records = totalRecords,
                rows = (
                    from m in finalList
                    select new
                    {
                        i = m.ID,
                        cell = new string[] {
                             HttpUtility.HtmlEncode(m.ID.ToString()),
                             HttpUtility.HtmlEncode(m.ID.ToString()),
                             CommonFunc.Link(HttpUtility.HtmlEncode(m.Name.ToString()), "javascript:ChooseCertificationID(\"" + m.ID + "\", \"" + m.Name + "\");", HttpUtility.HtmlEncode(m.Name.ToString()), false),
                             HttpUtility.HtmlEncode(m.Description)
                         }
                    }
                ).ToArray()
            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
        public Message Insert(Employee_Certification objUI)
        {
            TrainingCertificationDao trainDao = new TrainingCertificationDao();
            Message msg = null;
            try
            {
                Employee_Certification empCer = GetEmployeeAssignedCertification(objUI.EmployeeId, objUI.CertificationId);
                if (objUI != null && empCer == null)
                {

                    dbContext.Employee_Certifications.InsertOnSubmit(objUI);
                    dbContext.SubmitChanges();
                    // Show success message
                    objUI.Training_CertificationMaster = trainDao.GetById(objUI.CertificationId.ToString());
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Certification '" + objUI.Training_CertificationMaster.Name + "'", "added");
                }
                else
                {
                    objUI.Training_CertificationMaster = trainDao.GetById(objUI.CertificationId.ToString());
                    msg = new Message(MessageConstants.E0020, MessageType.Error, "Certification '" + objUI.Training_CertificationMaster.Name + "'", "this employee");
                }
            }
            catch (Exception ex)
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
                throw ex;
            }
            return msg;
        }