public ActionResult AddEditOPM(int OPM_ID = 0)
        {
            BuyerReferenceManager objBuyerReferenceManager = new BuyerReferenceManager(new DataContext());
            ParticipiantManager   objParticipiantManager   = new ParticipiantManager(new DataContext());
            BuyerNameManager      objBuyerNameManager      = new BuyerNameManager(new DataContext());
            OPMManager            context  = new OPMManager(new DataContext());
            OPM_Model             objModel = new OPM_Model();

            if (OPM_ID != 0)
            {
                objModel.Table = context.GetOPMById(OPM_ID);
                if (objModel.Table.Participants != null)
                {
                    objModel.Participant = objModel.Table.Participants.Split(',');
                }
                if (objModel.Table.BuyerReferenceName != null)
                {
                    objModel.BuyerReferenceName = objModel.Table.BuyerReferenceName.Split(',');
                }
            }
            else
            {
                objModel.Table              = new OPM();
                objModel.Participant        = null;
                objModel.BuyerReferenceName = null;
            }
            objModel.BuyerReferenceNameList = Extens.ToSelectList(objBuyerReferenceManager.GetDtBuyerReferenceName(), "BuyerReferenceName", "BuyerReferenceName");
            objModel.BuyerStoryNameList     = Extens.ToSelectList(objBuyerReferenceManager.GetDtBuyerStoryName(), "StoryName", "StoryName");
            objModel.BuyerNameList          = Extens.ToSelectList(objBuyerNameManager.GetDtBuyerName(), "Buyername", "Buyername");
            objModel.ParticipantList        = Extens.ToSelectList(objParticipiantManager.GetDtParticipiantName(), "Name", "Name");

            return(PartialView("OPMCRUD", objModel));
        }
        // GET: OrderProcessMeeting
        public ActionResult Index()
        {
            OPM_Model objModel = new OPM_Model();

            objModel.page           = 1;
            objModel.StaticPageSize = 5;
            BindOPMGrid(objModel, Convert.ToInt32(objModel.page), objModel.StaticPageSize);
            return(View(objModel));
        }
        public ActionResult DeleteOPM(string OPM_ID, OPM_Model objModel, int page = 1, int pageSize = 5)
        {
            OPMManager context = new OPMManager(new DataContext());

            if (!string.IsNullOrEmpty(OPM_ID))
            {
                context.DeleteOPM(Convert.ToInt32(OPM_ID));
            }

            if (objModel.StaticPageSize != 0)
            {
                pageSize = objModel.StaticPageSize;
            }
            objModel.StaticPageSize = pageSize;

            BindOPMGrid(objModel, page, pageSize);
            return(PartialView("OPMList", objModel));
        }
        public void BindOPMGrid(OPM_Model objModel, int page, int pageSize)
        {
            BuyerReferenceManager objBuyerReferenceManager = new BuyerReferenceManager(new DataContext());
            StringBuilder         query = new StringBuilder();
            var colName = common.GetColumns(CommonFunction.module.OPM.ToString());

            query = common.GetSqlTableQuery(CommonFunction.module.OPM.ToString());
            if (objModel != null)
            {
                objModel.StaticPageSize = pageSize;
            }

            objModel.BuyerReferenceNameList = Extens.ToSelectList(objBuyerReferenceManager.GetDtBuyerReferenceName(), "BuyerReferenceName", "BuyerReferenceName");
            //objModel.BuyerStoryNameList = Extens.ToSelectList(objBuyerReferenceManager.GetDtBuyerReferenceName(), "StoryName", "StoryName");
            OPMManager context = new OPMManager(new DataContext());

            objModel.sortOrder = "desc";
            objModel.fieldName = "OPM_ID";
            context.setModel(query, objModel, colName, "OPM_ID", page, pageSize);
        }
        public ActionResult SaveOPM(OPM_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));
            }

            //Save
            OPMManager context = new OPMManager(new DataContext());

            if (objModel.Participant != null)
            {
                objModel.Table.Participants = string.Join(",", objModel.Participant);
            }
            if (objModel.BuyerReferenceName != null)
            {
                objModel.Table.BuyerReferenceName = string.Join(",", objModel.BuyerReferenceName);
            }
            var msg = context.SaveOPM(objModel.Table);

            if (msg.Contains("exists"))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "exists"));
            }
            else
            {
                if (objModel.StaticPageSize != 0)
                {
                    pageSize = objModel.StaticPageSize;
                }
                objModel.StaticPageSize = pageSize;

                BindOPMGrid(objModel, page, pageSize);
                return(PartialView("OPMList", objModel));
            }
        }
 public ActionResult OPMFilterSearch(OPM_Model objModel, int page = 1, int pageSize = 5)
 {
     BindOPMGrid(objModel, page, pageSize);
     return(PartialView("OPMList", objModel));
 }