Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "DepartmentId,DepartmentName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,DepID,customerName,password,tel,email")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepID = new SelectList(db.Departments, "DepartmentId", "DepartmentName", user.DepID);
            return(View(user));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Name,Pid,PValue,Url")] Permissions permissions)
        {
            if (ModelState.IsValid)
            {
                db.Permissionss.Add(permissions);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Pid = new SelectList(db.Permissionss, "Id", "Name", permissions.Pid);
            return(View(permissions));
        }
Ejemplo n.º 4
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                user.passwordSalt = Utility.CreateSalt();
                user.password     = Utility.GenerateHashWithSalt(user.password, user.passwordSalt);
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepID = new SelectList(db.Departments, "DepartmentId", "DepartmentName", user.DepID);
            return(View(user));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader("test03.TXT");

            myModel context = new myModel();

            while ((line = file.ReadLine()) != null)
            {
                char[] temp = line.ToCharArray();
                if (checkFirstFormat(temp) == true)
                {
                    string index0_12  = String.Empty;
                    string index13_20 = String.Empty;
                    string index21_28 = String.Empty;

                    for (int i = 0; i < temp.Count(); i++)
                    {
                        if (i >= 0 && i <= 12)
                        {
                            index0_12 = index0_12 + temp[i];
                        }
                        else if (i >= 13 && i <= 20)
                        {
                            index13_20 = index13_20 + temp[i];
                        }
                        else if (i >= 21 && i <= 28)
                        {
                            index21_28 = index21_28 + temp[i];
                        }
                    }

                    // Console.WriteLine(index0_12 + " " + index13_20 + " " + index21_28);

                    if (index13_20 == "99999999")
                    {
                        DateTable data = new DateTable()
                        {
                            TickNumber = index0_12,
                            FlyingDay  = DateTime.MaxValue,
                            Birthday   = DateTime.ParseExact(index21_28, "yyyyMMdd", null)
                        };

                        context.DateTable.Add(data);
                        context.SaveChanges();
                    }
                    else
                    {
                        DateTable data = new DateTable()
                        {
                            TickNumber = index0_12,
                            FlyingDay  = DateTime.ParseExact(index13_20, "yyyyMMdd", null),
                            Birthday   = DateTime.ParseExact(index21_28, "yyyyMMdd", null)
                        };

                        context.DateTable.Add(data);
                        context.SaveChanges();
                    }
                }
            }


            var list = context.DateTable.ToList();

            foreach (var l in list)
            {
                Console.WriteLine(l.TickNumber + " " + l.FlyingDay.ToString("yyyy/MM/dd") + " " + l.Birthday.ToString("yyyy/MM/dd"));
            }


            file.Close();
            Console.ReadLine();
        }