public void BindQAInspectionGrid(QAInspection_Model objModel, int page, int pageSize)
        {
            QAInspectionManager context = new QAInspectionManager(new DataContext());
            //objModel.QAInspectionList = context.GetQAInspectionList(objModel.OPM_ID);
            var QAInspectionList = context.GetQAInspectionList(objModel.OPM_ID);

            objModel.QAInspectionList = QAInspectionList.ToPagedList(page, pageSize).ToList();
            objModel.pageList         = new PagedList <QAInspection>(QAInspectionList, page, pageSize);
        }
        public ActionResult QAInspectionFilterSearch(int OPM_ID, int page = 1, int pageSize = 5)
        {
            QAInspection_Model objModel = new QAInspection_Model();

            objModel.OPM_ID         = OPM_ID;
            objModel.StaticPageSize = pageSize;
            BindQAInspectionGrid(objModel, page, pageSize);
            return(PartialView("QAInspectionList", objModel));
        }
        public ActionResult DeleteQAInspection(string QAIns_ID, int OPM_ID, int page = 1, int pageSize = 5)
        {
            QAInspectionManager context = new QAInspectionManager(new DataContext());

            if (!string.IsNullOrEmpty(QAIns_ID))
            {
                context.DeleteQAInspection(Convert.ToInt32(QAIns_ID));
            }
            QAInspection_Model objModel = new QAInspection_Model();

            objModel.OPM_ID = OPM_ID;
            BindQAInspectionGrid(objModel, page, pageSize);
            return(PartialView("QAInspectionList", objModel));
        }
        public ActionResult AddEditQAInspection(int OPM_ID, int QAIns_ID = 0)
        {
            TypeOfInspectionManager objTypeOfInspection = new TypeOfInspectionManager(new DataContext());
            QAInspectionManager     context             = new QAInspectionManager(new DataContext());
            QAInspection_Model      objModel            = new QAInspection_Model();

            if (QAIns_ID != 0)
            {
                objModel.Table = context.GetQAInspectionById(QAIns_ID);
            }
            else
            {
                objModel.Table        = new QAInspection();
                objModel.Table.OPM_ID = OPM_ID;
            }
            objModel.InspectionTypeList = Extens.ToSelectList(objTypeOfInspection.GetTypeOfInspection(), "InspectionType", "InspectionType");
            return(PartialView("QAInspectionCRUD", objModel));
        }
        public ActionResult SaveQAInspection(QAInspection_Model objModel, int page = 1, int pageSize = 5)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join("|", ModelState.Values.SelectMany(e => e.Errors).Select(em => em.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }
            int OPM_ID = objModel.Table.OPM_ID != null ? objModel.Table.OPM_ID.Value : 0;
            //Save
            QAInspectionManager context = new QAInspectionManager(new DataContext());
            var msg = context.SaveQAInspection(objModel.Table);

            if (msg.Contains("exists"))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "exists"));
            }
            else
            {
                objModel.OPM_ID = OPM_ID;
                BindQAInspectionGrid(objModel, page, pageSize);
                string vwString = HtmlHelpers.RenderViewToString(this.ControllerContext, "QAInspectionList", objModel);
                return(Json(new { OPM_ID = OPM_ID, viewData = vwString }));
            }
        }