Beispiel #1
0
        public JsonResult GetProductInfo(int ID)
        {
            SourceMastersModel SM1 = new SourceMastersModel();

            var Product = SM1.GetProductById(ID);

            return(Json(Product, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult Home()
        {
            //
            List <int> RoleId = (List <int>)Session["RoleID"];

            int roleid = RoleId[0];

            if (roleid == 1)
            {
                var Query = (from t in db.Menus where t.IsAccountMenu.Value == false && t.RoleID == null orderby t.MenuOrder select t).ToList();
                Session["Menu"]  = Query;
                ViewBag.UserName = SourceMastersModel.GetUserFullName(Convert.ToInt32(Session["UserId"].ToString()), Session["UserType"].ToString());
                return(View());
            }
            else
            {
                //List<Menu> Query2 = new List<Menu>();
                var Query = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.MenuID where t1.RoleID == roleid && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

                var Query1 = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.ParentID where t1.RoleID == roleid && t.ParentID == 0 && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

                var Query2 = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.ParentID where t1.RoleID == roleid && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

                if (Query2 != null)
                {
                    foreach (Menu q in Query1)
                    {
                        var query3 = Query.Where(cc => cc.MenuID == q.MenuID).FirstOrDefault();
                        if (query3 == null)
                        {
                            Query2.Add(q);
                        }
                    }
                }

                if (Query1 != null)
                {
                    foreach (Menu q in Query1)
                    {
                        var query3 = Query.Where(cc => cc.MenuID == q.MenuID).FirstOrDefault();
                        if (query3 == null)
                        {
                            Query.Add(q);
                        }
                    }
                }



                Session["Menu"] = Query;

                ViewBag.UserName = SourceMastersModel.GetUserFullName(Convert.ToInt32(Session["UserId"].ToString()), Session["UserType"].ToString());
                return(View());
            }
        }
Beispiel #3
0
        public JsonResult GetCreditDays(int ID)
        {
            SourceMastersModel SM1 = new SourceMastersModel();
            int?CreditDays         = 0;
            var Product            = SM1.GetCustomerById(ID);

            if (Product.MaxCreditDays != null)
            {
                CreditDays = Product.MaxCreditDays;
            }

            return(Json(CreditDays, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult Home()
        {
            //var Query = (from t in db.Menus where t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();
            var Query = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.MenuID where t1.RoleID == 14 && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

            var Query1 = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.ParentID where t1.RoleID == 14 && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

            foreach (Menu q in Query)
            {
                Query1.Add(q);
            }
            Session["Menu"]  = Query1;
            ViewBag.UserName = SourceMastersModel.GetUserFullName(Convert.ToInt32(Session["UserId"].ToString()), Session["UserType"].ToString());
            return(View());
        }
        public ActionResult Home()
        {
            var Query = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.MenuID  where t1.RoleID == 13 && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

            var Query1 = (from t in db.Menus join t1 in db.MenuAccessLevels on t.MenuID equals t1.ParentID where t1.RoleID == 13 && t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

            foreach (Menu q in Query)
            {
                Query1.Add(q);
            }


            //List<MenuVM> Query = (
            //      from a in db.Menus
            //      from b in db.MenuAccessLevels
            //           .Where(bb => bb.MenuID == a.MenuID)
            //      from c in db.MenuAccessLevels
            //           .Where(cc => cc.ParentID == a.MenuID)
            //      where b.RoleID == 13 && c.RoleID == 13
            //      select new MenuVM  { MenuID = a.MenuID, Title = a.Title, Link = a.Link, ParentID = a.ParentID, Ordering = a.Ordering, SubLevel = a.SubLevel, RoleID = a.RoleID , CreatedBy =a.CreatedBy,  CreatedOn =a.CreatedOn,   ModifiedBy =a.ModifiedBy, ModifiedOn=a.ModifiedOn,
            //    IsActive=a.IsActive,
            //    imgclass =a.imgclass,
            //    PermissionRequired=a.PermissionRequired,
            //    MenuOrder=a.MenuOrder,
            //    IsAccountMenu=a.IsAccountMenu
            //      }).ToList();

            //select new
            //{
            //    ss=t.
            //    First_Name = d.First_Name
            //}
            ViewBag.UserName = SourceMastersModel.GetUserFullName(Convert.ToInt32(Session["UserId"].ToString()), Session["UserType"].ToString());

            Session["Menu"] = Query1;
            return(View());
        }
Beispiel #6
0
        public ActionResult Login(UserRegistration UR)
        {
            bool status = true;

            if (string.IsNullOrEmpty(UR.UserName))
            {
                status = false;
            }
            else if (string.IsNullOrEmpty(UR.Password))
            {
                status = false;
            }
            //else if (UR.BranchID <= 0)
            //    status = false;
            //else if (UR.AcFinancialYearID <= 0)
            //    status = false;



            if (status)
            {
                List <SP_LoginUser_Result> Log = new List <SP_LoginUser_Result>();

                Log = rgm.LoginUser(UR);
                var userlogin = entity.UserRegistrations.Where(d => d.EmailId == UR.UserName && d.Password == UR.Password).ToList();
                if (userlogin.Count > 0)
                {
                    foreach (var item in userlogin)
                    {
                        FormsAuthentication.SetAuthCookie(item.UserName, true);
                        var User_Registration = (from t in entity.UserRegistrations
                                                 where t.UserID == item.UserID
                                                 select t
                                                 ).FirstOrDefault();
                        if (User_Registration.BranchID == 0 || User_Registration.BranchID == null)
                        {
                            User_Registration.BranchID = entity.BranchMasters.FirstOrDefault().BranchID;
                        }
                        var acfinancialyearid = entity.AcFinancialYears.Where(d => d.BranchID == User_Registration.BranchID).FirstOrDefault().AcFinancialYearID;

                        int?BranchCurrencyId = (from e in entity.BranchMasters where e.BranchID == User_Registration.BranchID select e.CurrencyID).FirstOrDefault();
                        var basecurrency     = (from t in entity.CurrencyMasters where t.CurrencyID == BranchCurrencyId select t).FirstOrDefault();
                        Session["BaseCurrencyId"]     = BranchCurrencyId;
                        Session["BaseCurrency"]       = basecurrency.CurrencyName;
                        Session["BaseCurrencySymbol"] = basecurrency.Symbol;
                        Session["UserID"]             = item.UserID;
                        Session["UserName"]           = item.UserName;
                        Session["branchid"]           = User_Registration.BranchID;
                        var AccompanyId = (from c in entity.AcCompanies select c.AcCompanyID).FirstOrDefault();
                        Session["AcCompanyID"] = AccompanyId;
                        Session["fyearid"]     = acfinancialyearid;
                        SourceMastersModel objSourceMastersModel = new SourceMastersModel();
                        Session["Company"]    = objSourceMastersModel.GetAcCompaniesById(AccompanyId).AcCompany1;
                        Session["BranchName"] = entity.BranchMasters.Find(User_Registration.BranchID).BranchName;
                        var fyearFrom = (from t in entity.AcFinancialYears where t.AcFinancialYearID == acfinancialyearid select t.AcFYearFrom).FirstOrDefault();
                        Session["FyearFrom"] = fyearFrom;
                        var fyearTo = (from t in entity.AcFinancialYears where t.AcFinancialYearID == acfinancialyearid select t.AcFYearTo).FirstOrDefault();

                        Session["FyearTo"] = fyearTo;
                        var query = (from t in entity.UserRegistrations
                                     where t.UserID == item.UserID && t.RoleID.HasValue
                                     select t.RoleID.Value).ToList();
                        var UserRoleID = (from t in entity.UserRegistrations
                                          where t.UserID == item.UserID
                                          select t.RoleID).FirstOrDefault();
                        Session["UserRoleID"] = UserRoleID;
                        if (query != null)
                        {
                            Session["RoleID"] = query;
                            if (query[0] == 1)
                            {
                                var menuaccesslevels = new List <MenuAccessLevel>();
                                var menus            = (from t in entity.Menus where t.IsAccountMenu.Value == false orderby t.MenuOrder select t).ToList();

                                Session["Menu"] = menus;
                            }
                            else
                            {
                                Int32 roleid   = query[0];
                                var   menudata = (from t in entity.MenuAccessLevels
                                                  join s in entity.Menus on t.MenuID equals s.MenuID
                                                  where t.RoleID == roleid && t.IsView == true
                                                  orderby s.MenuOrder
                                                  select s).ToList();
                                Session["menu"] = menudata;
                            }
                        }
                        else
                        {
                            Session["RoleID"] = new List <int>();
                        }
                    }

                    return(RedirectToAction("Home", "Home"));
                }

                Session["ForgotStatus"]  = "Forgot";
                Session["StatusMessage"] = "Invalid EmailId!";
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                ViewBag.ErrorMessage = "Please fill mandatory fields";
                ViewBag.Branch       = entity.BranchMasters.ToList();

                ViewBag.fyears = entity.AcFinancialYearSelect(Convert.ToInt32(Session["branchid"])).ToList();
                return(View());
            }
        }