public IQueryable <tbl_newscomments> getreplynewscomments(int id = 0, int id01 = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_newscomments.Where(a => (a.newsid == id && a.parentid == id01 && a.comfirmation == true)).OrderByDescending(a => a.id);

            return(q);
        }
        public IQueryable <tbl_news> getslides(int i = 0, int j = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_news.Where(a => a.confirmation == true).OrderByDescending(a => a.id).Skip(j).Take(i);

            return(q);
        }
        public IQueryable <tbl_newstype> getnewstype()
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_newstype;

            return(q);
        }
        public IQueryable <tbl_news> getnewsbasedtype(int i = 0, int j = 0, int k = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_news.Where(a => (a.confirmation == true && a.newtypeid == k)).OrderByDescending(a => a.id).Skip(j).Take(i);

            return(q);
        }
Ejemplo n.º 5
0
        public int getentityitem(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = from b in db.tbl_listkala97

                    group b by b.productid into g
                    select new
            {
                productid = g.Key,

                Totalentity = g.Sum(item => item.kalanumberm),
            };

            var a = q.Where(k => k.productid == id).SingleOrDefault();

            if (a != null)
            {
                int h = (int)a.Totalentity;
                return(h);
            }
            else
            {
                int h = 0;
                return(h);
            }
        }
        public virtual tbl_ftp getftp(int id)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_ftp.Where(a => a.id == id).SingleOrDefault();

            return(q);
        }
        public IQueryable <tbl_newsimagefiles> getnewsimagefile()
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = db.tbl_newsimagefiles.OrderByDescending(a => a.id);

            return(q);
        }
Ejemplo n.º 8
0
        public IQueryable <tbl_listkala97> getlastsellrecord(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var lastrecord             = db.tbl_listkala97.Where(a => a.productid == id && a.htype == -1).OrderByDescending(a => a.sodoordate);


            return(lastrecord);
        }
Ejemplo n.º 9
0
        public virtual tbl_listkala getlastbuyrecord(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var lastrecord             = db.tbl_listkala97.Where(a => a.productid == id && a.htype == 1).Count() == 0 ? null : db.tbl_listkala.Where(a => a.productid == id && a.htype == 1).OrderByDescending(a => a.sodoordate).FirstOrDefault();


            return(lastrecord);
        }
Ejemplo n.º 10
0
        public int numberbuy(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var number = db.tbl_listkala97.Where(a => a.productid == id && a.htype == 1).Count();


            return(number);
        }
Ejemplo n.º 11
0
        public string getlastbuydate(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var lastbuydate            = db.tbl_listkala97.Where(a => a.productid == id && a.htype == 1).Count() == 0 ? "" : db.tbl_listkala.Where(a => a.productid == id && a.htype == 1).OrderByDescending(a => a.sodoordate).FirstOrDefault().sodoordate.ToPersianDate();


            return(lastbuydate);
        }
Ejemplo n.º 12
0
        public string getlastselldesc(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var lastselldesc           = db.tbl_listkala97.Where(a => a.productid == id && a.htype == -1).Count() == 0 ? "" : db.tbl_listkala.Where(a => a.productid == id && a.htype == -1).OrderByDescending(a => a.sodoordate).FirstOrDefault().kaladescription;


            return(lastselldesc);
        }
Ejemplo n.º 13
0
        public decimal getlastsellprice(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            decimal lastsellprice      = db.tbl_listkala97.Where(a => a.productid == id && a.htype == -1).Count() == 0 ? 0 : db.tbl_listkala.Where(a => a.productid == id && a.htype == -1).OrderByDescending(a => a.sodoordate).FirstOrDefault().kalacost;


            return(lastsellprice);
        }
Ejemplo n.º 14
0
        public IQueryable <tbl_products> getproducts(string s = "")
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = from a in db.tbl_products
                    where (a.name.Contains(s) || a.codename.Contains(s))
                    select a;

            return(q);
        }
