public ActionResult Create([Bind(Include = "Code_Docente,Nombre_Docente")] Docente docente)
        {
            if (ModelState.IsValid)
            {
                db.Docentes.Add(docente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(docente));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "Id_materia,Descripcion")] Materia materia)
        {
            if (ModelState.IsValid)
            {
                db.Materias.Add(materia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(materia));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "ID,Name,Phone,Mail,FechaNacimiento,Address,GenderId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _db.customers.Add(customer);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Age")] MyFirstTable myFirstTable)
        {
            if (ModelState.IsValid)
            {
                db.MyFirstTable.Add(myFirstTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(myFirstTable));
        }
        public ActionResult Create([Bind(Include = "Code_Alumno,Nombres,Apellidos,Fecha_Nacimiento,DNI")] Alumno alumno)
        {
            if (ModelState.IsValid)
            {
                db.Alumnoes.Add(alumno);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(alumno));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "Id_notas,Code_Alumno,Id_Materia,Nota1,Nota2")] Alumno_Materia alumno_Materia)
        {
            if (ModelState.IsValid)
            {
                db.Alumno_Materia.Add(alumno_Materia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Code_Alumno = new SelectList(db.Alumnoes, "Code_Alumno", "Nombres", alumno_Materia.Code_Alumno);
            ViewBag.Id_Materia  = new SelectList(db.Materias, "Id_materia", "Descripcion", alumno_Materia.Id_Materia);
            return(View(alumno_Materia));
        }
示例#7
0
        //添加邮件信息
        public static BaseResultModel <Message> SetMail(Message message)
        {
            BaseResultModel <Message> result = new BaseResultModel <Message>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Message ms = new Message();
                    ms.Name       = message.Name;
                    ms.Phone      = message.Phone;
                    ms.Email      = message.Email;
                    ms.Infos      = message.Infos;
                    ms.SubmitDate = DateTime.Now.ToString();
                    _cDBContext.Me.Add(ms);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = ms;
                    result.message = "邮件提交成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#8
0
        //用于添加富文章
        public static BaseResultModel <SimpleArticle> SetRichArticle(SimpleArticle simpleArticle)
        {
            BaseResultModel <SimpleArticle> result = new BaseResultModel <SimpleArticle>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    SimpleArticle a = new SimpleArticle();
                    a.UserName          = simpleArticle.UserName;
                    a.type              = simpleArticle.type;
                    a.ArticleContext    = simpleArticle.ArticleContext;
                    a.ArticleCreateDate = simpleArticle.ArticleCreateDate;
                    a.ArticleImgUrl     = simpleArticle.ArticleImgUrl;
                    a.ArticleUpdateDate = simpleArticle.ArticleUpdateDate;
                    _cDBContext.Si.Add(a);
                    _cDBContext.SaveChanges();

                    result.status  = 1;
                    result.Data    = null;
                    result.message = "添加文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#9
0
        //用于修改文章
        public static BaseResultModel <Article> UpdateArticle(Article article)
        {
            BaseResultModel <Article> result = new BaseResultModel <Article>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Article a = _cDBContext.Ar.FirstOrDefault(p => p.Id.Equals(article.Id));
                    a.UserName       = article.UserName;
                    a.type           = article.type;
                    a.ArticleContext = article.ArticleContext;

                    a.ArticleSideName   = article.ArticleSideName;
                    a.ArticleUpdateDate = article.ArticleUpdateDate;
                    a.ArticleName       = article.ArticleName;
                    _cDBContext.Ar.Update(a);
                    _cDBContext.SaveChanges();

                    result.status  = 1;
                    result.Data    = null;
                    result.message = "更新文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#10
0
        public void Guardar()
        {
            //var docente = new Docente();

            try
            {
                using (CDBContext db = new CDBContext())
                {
                    if (this.Code_Docente == 0)
                    {
                        db.Entry(this).State = EntityState.Added;
                        foreach (var m in this.Materias)
                        {
                            db.Entry(m).State = EntityState.Unchanged;
                        }
                    }
                    db.SaveChanges();
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#11
0
        //一次添加多个轮播图
        public static BaseResultModel <List <ScrollPicture> > AddScrollPicList(List <ScrollPicture> sp)
        {
            BaseResultModel <List <ScrollPicture> > result = new BaseResultModel <List <ScrollPicture> >();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    for (int i = 0; i < sp.Count; i++)
                    {
                        ScrollPicture scrollpicture = new ScrollPicture();
                        scrollpicture.PicName       = sp[i].PicName;
                        scrollpicture.ImgUrl        = sp[i].ImgUrl;
                        scrollpicture.ImgSubmitDate = sp[i].ImgSubmitDate;
                        scrollpicture.UserName      = sp[i].UserName;
                        _cDBContext.Sc.Add(scrollpicture);
                    }
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "多张轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
        public JsonResult Insert(Employee obj)
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFileBase file = Request.Files[i];
                        string             fname;
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testFiles = file.FileName.Split(new char[] { '\\' });
                            fname = testFiles[testFiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        var uploadRootFolderInput = AppDomain.CurrentDomain.BaseDirectory + "\\Uploads";
                        Directory.CreateDirectory(uploadRootFolderInput);
                        var directoryFullPathInput = uploadRootFolderInput;
                        fname = Path.Combine(directoryFullPathInput, fname);

                        file.SaveAs(fname);

                        obj.Image = file.FileName;
                    }
                }

                _context.Employees.Add(obj);
                _context.SaveChanges();

                return(Json("Record insert Sucessfully", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
        }
示例#13
0
        public static BaseResultModel <Message> DeleteMessages(string Id)
        {
            int id = Int32.Parse(Id);
            BaseResultModel <Message> result = new BaseResultModel <Message>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Message ms = new Message();
                    ms = _cDBContext.Me.FirstOrDefault(p => p.Id == id);
                    _cDBContext.Remove(ms);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "邮件删除成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#14
0
        public static BaseResultModel <ScrollPicture> DeleteScrollPic(string Id)
        {
            int id = Int32.Parse(Id);
            BaseResultModel <ScrollPicture> result = new BaseResultModel <ScrollPicture>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    ScrollPicture sps = new ScrollPicture();
                    sps = _cDBContext.Sc.FirstOrDefault(p => p.Id == id);
                    _cDBContext.Remove(sps);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "删除轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#15
0
        //用于修改富文章
        public static BaseResultModel <SimpleArticle> UpdateRichArticle(SimpleArticle simpleArticle)
        {
            BaseResultModel <SimpleArticle> result = new BaseResultModel <SimpleArticle>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    SimpleArticle a = _cDBContext.Si.FirstOrDefault(p => p.Id == simpleArticle.Id);
                    a.UserName          = simpleArticle.UserName;
                    a.type              = simpleArticle.type;
                    a.ArticleContext    = simpleArticle.ArticleContext;
                    a.ArticleUpdateDate = simpleArticle.ArticleUpdateDate;
                    _cDBContext.Si.Update(a);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "更新文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
示例#16
0
        //添加轮播图片
        public static BaseResultModel <ScrollPicture> AddScrollPic(ScrollPicture sp)
        {
            BaseResultModel <ScrollPicture> result = new BaseResultModel <ScrollPicture>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    ScrollPicture scrollpicture = new ScrollPicture();
                    scrollpicture.PicName       = sp.PicName;
                    scrollpicture.ImgUrl        = sp.ImgUrl;
                    scrollpicture.ImgSubmitDate = sp.ImgSubmitDate;
                    scrollpicture.UserName      = sp.UserName;
                    _cDBContext.Sc.Add(scrollpicture);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }