/// <summary> /// 根据部门id删除部门 /// </summary> /// <param name="_id"></param> /// <returns></returns> public bool DelDept(int _id) { t.Entry <Dept>(new Dept { ID = _id }).State = System.Data.EntityState.Deleted; return(t.SaveChanges() > 0); }
public object EditBibloInfo(BibloInfoDTO info) { try { var UpdateBibloItems = cugDB.BibloMains.Where(bm => bm.ID.Equals("Pagex") || bm.ID.Equals("page1Top") || bm.ID.Equals("Page1l") || bm.ID.Equals("Page1r") || bm.ID.Equals("Comments") || bm.ID.Equals("PageBibloTitle") || bm.ID.Equals("CopyRight") || bm.ID.Equals("PageBibloBody") || bm.ID.Equals("refTop")).OrderBy(bm => bm.MainId).ToList(); UpdateBibloItems[4].Body = info.PageRight; UpdateBibloItems[5].Body = info.PageLeft; UpdateBibloItems[8].Body = info.Comments; UpdateBibloItems[7].Body = info.PageBibloTitle; UpdateBibloItems[6].Body = info.PageBibloBody; UpdateBibloItems[2].Body = info.CopyRight; UpdateBibloItems[1].Body = info.PageRefTitle; cugDB.SaveChanges(); return(new Response { Status = "saved", Message = "Record SuccessFully Saved." }); } catch (Exception ex) { return(new Response { Status = "Error" + ex.Message, Message = "Invalid Data." }); } }
public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.StudentId) { return(BadRequest()); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// 新增 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> /// <returns></returns> public static int AddEntity <T>(T entity) where T : class { db.Entry <T>(entity).State = EntityState.Added; return(db.SaveChanges()); // DbContextFactory db = new DbContextFactory(); // db. // db = new DbContextFactory.GetCurrentDbContext(); }
/// <summary> /// 根据日程id修改日程 /// </summary> /// <param name="_c"></param> /// <returns></returns> public bool UpdCalendarByID(Calendar _c) { Calendar c = t.Calendar.Where(a => a.ID == _c.ID).FirstOrDefault(); c.ID = _c.ID; c.ActionTime = _c.ActionTime; c.Schedule = _c.Schedule; c.ScheduleDate = _c.ScheduleDate; return(t.SaveChanges() > 0); }
public ActionResult Create([Bind(Include = "ID,Name,Designation,Salary")] EmployeeBIO employeeBIO) { if (ModelState.IsValid) { db.EmployeeBIOs.Add(employeeBIO); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeBIO)); }
public ActionResult Create([Bind(Include = "multiple_district_id,multiple_district_name_thai,multiple_district_name_eng")] MultipleDistrict multipleDistrict) { if (ModelState.IsValid) { db.MultipleDistricts.Add(multipleDistrict); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(multipleDistrict)); }
public ActionResult Create([Bind(Include = "Customer_ID,FirstName,LastName,Email,Phone")] Customer customer) { if (ModelState.IsValid) { db.Customer.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
// [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "id,name,kana,tel,password")] user users) { if (ModelState.IsValid) { db.users.Add(users); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(users)); }
public ActionResult Create([Bind(Include = "Route_ID,Departure,Destination,Date,Airplane_ID")] Route route) { if (ModelState.IsValid) { db.Route.Add(route); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(route)); }
public ActionResult Create([Bind(Include = "track_id,album_id,artist_id,license_title,track_bit_rate,track_comments,track_composer,track_date_created,track_date_recorded,track_disc_number,track_duration,track_explicit,track_explicit_notes,track_favorites,track_information,track_instrumental,track_interest,track_language_code,track_listens,track_lyricist,track_number,track_publisher,track_title,track_url")] Track track) { if (ModelState.IsValid) { db.Tracks.Add(track); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(track)); }
public ActionResult Create([Bind(Include = "ID_MARCA,DESCRIPCION")] MARCA mARCA) { if (ModelState.IsValid) { db.MARCA.Add(mARCA); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mARCA)); }
public ActionResult deleteResult(int usrmovieId) { UserMovie toDeleteEntry = msContext.UserMovie.Where(x => x.UserMovieId == usrmovieId).FirstOrDefault(); msContext.Entry(toDeleteEntry).State = System.Data.Entity.EntityState.Deleted; msContext.SaveChanges(); string test = "hiii"; return(Json(test)); }
public ActionResult Create([Bind(Include = "Id,Subject,Content,PosyDateTime")] Table table) { if (ModelState.IsValid) { db.Table.Add(table); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table)); }
public ActionResult Create([Bind(Include = "district_id,district_name_thai,district_name_eng,multiple_district_id")] District district) { if (ModelState.IsValid) { db.Districts.Add(district); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.multiple_district_id = new SelectList(db.MultipleDistricts, "multiple_district_id", "multiple_district_name_thai", district.multiple_district_id); return(View(district)); }
public ActionResult Create([Bind(Include = "ID_MODELO,ID_MARCA,DESCRIPCION_MODELO")] MODELO mODELO) { if (ModelState.IsValid) { db.MODELO.Add(mODELO); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_MARCA = new SelectList(db.MARCA, "ID_MARCA", "DESCRIPCION", mODELO.ID_MARCA); return(View(mODELO)); }
public ActionResult Create([Bind(Include = "Route_ID,Departure,Destination,Date,Airplane_ID")] Route route) { if (ModelState.IsValid) { db.Route.Add(route); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Airplane_ID = new SelectList(db.Airplane, "Airplane_ID", "Plane_Type", route.Airplane_ID); return(View(route)); }
public void Delete(object Id) { try { T entityToDelete = dbSet.Find(Id); dbSet.Remove(entityToDelete); dbEntites.SaveChanges(); } catch (Exception ex) { throw; } }
public ActionResult Add(UserInfo us) { myContext.UserInfo.Add(us); int result = myContext.SaveChanges(); if (result > 0) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Add")); } }
/// <summary> /// 根据员工id删除该员工权限 /// </summary> /// <param name="_id"></param> /// <returns></returns> public bool DelPerByEmID(int?_id) { List <Employee_PermissionInfo> emlist = t.Employee_PermissionInfo.Where(a => a.EmployeeId == _id).ToList(); foreach (var item in emlist) { t.Employee_PermissionInfo.Remove(item); } return(t.SaveChanges() > 0); }
public ActionResult Create([Bind(Include = "Id,UserId,SongId,AlbumId,TrackId,ArtistId,Text,Rating,Type,Cdate")] Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AlbumId = new SelectList(db.Albums, "album_id", "album_engineer", comment.AlbumId); ViewBag.ArtistId = new SelectList(db.Artists, "artist_id", "artist_active_year_end", comment.ArtistId); ViewBag.TrackId = new SelectList(db.Tracks, "track_id", "license_title", comment.TrackId); ViewBag.UserId = new SelectList(db.Users, "Id", "Username", comment.UserId); return(View(comment)); }
public ActionResult Create([Bind(Include = "ProjectID,ProjectName,ProjectDescription,Projectstatus,StartDate,endData,price")] Project project) { project.Projectstatus = 0; project.StartDate = DateTime.Now.ToString(); project.endData = "0 - 0 - 0"; project.price = 0; if (ModelState.IsValid) { db.projects.Add(project); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult regester(string UserEmail, string UserFirstName, string UserLasttName, string UserPhone, string UserRole, string UserPassword) { User user = new User(); user.UserEmail = UserEmail; user.UserPassword = UserPassword; user.UserRole = UserRole; user.UserLasttName = UserLasttName; user.UserFirstName = UserFirstName; user.NumOFProject = 0; user.Qualifications = " "; user.UserExpirienceYears = 0; user.UserJob_description = ""; user.UserPhoto = "~/ Content / 4.jpg"; user.UserPhone = UserPhone; db.users.Add(user); db.SaveChanges(); User user1 = db.users.SingleOrDefault(u => u.UserEmail == UserEmail && u.UserPassword == UserPassword && u.UserRole == UserRole); Session["userId"] = user1.UserId; if (UserRole == "cm") { return(RedirectToAction("CustomerProfile", "Users", new { id = Session["userId"] })); } if (UserRole == "pm") { return(RedirectToAction("PMHome", "Users", new { id = Session["userId"] })); } if (UserRole == "tl") { return(RedirectToAction("TeamLeaderProfile", "Users", new { id = Session["userId"] })); } if (UserRole == "admin") { return(RedirectToAction("AdminProfile", "Users", new { id = Session["userId"] })); } else if (UserRole == "jd") { return(RedirectToAction("JonurDeveloperProfile", "Users", new { id = Session["userId"] })); } else { return(View("Index")); } }
public ActionResult Attend(int?movieId, int?count, string phone, int?time) { //// make argument like JSON and pass json parameter from Jquery post string test = "false"; using (testEntities _context = new testEntities()) { UserMovie userMovie = new UserMovie(); userMovie.MovieId = movieId; userMovie.PurchaseCount = count; userMovie.PhoneNumber = phone; userMovie.MovieTime = time; _context.UserMovie.Add(userMovie); Movie Movie = _context.Movie.Where(x => x.MovieId == movieId).FirstOrDefault(); int? value = 0; value = Movie.Available - count; //value--; test = value.ToString(); Movie.Available = value; _context.SaveChanges(); } //Json data return(Json(test)); // return null; }
public ActionResult Register(userViewModel userInfo, HttpPostedFileBase file) { if (ModelState.IsValid) { string vCode = Request.Form["txtverifcode1"]; if (vCode != Session["ValidateCode"].ToString()) { return(Content("<script>;alert('验证码错误!');history.go(-1)</script>")); } var user = myContext.UserInfo.Where(u => u.UName == userInfo.Uname).FirstOrDefault(); if (user != null) { return(Content("<script>;alert('用户名已被占用!');history.go(-1)</script>")); } UserInfo userNew = new UserInfo(); userNew.UID = userInfo.Uid; userNew.UName = userInfo.Uname; userNew.UPassWord = userInfo.UPassWord; myContext.UserInfo.Add(userNew); myContext.SaveChanges(); return(Content("<script>;alert('注册成功!正在跳转到首页..');window.location.href='/Home/Index'</script>")); } else { return(View()); } }
/// <summary> /// 添加工资发放记录 /// </summary> /// <param name="_sr"></param> /// <returns></returns> public bool AddPayRecord(SalaryRecord _sr) { testEntities t = new testEntities(); t.SalaryRecord.Add(_sr); return(t.SaveChanges() > 0); }
public ActionResult Delete(TwitterClone.Models.Person objItem) { //SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConString"]); //SqlCommand cmd = new SqlCommand(); //string Query = @"Update person set active=0 where user_id = @user_Id"; //cmd = new SqlCommand(Query, con); //cmd.Parameters.AddWithValue("@user_Id", objItem.user_id); //con.Open(); //cmd.ExecuteNonQuery(); //con.Close(); testEntities dbPersonEntity = new testEntities(); var empQuery = from person in dbPersonEntity.People where person.user_Id == objItem.user_id select person; Person objPerson = empQuery.Single(); objPerson.user_Id = objItem.user_id; objPerson.active = false; dbPersonEntity.SaveChanges(); return(View("TweetsView")); }
public void ExcelToImg(string ExcelPath, string excelid) { testEntities db = new testEntities(); LicenseHelper.ModifyInMemory.ActivateMemoryPatching(); Workbook book = new Workbook(ExcelPath); var list = book.Worksheets; foreach (var item in list) { item.PageSetup.LeftMargin = 0; item.PageSetup.RightMargin = 0; item.PageSetup.BottomMargin = 0; item.PageSetup.TopMargin = 0; ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png; imgOptions.OnePagePerSheet = true; imgOptions.PrintingPage = PrintingPageType.IgnoreBlank; SheetRender sr = new SheetRender(item, imgOptions); string guid = System.Guid.NewGuid().ToString(); string RelativePath = $@"/Upload/Sopimg/{guid}.png";//相对路径 string filepath = Server.MapPath(RelativePath); sr.ToImage(0, filepath); db.Sop_Img.Add(new Sop_Img() { imgid = excelid, imgpath = RelativePath }); db.SaveChanges(); } }
public ActionResult Sopinfo(string name, HttpPostedFileBase file) { TempData["msg"] = "error"; testEntities db = new testEntities(); if (file != null && file.FileName != "") { var guid = System.Guid.NewGuid(); string filetype = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1); //获取后缀名 string RelativePath = $@"/Upload/SopExcel/{guid.ToString()}.{filetype}"; //相对路径 string path = Server.MapPath(RelativePath); var SopExcel = new Sop_Excel() { id = guid, excelname = name, excelpath = RelativePath, addtime = DateTime.Now, }; db.Sop_Excel.Add(SopExcel); db.SaveChanges(); file.SaveAs(path); ExcelToImg(path, SopExcel.id.ToString()); TempData["msg"] = "success"; return(View(db.Sop_Excel.ToList())); } return(View(db.Sop_Excel.ToList())); }
public void DoubleValuesNonEnglish() { CultureInfo curCulture = Thread.CurrentThread.CurrentCulture; CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture; CultureInfo newCulture = new CultureInfo("da-DK"); Thread.CurrentThread.CurrentCulture = newCulture; Thread.CurrentThread.CurrentUICulture = newCulture; try { using (testEntities context = new testEntities()) { Child c = new Child(); c.EmployeeID = 1; c.FirstName = "Bam bam"; c.LastName = "Rubble"; c.BirthWeight = 8.65; c.Modified = DateTime.Now; context.AddToChildren(c); context.SaveChanges(); } } finally { Thread.CurrentThread.CurrentCulture = curCulture; Thread.CurrentThread.CurrentUICulture = curUICulture; } }