Ejemplo n.º 15
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();


            if (filterContext.HttpContext.Session.GetInt32("userid") == null)
            {
                if (filterContext.HttpContext.Request.Cookies["userid"] != null)
                {
                    filterContext.HttpContext.Session.SetString("username", filterContext.HttpContext.Request.Cookies["username"]);
                    filterContext.HttpContext.Session.SetInt32("userid", int.Parse(filterContext.HttpContext.Request.Cookies["userid"]));

                    int    userid   = filterContext.HttpContext.Session.GetInt32("userid").Value;
                    string fname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().name;
                    string lname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().Lname;
                    string fullname = fname + " " + lname;
                    filterContext.HttpContext.Session.SetString("fullname", fullname);
                }
            }

            //
            int    usernameid = 0;
            string action     = filterContext.RouteData.Values["Action"].ToString();
            string controller = filterContext.RouteData.Values["Controller"].ToString();
            bool?  permission = null;

            if (filterContext.HttpContext.Session.GetInt32("userid") != null)
            {
                usernameid = filterContext.HttpContext.Session.GetInt32("userid").Value;
                var q = db.tbl_actionaccessibility.Where(a => a.acction_.action_name.ToLower() == action.ToLower() && a.acction_.controller_.controller_name.ToLower() == (controller.ToLower() + "controller").ToLower() && a.userid == usernameid).FirstOrDefault();
                if (q != null)
                {
                    int idd = q.id;
                    permission = q.permission;
                }
                else
                {
                    permission = false;
                }
            }

            if (permission == null)
            {
                filterContext.Result = new ViewResult
                {
                    ViewName = "~/Views/Home/login.cshtml",
                };
            }
            else if (permission == false)
            {
                filterContext.Result = new ViewResult
                {
                    ViewName = "~/Views/Home/AccessIsDenied.cshtml",
                };
            }
        }
Ejemplo n.º 16
0
        public IQueryable <tbl_sample> getsample(int ID = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = from a in db.tbl_sample
                    where a.idcategory == ID

                    select a;

            //var w = q.FirstOrDefault().tbl_category.categoryname;

            return(q);
        }
        public static bool thisuserallowtodo(int userid = 0, int accessid = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var record = db.tbl_accesslevels.Where(a => a.accessid == accessid && a.userid == userid && a.accessvalue == true);

            if (record.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 18
0
        public string getexistproducts(int id = 0)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var q = from b in db.tbl_listkala97

                    group b by b.productid into g
                    select new
            {
                productid = g.Key,

                Totalentity = g.Sum(item => item.kalanumberm),
            };
            var kalaq = db.tbl_products.Where(l => l.idproduct == id).SingleOrDefault();

            var a = q.Where(k => k.productid == id).SingleOrDefault();

            if (a != null)
            {
                int h = (int)a.Totalentity;
                if (h >= kalaq.inventory)
                {
                    return("موجود");
                }
                else if (h < kalaq.inventory && h > 0)
                {
                    return("محدود");
                }
                else if (h == 0)
                {
                    return("به زودی ");
                }
                else if (h < 0)
                {
                    return("موجودی منفی");
                }
                else
                {
                    return("نا مشخص");
                }
            }
            else
            {
                return("موجود نیست");
            }
        }
Ejemplo n.º 19
0
        public IQueryable <tbl_sample> getsamplerandom()
        {
            Random rnd = new Random();

            int b = rnd.Next(1, getsample().Count());

            _4820_soltaniwebContext db = new _4820_soltaniwebContext();



            var q = from a in db.tbl_sample
                    where a.idsample.Equals(b)
                    select a;



            return(q);
        }
Ejemplo n.º 20
0
        public static bool statisticssave(string controller, string action, string ip, Nullable <int> userid)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            tbl_statistics          t  = new tbl_statistics();

            t.actionname     = action;
            t.controllername = controller;
            t.enterdate      = DateTime.Now;
            t.ip             = ip;
            if (userid != null)
            {
                t.user_id = userid;
            }

            db.tbl_statistics.Add(t);
            db.SaveChanges();
            return(true);
        }
