示例#1
0
        public void adduser(userinfo eh)
        {
            var      uid = db.Usr.Max(v => v.ID) + 1;
            Usr      ei  = new Usr();
            Secur    sr  = new Secur();
            UserRole ur  = new UserRole();

            ei.UserID = uid;
            ei.EmpID  = eh.EmpID;
            var emp = db.EmpInfo.Where(x => x.ID == eh.EmpID).FirstOrDefault();

            emp.Usr        = eh.UserName.Trim();
            ei.UserName    = eh.UserName.Trim();
            ei.UserKey     = sr.Encrypt(eh.UserKey.Trim());
            ei.EntryKey    = "000";
            ei.Role        = eh.Role;
            ei.Email       = eh.Email;
            ei.Telephone   = eh.Telephone;
            ei.IsActive    = eh.IsActive;
            ei.ValidFrom   = eh.ValidFrom;
            ei.CreatedBy   = eh.Createby;
            ei.CreatedDate = DateTime.Today;
            ei.CreatedTime = DateTime.Now.TimeOfDay;
            ur.UserID      = uid;
            ur.RoleID      = eh.Role;
            ur.IsActive    = eh.IsActive;
            ur.ValidFrom   = DateTime.Today;
            ur.CreatedBy   = eh.Createby;
            ur.CreatedDate = DateTime.Today;
            ur.CreatedTime = DateTime.Now.TimeOfDay;
            db.Usr.Add(ei);
            db.SaveChanges();
            db.UserRole.Add(ur);
            db.SaveChanges();
        }
示例#2
0
        public ActionResult EditUser([Bind(Include = "ID,UserID,EmpID,UserName,UserKey,Role,Telephone,EmpID,Email,IsActive,ValidFrom,CreatedBy")] Usr eh)
        {
            ViewBag.depts = new SelectList(am.Role, "ID", "RoleName");
            var empi = am.EmpInfo.Where(x => x.Usr == eh.UserName).Select(c => c.FullName).FirstOrDefault();

            ViewBag.emp = empi;
            if (ModelState.IsValid)
            {
                CoreManager DM = new CoreManager();
                if (!DM.IsLoginName(eh.UserName, eh.ID))
                {
                    var ei = am.Usr.SingleOrDefault(v => v.UserID == eh.UserID);
                    var ri = am.UserRole.SingleOrDefault(v => v.UserID == eh.UserID);
                    if (ei == null)
                    {
                        return(HttpNotFound());
                    }
                    ei.UserName  = eh.UserName.Trim();
                    ei.Role      = eh.Role;
                    ei.Email     = eh.Email;
                    ei.Telephone = eh.Telephone;
                    ei.IsActive  = eh.IsActive;
                    ei.ValidFrom = eh.ValidFrom;
                    ei.CreatedBy = eh.CreatedBy;
                    ei.EmpID     = eh.EmpID;
                    var emp = am.EmpInfo.Where(x => x.ID == eh.EmpID).FirstOrDefault();
                    if (emp != null)
                    {
                        emp.Usr = eh.UserName.Trim();
                    }
                    if (ri != null)
                    {
                        ri.RoleID = eh.Role; ri.ValidFrom = eh.ValidFrom; ri.IsActive = eh.IsActive;
                    }
                    am.SaveChanges();
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "الاسم موجود من قبل");
                    return(View());
                }
            }
            return(RedirectToAction("Index", "User"));
        }
示例#3
0
        public JsonResult removerow(int?id)
        {
            orditm orditm = db.orditm.Find(id);

            db.orditm.Remove(orditm);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public JsonResult adshf(bool a)
        {
            Shft bi = new Shft();

            bi.ShID     = db.Shft.ToList().LastOrDefault().ShID + 1;
            bi.ShftDate = DateTime.Now;
            bi.ShftT    = a;
            db.Shft.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public JsonResult adacount(string expnme)
        {
            SyDB    db = new SyDB();
            var     ca = db.ExpList.ToList().LastOrDefault().ExpID + 1;
            ExpList bi = new ExpList();

            bi.ExpID    = ca;
            bi.ExpName  = expnme;
            bi.IsActive = true;
            db.ExpList.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public JsonResult addexp(int idexp, DateTime exdate, decimal expval, string remrk)
        {
            SyDB     db = new SyDB();
            var      ca = db.ExpDaily.ToList().LastOrDefault().Ser + 1;
            ExpDaily bi = new ExpDaily();

            bi.Ser     = ca;
            bi.ExpID   = idexp;
            bi.ExpVal  = expval;
            bi.ExpDate = exdate;
            bi.Remark  = remrk;
            db.ExpDaily.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        public JsonResult aditm(int itmfk, int ordfk, decimal pr, int shi, int cby)
        {
            SyDB db = new SyDB();
            var  ca = db.orditm.ToList().LastOrDefault().ser + 1;
            //     var dk = db.OrdList.Where(x => x.shitfk == shvt).s + 1;
            //var ddd = db.OrdList.Where(x => x.shitfk == shvt).Max(b => (int?)b.OrderFk) + 1 ?? 1;
            orditm bi = new orditm();

            bi.ser        = ca;
            bi.ordfk      = ordfk;
            bi.itemfk     = itmfk;
            bi.price      = pr;
            bi.qty        = 1;
            bi.totval     = pr * 1;
            bi.createdate = DateTime.Now;
            bi.shid       = shi;
            bi.createby   = cby;
            db.orditm.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public JsonResult adORD(string gsname, int shvt, string address, string tel, string mob, bool?syrim)
        {
            SyDB    db  = new SyDB();
            var     ca  = db.OrdList.ToList().LastOrDefault().OrdID + 1;
            var     ddd = db.OrdList.Where(x => x.shitfk == shvt).Max(b => (int?)b.OrderFk) + 1 ?? 1;
            OrdList bi  = new OrdList();

            bi.OrdID     = ca;
            bi.shitfk    = shvt;
            bi.GuestName = gsname;
            bi.OrdDate   = DateTime.Now;
            bi.OrderFk   = ddd;
            bi.IsActive  = true;
            bi.Address   = address;
            bi.TelNum    = tel;
            bi.Mob       = mob;
            bi.SyianM    = syrim;
            db.OrdList.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        public JsonResult adORD(string gsname, int shvt)
        {
            SyDB db = new SyDB();
            var  ca = db.OrdList.ToList().LastOrDefault().OrdID + 1;
            //     var dk = db.OrdList.Where(x => x.shitfk == shvt).s + 1;
            var ddd = db.OrdList.Where(x => x.shitfk == shvt).Max(b => (int?)b.OrderFk) + 1 ?? 1;



            OrdList bi = new OrdList();

            bi.OrdID     = ca;
            bi.shitfk    = shvt;
            bi.GuestName = gsname;
            bi.OrdDate   = DateTime.Now;
            bi.OrderFk   = ddd;
            bi.IsActive  = true;
            db.OrdList.Add(bi);
            db.SaveChanges();
            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }