public ActionResult SaveProductName(ProductName_Model objModel, int page = 1, int pageSize = 10)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join("|", ModelState.Values.SelectMany(e => e.Errors).Select(em => em.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }

            //Save
            ProductNameManager context = new ProductNameManager(new DataContext());
            var msg = context.SaveProductName(objModel.Table);

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

                BindProductNameGrid(objModel, page, pageSize);
                return(PartialView("ProductNameList", objModel));
            }
        }
        public ActionResult ProductNameGrid()
        {
            ProductName_Model objModel = new ProductName_Model();

            objModel.page           = 1;
            objModel.StaticPageSize = 10;
            BindProductNameGrid(objModel, Convert.ToInt32(objModel.page), objModel.StaticPageSize);
            return(View(objModel));
        }
        public ActionResult AddEditProductname(int ID = 0)
        {
            ProductNameManager context  = new ProductNameManager(new DataContext());
            ProductName_Model  objModel = new ProductName_Model();

            if (ID != 0)
            {
                objModel.Table = context.GetProductNameById(ID);
            }
            else
            {
                objModel.Table = new Productname();
            }
            return(PartialView("ProductNameCRUD", objModel));
        }
        public void BindProductNameGrid(ProductName_Model objModel, int page, int pageSize)
        {
            StringBuilder query   = new StringBuilder();
            var           colName = common.GetColumns(CommonFunction.module.ProductName.ToString());

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

            ProductNameManager context = new ProductNameManager(new DataContext());

            context.setModel(query, objModel, colName, "Productname", page, pageSize);
        }
        public ActionResult DeleteProductName(string ID, ProductName_Model objModel, int page = 1, int pageSize = 10)
        {
            ProductNameManager context = new ProductNameManager(new DataContext());

            if (!string.IsNullOrEmpty(ID))
            {
                int pId = Convert.ToInt32(ID);
                List <Productname> lst = context.GetAll(c => c.PrdID == pId).ToList();
                context.DeleteProductName(lst);
            }

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

            BindProductNameGrid(objModel, page, pageSize);
            return(PartialView("ProductNameList", objModel));
        }
 public ActionResult ProductNameFilterSearch(ProductName_Model objModel, int page = 1, int pageSize = 10)
 {
     BindProductNameGrid(objModel, page, pageSize);
     return(PartialView("ProductNameList", objModel));
 }