示例#1
0
        public ActionResult Create([Bind(Include = "firstname,lastname,email")] users users)
        {
            if (ModelState.IsValid)
            {
                int tmpUser = int.Parse(db.users.OrderByDescending(p => p.id) //
                                        .Select(r => r.id)                    // Костылик для автоинкремента id :)
                                        .First().ToString());                 //

                users.id      = tmpUser + 1;
                users.deleted = 0;

                users record = db.users.FirstOrDefault(u => u.email.StartsWith(users.email) && u.email.EndsWith(users.email) && u.deleted == 0); // А этот костылик создан для сравнения text с varchar ибо ругается студия, что их сравнивать нельзя
                if (record == null)
                {
                    db.users.Add(users);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.error = "Пользователь с таким мылом уже существует";
                    return(View());
                }
            }

            return(View(users));
        }
        public ActionResult Create([Bind(Include = "UserDisplayName,DeviceOS,DeviceType,WhenChanged,id")] Mobile20160830 mobile20160830)
        {
            if (ModelState.IsValid)
            {
                db.Mobile20160830.Add(mobile20160830);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mobile20160830));
        }
        public ActionResult Create([Bind(Include = "CourseID,Title,Credits")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Course.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "Id,Name")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "StudentID,LastName,FirstName,EnrollmentDate,MiddleName")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Student.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
        public ActionResult Create([Bind(Include = "EnrollmentID,Grade,CourseID,StudentID")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                db.Enrollment.Add(enrollment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID  = new SelectList(db.Course, "CourseID", "Title", enrollment.CourseID);
            ViewBag.StudentID = new SelectList(db.Student, "StudentID", "LastName", enrollment.StudentID);
            return(View(enrollment));
        }
示例#7
0
        public ActionResult Index(KhachHang kh)
        {
            if (ModelState.IsValid)
            {
                testDBEntities db = new testDBEntities();

                //thong tin bang KHACH
                KHACH kh1 = new KHACH();
                kh1.MaKhach  = kh.maKH;
                kh1.TenKhach = kh.TenKhach;
                kh1.CMND     = kh.Cmnd;
                kh1.Mail     = kh.Mail;
                kh1.SDT      = kh.Sdt;
                db.KHACHes.Add(kh1);

                //thong tin bang Account
                Account acc1 = new Account();
                acc1.IdA     = kh.Sdt;
                acc1.PassA   = kh.Password;
                acc1.MaQuyen = 3;
                db.Accounts.Add(acc1);

                db.SaveChanges();
                return(RedirectToAction("TrangChu"));
            }
            else
            {
            }
            return(View("Index"));
        }
        public ActionResult StavkaEdit(Stavke stavka)
        {
            Stavke jednastavka = db.Stavke.Where(m => m.StavkaId == stavka.StavkaId).FirstOrDefault();

            System.Diagnostics.Debug.WriteLine("kol:" + stavka.Kolicina);
            System.Diagnostics.Debug.WriteLine("PonudaId:" + stavka.PonudaId);
            System.Diagnostics.Debug.WriteLine("ArtikalId:" + stavka.ArtikalId);
            System.Diagnostics.Debug.WriteLine("UkupnaCijenaStavke:" + stavka.UkupnaCijenaStavke);
            System.Diagnostics.Debug.WriteLine("Kolicina:" + stavka.Kolicina);

            jednastavka.UkupnaCijenaStavke = stavka.UkupnaCijenaStavke;
            jednastavka.Kolicina           = stavka.Kolicina;
            jednastavka.ArtikalId          = stavka.ArtikalId;
            db.SaveChanges();


            //UPdate u bazi, stora...
            CalculatePonuda(stavka.PonudaId);
            return(RedirectToAction("Index", "Ponude"));
        }
示例#9
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (testDBEntities obj = new testDBEntities())
     {
         Department cpt = new Department
         {
             Name = txtCourse.Text.Trim()
         };
         obj.Departments.Add(cpt);
         obj.SaveChanges();
     }
     Response.Redirect(Request.RawUrl);
 }