示例#1
0
 public List <customerinfo> GetListByUser(int userid, int page = 0, int size = 100)
 {
     using (var edm = new appEntities())
     {
         return(edm.customerinfo.Where(p => p.isdel == 0 && p.userId == userid).OrderByDescending(p => p.id).Skip((page - 1) * size).Take(size).ToList());
     }
 }
示例#2
0
        public ActionResult Index(UserViewModel objInputi)
        {
            appEntities contex = new appEntities();

            string aa = (MD5Hash(objInputi.password)).ToString();

            var person = (from a in contex.useris
                          where a.email == objInputi.email && a.password == aa
                          select a).FirstOrDefault();

            if (person != null)
            {
                var adminOrUser = contex.useris.Where(a => a.AdminOrUser == 0 && a.email == objInputi.email).FirstOrDefault();



                if (adminOrUser != null)
                {
                    Session["UserEmail"] = objInputi.email;
                    return(Content("<script language='javascript' type='text/javascript'>alert('login succees :USER:'******'home/index'</script>"));
                }

                else
                {
                    Session["UserEmail"] = objInputi.email;
                    return(Content("<script language='javascript' type='text/javascript'>alert('login succees :ADMIN:'); window.location.href='admin/admin'</script>"));
                }
            }

            else
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('login fail');window.location.href='https://localhost:44303/home/index'</script>"));
            }
        }
示例#3
0
 public void add(string name, string sex, string ismarr, string cardNo, string address, string workunit, string workaddress, string job, string phone, string str, string username, int userid)
 {
     using (var edm = new appEntities())
     {
         var model = new customerinfo()
         {
             name        = name,
             sex         = sex,
             ismarr      = ismarr,
             cardNo      = cardNo,
             address     = address,
             workaddress = workaddress,
             workunit    = workunit,
             job         = job,
             phone       = phone,
             detail      = str,
             createTime  = DateTime.Now,
             user        = username,
             userId      = userid,
             isdel       = 0
         };
         edm.customerinfo.Add(model);
         edm.SaveChanges();
     }
 }
示例#4
0
 public void DelCustomer(int id)
 {
     using (var edm = new appEntities())
     {
         var model = edm.customerinfo.FirstOrDefault(p => p.id == id);
         model.isdel   = 1;
         model.delInfo = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         edm.SaveChanges();
     }
 }
示例#5
0
 public int GetCount(int usr = 0)
 {
     using (var edm = new appEntities())
     {
         if (usr != 0)
         {
             return(edm.customerinfo.Where(p => p.isdel == 0 && p.userId == usr).Count());
         }
         return(edm.customerinfo.Where(p => p.isdel == 0).Count());
     }
 }
示例#6
0
 public ActionResult admin()
 {
     using (var contex = new appEntities())
     {
         var objDBB = contex.useris.ToList();
         if (objDBB != null)
         {
             return(View("admin", objDBB));
         }
     }
     return(View());
 }
示例#7
0
        public JsonResult admin(string search)
        {
            appEntities contex = new appEntities();
            //Filtrim sipas inputit
            var RecordFiltred = contex.useris.Where(x => x.emer.Contains(search) || x.email.Contains(search) ||
                                                    x.ID.ToString().Contains(search) || x.mbiemer.Contains(search) || x.password.Contains(search) || x.AdminOrUser.ToString().Contains(search)).ToList();

            System.IO.FileStream fs = new FileStream(Server.MapPath("~/App_Data") + "\\" + "document.pdf", FileMode.Create);


            Document document = new Document(PageSize.A4, 25, 25, 30, 30);


            PdfWriter writer = PdfWriter.GetInstance(document, fs);
            PdfPTable table  = new PdfPTable(6);

            PdfPCell cell = new PdfPCell(new Phrase("Raport Data Table"));

            cell.Colspan             = 6;
            cell.HorizontalAlignment = 1;
            table.AddCell(cell);

            table.AddCell("PersonID");
            table.AddCell("Emer");
            table.AddCell("Mbiemer");
            table.AddCell("Email");
            table.AddCell("Password Encrypted");
            table.AddCell("Admin Or User");

            foreach (var item in RecordFiltred)
            {
                table.AddCell((item.ID).ToString());
                table.AddCell(item.emer);
                table.AddCell(item.mbiemer);
                table.AddCell(item.email);
                table.AddCell(item.password);
                table.AddCell((item.AdminOrUser).ToString());
            }

            // Open the document to enable you to write to the document
            document.Open();
            //document.Add(new Paragraph());
            document.Add(table);
            // Close the document
            document.Close();
            // Close the writer instance
            writer.Close();
            // Always close open filehandles explicity
            fs.Close();
            Download();
            return(Json("ok"));
        }
示例#8
0
 public List <users> GetUserList()
 {
     try
     {
         using (var edm = new appEntities())
         {
             var users = edm.users.Where(p => p.Type > 0).ToList();
             return(users);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#9
0
 public users Login(string name, string pwd)
 {
     try
     {
         using (var edm = new appEntities())
         {
             pwd = pwd.ToMD5();
             var model = edm.users.FirstOrDefault(p => p.UserName == name && p.PWd == pwd);
             return(model);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#10
0
 public users Add(string name, string pwd, string nickname = "")
 {
     try
     {
         using (var edm = new appEntities())
         {
             pwd = pwd.ToMD5();
             var model = new users()
             {
                 UserName = name, PWd = pwd, NickName = nickname, CreateTime = DateTime.Now, Type = 3
             };
             edm.users.Add(model);
             edm.SaveChanges();
             return(model);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#11
0
 public ActionResult register(UserViewModel objinput)
 {
     using (var ctx = new appEntities())
     {
         var register = ctx.useris.Where(a => a.email == objinput.email).FirstOrDefault();
         if (register != null)
         {
             return(Content("<script language='javascript' type='text/javascript'>alert('ky email ekziston');</script>"));
         }
         else
         {
             useri registeo = new useri();
             registeo.email    = objinput.email;
             registeo.emer     = objinput.emer;
             registeo.mbiemer  = objinput.mbiemer;
             registeo.password = MD5Hash(objinput.password);
             ctx.useris.Add(registeo);
             ctx.SaveChanges();
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
示例#12
0
        public ActionResult Index()
        {
            StringBuilder sb = new StringBuilder();

            using (var context = new appEntities())
            {
                context.plan.Load();

                // Add a new plan to the context
                context.plan.Add(new plan
                {
                    name                 = "BasicTests",
                    minute_limit         = 100,
                    sms_limit            = 110,
                    price                = 10,
                    overage_minute_price = 0.014M,
                    overage_sms_price    = 0.15M,
                    is_available         = true
                });

                context.plan.Find(2).name = "testmodified";
                // Mark one of the existing plans as Deleted
                context.plan.Remove(context.plan.Find(1));

                // Loop over the plans in the context.
                log.Info("In Local: ");
                foreach (var plan in context.plan.Local)
                {
                    log.Info(
                        "Plan ID : " +
                        plan.plan_id + " Plan Name : " +
                        plan.name + "Context state : " +
                        context.Entry(plan).State);
                }

                // Perform a query against the database.
                log.Info("\nIn DbSet query: ");
                foreach (var plan in context.plan)
                {
                    log.Info(
                        "Plan ID : " +
                        plan.plan_id + " Plan Name : " +
                        plan.name + "Context state : " +
                        context.Entry(plan).State);
                }

                log.Info("\nAll modified entities: ");
                foreach (var entry in context.ChangeTracker.Entries()
                         .Where(e => e.State == EntityState.Modified))
                {
                    log.Info(
                        "Found entity of type " + ObjectContext.GetObjectType(entry.Entity.GetType()).Name + " with state " + entry.State
                        );
                }                /* var plan = new plan()
                                 *  {
                                 *  name = "Basic",
                                 *  minute_limit = 100,
                                 *  sms_limit = 110,
                                 *  price = 10,
                                 *  overage_minute_price = 0.014M,
                                 *  overage_sms_price = 0.15M,
                                 *  is_available = true
                                 *
                                 *  };
                                 *  context.plan.Add(plan);
                                 *  context.SaveChanges();*/
                                 //  var query = context.plan.Find(1).name;//context.plan.ToList();
                                 // log.Error(query);

                foreach (var plan in context.plan)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(" ; ");
                    }
                    sb.Append(plan.name.Trim());
                }
            }

            return(View((object)sb.ToString()));
        }