示例#1
0
        public static SA_HomeHeader GetHeaderData()
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = _context1.SA_HomeHeader.OrderByDescending(w => w.Id).FirstOrDefault();

            return(cat);
        }
示例#2
0
        public ActionResult CustUpdateProfile()
        {
            int id = int.Parse(Session["LoginUser"].ToString());
            ChemAnalystContext   _context = new ChemAnalystContext();
            CustomerDataStore    Obj      = new CustomerDataStore();
            SA_Customer          obj      = Obj.GetCustomerByid(id);
            SA_CustomerViewModel Objuser  = new SA_CustomerViewModel();

            Objuser.id           = obj.id;
            Objuser.Fname        = obj.Fname;
            Objuser.Lname        = obj.Lname;
            Objuser.Phone        = obj.Phone;
            Objuser.Role         = obj.Role;
            Objuser.Email        = obj.Email;
            Objuser.Gender       = obj.Gender;
            Objuser.UserPassword = obj.UserPassword;
            Objuser.ProfileImage = obj.ProfileImage;

            var customerData = (from User in _context.SA_Role
                                //  select  { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password});
                                select new SelectListItem {
                Text = User.Role, Value = User.Role
            }).ToList();

            Objuser.UserRoleList = customerData;
            return(View("cust-update-profile", Objuser));
        }
        public ActionResult EditUser(int id)
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            UserDataStore      Obj      = new UserDataStore();
            SA_User            obj      = Obj.GetUserByid(id);
            SA_UserViewModel   Objuser  = new SA_UserViewModel();

            Objuser.id           = obj.id;
            Objuser.Fname        = obj.Fname;
            Objuser.Lname        = obj.Lname;
            Objuser.Phone        = obj.Phone;
            Objuser.ProfileImage = obj.ProfileImage;
            Objuser.Role         = obj.Role;
            Objuser.Email        = obj.Email;
            Objuser.UserPassword = obj.UserPassword;
            Objuser.Gender       = obj.Gender;
            var customerData = (from User in _context.SA_Role
                                //  select  { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password});
                                select new SelectListItem {
                Text = User.Role, Value = User.Role
            }).ToList();

            Objuser.UserRoleList = customerData;
            return(View("add-user", Objuser));
        }
        // GET: CompanyProfRecord/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ChemAnalystContext _context = new ChemAnalystContext();
            var companyProfileRecord    = _context.CompanyProfRecords.SingleOrDefault(c => c.Id == id);

            if (companyProfileRecord == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var viewModel = new CompanyProfRecordViewModel()
            {
                FinancialYearId = companyProfileRecord.FinancialYearId,
                SA_CompanyId    = companyProfileRecord.SA_CompanyId,
                Revenues        = companyProfileRecord.Revenues,
                Growth          = companyProfileRecord.Growth,
                FinancialYear   = _context.FinancialYears.ToList(),
                SA_Company      = _context.SA_Company.ToList()
            };

            return(View(viewModel));
        }
        // GET: CompanyProduct/AllCompanyProducts
        public ActionResult AllCompanyProducts()
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            var companyProduct          = _context.SA_Product;

            return(View(companyProduct));
        }
示例#6
0
        // GET: Customer/ManageCustomerAndProduct/5
        public ActionResult CustomerAndProduct(int?id)
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var        customerAndProducRelation = _context.CustomerAndProducRelation.Where(c => c.Lead_MasterId == id);
            List <int> i = new List <int>();

            foreach (var item in customerAndProducRelation)
            {
                i.Add(item.SA_ProductId);
            }

            List <SA_Product> cp = new List <SA_Product>();

            foreach (var item in i)
            {
                var cpdb = _context.SA_Product.SingleOrDefault(c => c.id == item);
                cp.Add(cpdb);
            }

            return(View(cp));
        }
示例#7
0
        public ActionResult SaveCompanyAndProductRelation(CompanyProfAndCompanyProductRelationFormViewModel viewModel)
        {
            //if (!ModelState.IsValid)
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            ChemAnalystContext _context = new ChemAnalystContext();

            foreach (var item in viewModel.CompanyProduct)
            {
                if (item.IsSelected)
                {
                    var checkForSameCompany = _context.CompanyAndProductRelations.Where(w => w.SA_CompanyId == viewModel.CompanyProfId && w.SA_ProductId == item.id).FirstOrDefault();
                    if (checkForSameCompany != null)
                    {
                        TempData["Message"] = "This compnay already exist with same product.";
                    }
                    else
                    {
                        CompanyAndProductRelation companyAndProductRelation = new CompanyAndProductRelation();
                        companyAndProductRelation.SA_CompanyId = viewModel.CompanyProfId;
                        companyAndProductRelation.SA_ProductId = item.id;
                        _context.CompanyAndProductRelations.Add(companyAndProductRelation);
                    }
                }
            }
            _context.SaveChanges();
            //TEMP REDIRECT.
            return(RedirectToAction("AllComAndProductRelationRecords"));
        }
示例#8
0
        public static string GetCategory(int cat)
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            var category = _context.SA_Category.Where(w => w.id == cat).FirstOrDefault() != null?_context.SA_Category.Where(w => w.id == cat).FirstOrDefault().CategoryName : "";

            return(category);
        }
        public ActionResult SaveCompanyProduct(SA_Product model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ChemAnalystContext _context = new ChemAnalystContext();
            var companyProductInDb      = _context.SA_Product.SingleOrDefault(p => p.id == model.id);

            if (companyProductInDb == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            companyProductInDb.ProductName        = model.ProductName;
            companyProductInDb.ProductDiscription = model.ProductDiscription;
            companyProductInDb.Meta            = model.Meta;
            companyProductInDb.MetaDiscription = model.MetaDiscription;
            companyProductInDb.status          = model.status;
            companyProductInDb.CreatedTime     = model.CreatedTime;
            companyProductInDb.ProductImg      = model.ProductImg;
            companyProductInDb.Category        = model.Category;

            _context.SaveChanges();

            return(RedirectToAction("AllCompanyProducts"));
        }
示例#10
0
        // GET: CustomerAndProduct
        public ActionResult Index()
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            var customers = _context.Lead_Master;

            return(View(customers));
        }
        public ActionResult EditCountry(int id)
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            SA_Country obj = _context.SA_Country.Where(w => w.id == id).FirstOrDefault();

            return(View("add-country", obj));
        }
        // GET: CompanyProfRecord/AllCompanyProfileRecords
        public ActionResult AllCompanyProfileRecords()
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            //var companyProfilerRcord = _context.CompanyProfRecordNew.Include(p => p.FinancialYear).Include(p => p.SA_Company);
            var companyProfilerRcord = _context.CompanyProfRecordNew.Include(p => p.SA_Company);

            return(View(companyProfilerRcord));
        }
        public ActionResult EditState(int id)
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            SA_States obj = _context.SA_States.Where(w => w.Id == id).FirstOrDefault();

            return(View("add-state", obj));
        }
示例#14
0
        //GET: CompanyProf/AllCompanyProf
        public ActionResult AllCompanyProf()
        {
            //which layout ?
            ChemAnalystContext _context = new ChemAnalystContext();
            var companyProf             = _context.SA_Company.OrderBy(c => c.Name);

            return(View(companyProf));
        }
示例#15
0
        public static IEnumerable <SelectListItem> GetProduct()
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = (from coun in _context1.SA_Product where coun.status == 1 select new SelectListItem {
                Text = coun.ProductName, Value = coun.id.ToString()
            }).AsEnumerable();

            return(cat);
        }
示例#16
0
        public static IEnumerable <SelectListItem> GetState()
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = (from coun in _context1.SA_States select new SelectListItem {
                Text = coun.State, Value = coun.Id.ToString()
            }).AsEnumerable();

            return(cat);
        }
示例#17
0
        public static IEnumerable <SelectListItem> GetUniqueYears()
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = (from coun in _context1.SA_MarketbyComp select new SelectListItem {
                Text = coun.year, Value = coun.year.ToString()
            }).OrderBy(w => w.Value).Distinct().AsEnumerable();

            return(cat);
        }
示例#18
0
        public static IEnumerable <SelectListItem> GetAdvisory()
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = (from coun in _context1.SA_Advisory select new SelectListItem {
                Text = coun.AdvisoryName, Value = coun.id.ToString()
            }).AsEnumerable();

            return(cat);
        }
        public JsonResult GetState(int Country)
        {
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = (from coun in _context1.SA_States where coun.CountryId == Country select new SelectListItem {
                Text = coun.State, Value = coun.Id.ToString()
            }).OrderBy(w => w.Value).Distinct().AsEnumerable();

            return(Json(cat));
        }
示例#20
0
        public List <string> GetCustProductList(int custId)
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            List <CustProduct> product  = new List <CustProduct>();

            product = _context.CustProduct.Where(x => x.CustId == custId).ToList();
            List <string> lst = product.Select(e => e.ProdId.ToString()).ToList();

            return(lst);
        }
示例#21
0
        // GET: CompanyAndProductRelation/AllComAndProductRelationRecords
        public ActionResult AllComAndProductRelationRecords()
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            var companyAndProductRelations = _context
                                             .CompanyAndProductRelations
                                             .Include(d => d.SA_Company)
                                             .Include(d => d.SA_Product)
                                             .OrderByDescending(d => d.Id);

            return(View(companyAndProductRelations));
        }
