public void GetExcel(DrugBrandViewModel model)
        {
            List <DrugBrand> drugBrands = DrugBrandManager.Getdrugs();

            model.DrugBrands = drugBrands;

            const string fileName    = "DrugBrands";
            var          boundFields = new List <BoundField>
            {
                new BoundField()
                {
                    HeaderText = @"Brand Name", DataField = "Name"
                },
                new BoundField()
                {
                    HeaderText = @"Description", DataField = "Preparation"
                },
                new BoundField()
                {
                    HeaderText = @"Generic Name", DataField = "DrugGeneric.Name"
                }
            };

            ReportConverter.CustomGridView(boundFields, model.DrugBrands, fileName);
        }
        public ActionResult Print(DrugBrandViewModel model)
        {
            var totalrecords = 0;
            //List<DrugBrand> drugBrands = DrugBrandManager.GetdrugBySearchKey(model.SeachByBrandName);

            List <DrugBrand> drugBrands = DrugBrandManager.Getdrugs();

            //List<DrugBrand> drugBrands = DrugBrandManager.GetAllDrugBrand(out totalrecords, model);
            model.DrugBrands = drugBrands;
            return(View("_DrugBrandtPdfReport", model));
        }
        public JsonResult Delete(DrugBrandViewModel model)
        {
            int deleteIndex = 0;

            try
            {
                deleteIndex = DrugBrandManager.DeleteDrugBrand(model.BrandId);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            return(deleteIndex > 0 ? Reload() : ErroResult("Failed to delete"));
        }
        public JsonResult Save(DrugBrandViewModel model)
        {
            int saveIndex = 0;

            var _drugBrand = new DrugBrand();

            _drugBrand.BrandId     = model.BrandId;
            _drugBrand.Name        = model.Name;
            _drugBrand.Preparation = model.Preparation;
            _drugBrand.GenericId   = model.GenericId;
            saveIndex = model.BrandId == 0 ? DrugBrandManager.SaveDrugBrand(_drugBrand) : DrugBrandManager.EditDrugBrand(_drugBrand);
            //return saveIndex > 0 ? Reload(saveIndex) : ErroeMessageResult();
            return(Reload(saveIndex));
        }
        public ActionResult Edit(DrugBrandViewModel model)
        {
            ModelState.Clear();
            model.DrugGenerics = DrugGenericManager.GettAllGenericDrug();
            if (model.BrandId > 0)
            {
                var _drugBrand = DrugBrandManager.GetBrandDrugById(model.BrandId) ?? new DrugBrand();;

                model.BrandId     = _drugBrand.BrandId;
                model.Name        = _drugBrand.Name;
                model.Preparation = _drugBrand.Preparation;
                model.GenericId   = _drugBrand.GenericId;
            }
            return(View(model));
        }
        public ActionResult Index(DrugBrandViewModel model)
        {
            ModelState.Clear();
            model.Name = model.SeachByBrandName;
            //if (!model.IsSearch)
            //{
            //    model.IsSearch = true;
            //    return View(model);
            //}

            var totalrecords = 0;



            model.DrugGenerics = DrugGenericManager.GettAllGenericDrug();

            model.DrugBrands   = DrugBrandManager.GetAllDrugBrand(out totalrecords, model);
            model.TotalRecords = totalrecords;

            return(View(model));
        }
        //private readonly int _pageSize = AppConfig.PageSize;

        public ActionResult Index(DrugBrandViewModel model)
        {
            ModelState.Clear();


            //var startPage = 0;

            //if (model.Page.HasValue && model.Page.Value > 0)
            //{
            //    startPage = model.Page.Value - 1;
            //}

            var totalrecords = 0;

            model.Name = model.SeachByBrandName;

            //model.DrugGenerics = DrugGenericManager.GettAllGenericDrug();

            //var   drugGenericsList = DrugGenericManager.GettAllGenericDrug();

            //var drugGenericsList = DrugGenericManager.GetAllGenericDrug((startPage, _pageSize, out totalrecords , model);

            //model.DrugGenerics = drugGenericsList.Where(x=>x.GenericId==model.GenericId|| model.GenericId==0).ToList();

            //ViewBag.SearchByGenericDSrug=new SelectList(drugGenericsList,"GenericId","Name");
            //var genericId = model.SearchByGenericDSrug;
            //var genericId = model.SearchByGenericDSrug;

            // var drugBrandlist = DrugBrandManager.GetAllDrugBrandByGeneric(genericId);

            // ViewBag.SearchByDrugBrand=new SelectList(drugBrandlist,"BrandId","Name",model.SearchByDrugBrand);
            model.DrugGenerics = DrugGenericManager.GettAllGenericDrug();

            //model.DrugBrands = DrugBrandManager.GetAllDrugBrand(startPage, _pageSize, out totalrecords, model);
            model.DrugBrands   = DrugBrandManager.GetAllDrugBrand(out totalrecords, model);
            model.TotalRecords = totalrecords;

            return(View(model));
        }