Ejemplo n.º 21
0
        public IQueryable getentity()
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            //var q = db.tbl_news.Where(a => a.confirmation == true).OrderByDescending(a => a.id).Skip(j).Take(i);

            var q = (from b in db.tbl_listkala97
                     group b by b.productid into g
                     select new
            {
                productid = g.Key,

                Totalentity = g.Sum(item => item.kalanumberm),
            });



            return(q);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();


            //
            int    usernameid = 0;
            string action     = filterContext.RouteData.Values["Action"].ToString();
            string controller = filterContext.RouteData.Values["Controller"].ToString();
            bool?  permission = null;

            if (filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                //usernameid = filterContext.HttpContext.Session.GetInt32("userid").Value;
                usernameid = int.Parse(filterContext.HttpContext.User.Claims.FirstOrDefault().Value);
                var q = db.tbl_actionaccessibility.Where(a => a.acction_.action_name.ToLower() == action.ToLower() && a.acction_.controller_.controller_name.ToLower() == (controller.ToLower() + "controller").ToLower() && a.userid == usernameid).FirstOrDefault();
                if (q != null)
                {
                    int idd = q.id;
                    permission = q.permission;
                }
                else
                {
                    permission = false;
                }
            }

            if (permission == null)
            {
                filterContext.Result = new ViewResult
                {
                    ViewName = "~/Views/Home/AccessIsDenied.cshtml",
                };
            }
            else if (permission == false)
            {
                filterContext.Result = new ViewResult
                {
                    ViewName = "~/Views/Home/AccessIsDenied.cshtml",
                };
            }
        }
Ejemplo n.º 23
0
        public virtual tbl_files getsamplesrandom(int decortype = 0)
        {
            Random rnd = new Random();
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();
            var qcabinet    = db.tbl_files.Where(a => a.decortypeid == decortype);
            int countsample = qcabinet.Count();
            int row         = rnd.Next(1, countsample);

            if (countsample > 1)
            {
                var q = qcabinet.OrderBy(a => a.id).Skip(row).Take(1).SingleOrDefault();

                return(q);
            }
            else
            {
                var q = qcabinet.SingleOrDefault();
                return(q);
            }
        }
Ejemplo n.º 24
0
 public sliderepository(_4820_soltaniwebContext db)
 {
     this.db = db;
 }
Ejemplo n.º 25
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _4820_soltaniwebContext db = new _4820_soltaniwebContext();

            if (filterContext.HttpContext.Session.GetInt32("userid") == null)
            {
                if (filterContext.HttpContext.Request.Cookies["userid"] != null)
                {
                    filterContext.HttpContext.Session.SetString("username", filterContext.HttpContext.Request.Cookies["username"]);
                    filterContext.HttpContext.Session.SetInt32("userid", int.Parse(filterContext.HttpContext.Request.Cookies["userid"]));

                    int    userid   = filterContext.HttpContext.Session.GetInt32("userid").Value;
                    string fname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().name;
                    string lname    = db.tbl_user.Where(a => a.id == userid).SingleOrDefault().Lname;
                    string fullname = fname + " " + lname;
                    filterContext.HttpContext.Session.SetString("fullname", fullname);
                }
            }



            tbl_statistics t = new tbl_statistics();

            //t.actionname = (string)routingValues["action"];
            t.actionname     = filterContext.RouteData.Values["Action"].ToString();
            t.controllername = filterContext.RouteData.Values["Controller"].ToString();
            t.enterdate      = DateTime.Now;
            t.ip             = filterContext.HttpContext.Connection.RemoteIpAddress.ToString();
            if (filterContext.HttpContext.Session.GetInt32("userid") == null)
            {
                t.user_id = null;
            }
            else
            {
                t.user_id = filterContext.HttpContext.Session.GetInt32("userid");
            }

            //var myparams = filterContext.ActionParameters;
            var    myparams   = filterContext.ActionArguments;
            string parameters = "";
            int    x          = 0;
            int    count      = 0;

            count = myparams.Count();


            foreach (var item in myparams)
            {
                if (count == 1 || x == count - 1)
                {
                    if (item.Value == null)
                    {
                        parameters = parameters + item.Key + "=null";
                    }
                    else
                    {
                        parameters = parameters + item.Key + "=" + item.Value.ToString();
                    }
                }
                else
                {
                    if (item.Value == null)
                    {
                        parameters = parameters + item.Key + "=null" + "&";
                    }
                    else
                    {
                        parameters = parameters + item.Key + "=" + item.Value.ToString() + "&";
                    }
                }
                x += 1;
            }



            t.parameter = parameters;
            t.fullurl   = "www.soltaniwoodproducts.com/" + t.controllername + "/" + t.actionname + "?" + parameters;
            db.tbl_statistics.Add(t);
            db.SaveChanges();
        }