示例#22
0
        // GET: CompanyAndProductRelation
        public ActionResult Index()
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            var viewModel = new CompanyProfAndCompanyProductRelationFormViewModel()
            {
                CompanyProf    = _context.SA_Company.ToList(),
                CompanyProduct = _context.SA_Product.ToList()
            };

            return(View(viewModel));
        }
        // GET: CompanyProfRecord
        public ActionResult Index()
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            var viewModel = new CompanyProfRecordViewModel()
            {
                FinancialYear = _context.FinancialYears.ToList(),
                SA_Company    = _context.SA_Company.ToList()
            };

            return(View(viewModel));
        }
示例#24
0
        // GET: Customer/CompanyAndProductRelation/5
        //SEND SA_Product Id AS PARAMETER
        public ActionResult CompanyAndProductRelation(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ChemAnalystContext _context = new ChemAnalystContext();

            var companyProf = _context.CompanyAndProductRelations.Include(c => c.SA_Company).Where(c => c.SA_ProductId == id).OrderBy(c => c.SA_CompanyId);

            return(View(companyProf));
        }
        public ActionResult AddUser()
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            var customerData            = (from User in _context.SA_Role
                                           //  select  { Fname = User.Fname+" "+User.Lname , Phone = User.Phone, Role=User.Role,Email=User.Email,UserPassword=User.Password});
                                           select new SelectListItem {
                Text = User.Role, Value = User.Role
            }).Where(w => w.Value != "Admin").ToList();
            SA_UserViewModel obj = new SA_UserViewModel();

            obj.UserRoleList = customerData;
            return(View("add-user", obj));
        }
示例#26
0
        public ActionResult SaveCompanyProf(SA_Company model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ChemAnalystContext _context = new ChemAnalystContext();

            var companyProfInDb = _context.SA_Company.SingleOrDefault(c => c.id == model.id);

            if (companyProfInDb == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/images"), fileName);
                    file.SaveAs(path);
                    companyProfInDb.Logo = fileName;
                }
            }

            companyProfInDb.Name        = model.Name;
            companyProfInDb.Description = model.Description;
            //companyProfInDb.Logo = model.Logo;
            companyProfInDb.RegDate         = Convert.ToDateTime(model.RegDate);
            companyProfInDb.CIN             = model.CIN;
            companyProfInDb.Category        = model.Category;
            companyProfInDb.Address         = model.Address;
            companyProfInDb.NOE             = model.NOE;
            companyProfInDb.CEO             = model.CEO;
            companyProfInDb.Meta            = model.Meta;
            companyProfInDb.MetaDescription = model.MetaDescription;
            companyProfInDb.website         = model.website;
            companyProfInDb.phoneNo         = model.phoneNo;
            companyProfInDb.fax             = model.fax;
            companyProfInDb.EmailId         = model.EmailId;
            //companyProfInDb.CreatedTime = model.CreatedTime;

            _context.SaveChanges();

            return(RedirectToAction("AllCompanyProf"));
        }
示例#27
0
        //GET: CompanyAndProductRelation/Delete
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChemAnalystContext _context = new ChemAnalystContext();
            var companyProductInDb      = _context.CompanyAndProductRelations.Include(d => d.SA_Company).Include(d => d.SA_Product).SingleOrDefault(d => d.Id == id);

            if (companyProductInDb == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            return(View(companyProductInDb));
        }
示例#28
0
        public static string GetModuleName(int PageId)
        {
            string             PageName  = "";
            ChemAnalystContext _context1 = new ChemAnalystContext();
            var cat = _context1.SA_PageList.Where(w => w.id == PageId).FirstOrDefault();

            if (cat != null)
            {
                PageName = cat.PageDiscription;
            }
            else
            {
                PageName = "N/A";
            }
            return(PageName);
        }
示例#29
0
        public static string GetProductName(int ProductId)
        {
            string             ProductName = "";
            ChemAnalystContext _context1   = new ChemAnalystContext();
            var cat = _context1.SA_Product.Where(w => w.id == ProductId).FirstOrDefault();

            if (cat != null)
            {
                ProductName = cat.ProductName;
            }
            else
            {
                ProductName = "N/A";
            }
            return(ProductName);
        }
示例#30
0
        public ActionResult Delete(int?id)
        {
            ChemAnalystContext _context = new ChemAnalystContext();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SA_Company state = _context.SA_Company.Where(c => c.id == id).FirstOrDefault();

            _context.Entry(state).State = EntityState.Deleted;
            int x = _context.SaveChanges();


            return(RedirectToAction("AllCompanyProf"));
        }