public ActionResult EnrollInClasses(List <SelectListItem> list) { string value = Request.Form["EnrollInClasses"].ToString(); var entities = new Entities1(); entities.Database.Connection.Open(); var loggedInUser = (User)Session["User"]; var user = entities.Users.FirstOrDefault(t => t.UserEmail.ToLower() == loggedInUser.UserEmail.ToLower() && t.UserPassword == loggedInUser.UserPassword); var val = Int32.Parse(value); var cls = entities.Classes.FirstOrDefault(t => t.ClassId == val); user.Classes.Add(cls); entities.SaveChanges(); return(View()); }
public bool Add(Client st, string id) { try { st.Id_user = id; _entities.Client.Add(st); _entities.SaveChanges(); logger.Debug("Добавление информации клиента"); } catch (System.ServiceModel.CommunicationException ex) { logger.Error("Ошибка: ", ex); return(false); } return(true); }
public ActionResult SignUpView(Registration mymodelSignUp) { ActionResult myaction = RedirectToAction("VenderActionIndex", "Vendor"); try { //regform.name = mymodelSignUp.name; //regform.email = mymodelSignUp.email; //regform.address = mymodelSignUp.address; //regform.cellNo = mymodelSignUp.cellNo //regform.password = mymodelSignUp.password; //regform.userType = mymodelSignUp.userType //regform.time = Convert.ToString(DateTime.Now.Date); //if (mymodelSignUp.userType == "Vendor") //{ // regform.isActive = false; //} //else //{ // regform.isActive = true; //} //#region Save Image on Server string FileName = Path.GetFileNameWithoutExtension(mymodelSignUp.Image_new.FileName); string Extension = Path.GetExtension(mymodelSignUp.Image_new.FileName); FileName = FileName + DateTime.Now.ToString("yymmssff") + Extension; mymodelSignUp.Image = "~/Pictures/" + FileName; FileName = Path.Combine(Server.MapPath("~/Pictures/"), FileName); mymodelSignUp.Image_new.SaveAs(FileName); db.Registrations.Add(mymodelSignUp); db.SaveChanges(); myaction = RedirectToAction("VenderActionIndex", "Vendor", mymodelSignUp); } catch (Exception ex) { Response.Write(ex.Message); } return(myaction); }
public bool Add(Mediabuiner st, string id) { try { var currentUser = new Entities1().AspNetUsers.Where(n => n.Id.Equals(id)).FirstOrDefault(); st.Id_user = currentUser.Id; st = _entities.Mediabuiner.Add(st); _entities.SaveChanges(); logger.Debug("Добавлен"); } catch (System.ServiceModel.CommunicationException ex) { logger.Error("Ошибка: ", ex); return(false); } return(true); }
private void OkButton_OnClick(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(StopName.Text) && !string.IsNullOrEmpty(LineName.Text)) { BSV = new BusStopView(StopName.Text, LineName.Text, Direction.Text); var id = NewFavoriteStop.GetStationIdFromName(StopName.Text); if (MainWindow.loggedInBenutzer != null) { BenutzerHaltestellen bh = new BenutzerHaltestellen() { Benutzer_ID = MainWindow.loggedInBenutzer.Benutzer_ID, Haltestellen_ID = id, Linie = LineName.Text, Richtung = Direction.Text }; dbEntities.BenutzerHaltestellens.Add(bh); dbEntities.SaveChanges(); } } }
public ActionResult DeleteConfirmed(int id) { InScanMaster a = db.InScanMasters.Find(id); if (a == null) { return(HttpNotFound()); } else { a.IsDeleted = true; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully deleted Pickup Request."; return(RedirectToAction("Index")); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || tbNewPassword.Text == "" || tbConfirmPassword.Text == "" || tbNewPassword.Text != tbConfirmPassword.Text) { MessageBox.Show("Please input field! Verify New Password and Confirm Password is the same!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { Entities1 mdl = new Entities1(); mdl.Connection.Open(); user user = new user(); user.user_name = textBox1.Text; user.user_password = tbNewPassword.Text; user.created_by = Global.GlobalVar; user.created_date = DateTime.Now; user.updated_by = Global.GlobalVar; user.updated_date = DateTime.Now; user.user_address = ""; user.user_birth_date = DateTime.Now; user.user_birth_place = ""; user.user_email = ""; user.user_first_name = ""; user.user_last_name = ""; user.user_last_login = DateTime.Parse("01/01/1970"); user.user_phone_number = ""; user.user_photo_file = ""; user.user_social_number = ""; user.user_marital_status = ""; user.user_gender = ""; user.user_group_id = 1; mdl.AddTousers(user); mdl.SaveChanges(); mdl.Connection.Close(); MessageBox.Show("Success Add New User", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Loading(); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.InnerException + " " + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public ActionResult AddStudent(Student_Affairs.Models.Student request) { if (Session["UserID"] != null) { if (ModelState.IsValid) { db.Students.Add(request); db.SaveChanges(); ModelState.Clear(); return(View()); } return(View(request)); } else { return(RedirectToAction("../Login/Index")); } }
public JsonResult DeleteEvent(int eventID) { bool status = false; using (Entities1 dc = new Entities1()) { var v = dc.WorkerSchedules.Where(a => a.EventID.Equals(eventID)).FirstOrDefault(); if (v != null) { dc.WorkerSchedules.Remove(v); dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }
public void Update_News(News x) { var obj = new List <News>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.News where t.MatchId == x.MatchId select t).ToList(); obj[0].NewsDescription = x.NewsDescription; entity.SaveChanges(); } catch (Exception e) { throw (e); } }
public int Add_News(News s) { try { Entities1 entity = new Entities1(); News st = new News() { MatchId = s.MatchId, NewsDescription = s.NewsDescription }; entity.News.Add(st); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(1); }
public bool SendChangePersonInfoToDB(PersonInfo personInfo) { try { Entities1 dbContext = new Entities1(); var userInfo = dbContext.USERINFO.Where(x => x.NICKNAME == personInfo.UserNickName).ToList().First(); userInfo.PASSWORD = personInfo.PassWord; userInfo.MACADDRESS = personInfo.MacAddress; var num = dbContext.SaveChanges(); if (num == 1) { return(true); } } catch { } return(false); }
protected void Terminar_Orden(object sender, EventArgs e) { Button btn = (Button)sender; int idOrden = Int32.Parse(btn.CommandArgument); using (var db = new Entities1()) { Ordene orden = db.Ordenes.Where(x => x.Id == idOrden).First(); OrdenesEstado oe = new OrdenesEstado(); oe.fecha = DateTime.Now; oe.estado_id = 4; orden.OrdenesEstados.Add(oe); db.SaveChanges(); } Response.Redirect("~/Mecanico/Ordenes.aspx"); }
public void Delete(int id) { var query = from c in _entities.application where c.Id == id select c; foreach (application app in query) { app.status = "This application is stopped"; } try { _entities.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); // Provide for exceptions. } }
private void customerDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { try { context.SaveChanges(); OnLogableEvent("Saved Changes to customer!\n"); } catch (Exception er) { OnLogableEvent("Error saving updates!!! Please exit: your data may be invalid\n " + er); throw; } } catch (Exception) { OnLogableEvent("oops" + this.Name); } }
protected void Guardar(object sender, EventArgs e) { int cantidad; if (Int32.TryParse(txtCantidad.Text, out cantidad)) { using (var db = new Entities1()) { int id = Int32.Parse(lblId.Text); Producto p = db.Productos.Where(x => x.Id == id).FirstOrDefault(); if (p != null) { p.stock += cantidad; db.SaveChanges(); } } } }
public async Task <ActionResult> Edit([Bind(Include = "Id,ClaimType,ClaimValue,Card_id, published")] CARD_CLAIMS cARD_CLAIMS) { if (ModelState.IsValid) { var claims = db.CARD_CLAIMS.Where(c => c.ClaimValue == cARD_CLAIMS.ClaimValue).ToList(); foreach (var i in claims) { CARD_CLAIMS cc = db.CARD_CLAIMS.Find(i.Id); cc.published = cARD_CLAIMS.published; db.Entry(cc).State = EntityState.Modified; db.SaveChanges(); } //db.Entry(cARD_CLAIMS).State = EntityState.Modified; //await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Card_id = new SelectList(db.cards, "Id", "text", cARD_CLAIMS.Card_id); return(View(cARD_CLAIMS)); }
public List <Match> SelectAll_Ticket() { var obj = new List <Match>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.Matches select t).ToList(); entity.SaveChanges(); } catch (Exception ex) { throw (ex); } return(obj); }
public void insert_Customer_Ticket(Ticket t) { try { Entities1 entity = new Entities1(); Ticket ticket = new Ticket() { MatchId = t.MatchId, TicketCategoryId = t.TicketCategoryId + 1, Price = t.Price, }; entity.Tickets.Add(ticket); entity.SaveChanges(); } catch (Exception ex) { throw (ex); } }
public ActionResult EditStudent(STUDENT a) { Entities1 context = new Entities1(); var data = context.STUDENTs.FirstOrDefault(x => x.STUDENT_ID == a.STUDENT_ID); data.ADDRESS = a.ADDRESS; data.AGE = a.AGE; data.COLLEGE_ID = a.COLLEGE_ID; data.COURSE = a.COURSE; data.DOA = a.DOA; data.DOB = a.DOB; data.EDUCATIONAL = a.EDUCATIONAL; data.F_NAME = a.F_NAME; data.M_NAME = a.M_NAME; data.NAME = a.NAME; data.COLLEGE = a.COLLEGE; data.STUDENT_ID = a.STUDENT_ID; context.SaveChanges(); return(RedirectToAction("DisplayStudent")); }
public List <Stat> SelectAll_Statistics() { var obj = new List <Stat>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.Stats select t).ToList(); entity.SaveChanges(); } catch (Exception ex) { throw (ex); } return(obj); }
public List <Schedule> SelectAll_Schedule() { var obj = new List <Schedule>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.Schedules select t).ToList(); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(obj); }
public int Add_Tc(TicketCategory s) { try { Entities1 entity = new Entities1(); TicketCategory st = new TicketCategory() { TicketCategoryId = s.TicketCategoryId, TicketCategoryName = s.TicketCategoryName, TicketDescription = s.TicketDescription }; entity.TicketCategories.Add(st); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(1); }
public List <TicketCategory> SelectAll_Tc() { var obj = new List <TicketCategory>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.TicketCategories select t).ToList(); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(obj); }
public ActionResult Update(TUser c) { string message = ""; bool status = false; if (ModelState.IsValid) { using (Entities1 dc = new Entities1()) { if (c.intUserID > 0) { var v = dc.TUsers.Where(a => a.intUserID.Equals(c.intUserID)).FirstOrDefault(); if (v != null) { v.strUserName = c.strUserName; v.strPassword = c.strPassword; } else { return(HttpNotFound()); } } else { dc.TUsers.Add(c); } dc.SaveChanges(); status = true; message = "Data Is Successfully Updated."; } } else { message = "Error! Please try again."; } return(new JsonResult { Data = new { status = status, message = message } }); }
private void button1_Click(object sender, EventArgs e) { if (tbOldPassword.Text.Trim() == "" || tbNewPassword.Text.Trim() == "" || tbConfirmPassword.Text.Trim() == "" || tbConfirmPassword.Text != tbNewPassword.Text) { MessageBox.Show("Please input field! Verify New Password and Confirm Password is the same!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tbOldPassword.Text = ""; tbNewPassword.Text = ""; tbConfirmPassword.Text = ""; tbOldPassword.Focus(); } else { Entities1 mdl = new Entities1(); mdl.Connection.Open(); using (MD5 md5Hash = MD5.Create()) { string hash = this.GetMd5Hash(md5Hash, tbOldPassword.Text); string hash2 = this.GetMd5Hash(md5Hash, tbNewPassword.Text); user login = mdl.sp_login_user(textBox1.Text, hash).FirstOrDefault(); if (login != null) { user access = (from c in mdl.users where c.user_name == textBox1.Text select c).FirstOrDefault(); access.user_password = hash2; mdl.SaveChanges(); MessageBox.Show("Success Change Password", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Username or Old Password Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tbOldPassword.Text = ""; tbNewPassword.Text = ""; tbConfirmPassword.Text = ""; tbOldPassword.Focus(); } } mdl.Connection.Close(); } }
public List <News> Search_News(int id) { var obj = new List <News>(); try { Entities1 PracticeEntities1 = new Entities1(); obj = (from t in PracticeEntities1.News where t.MatchId == id select t).ToList(); PracticeEntities1.SaveChanges(); } catch (Exception ex) { throw (ex); } return(obj); }
public List <News> Search_News(int id) { var obj = new List <News>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.News where t.MatchId == id select t).ToList(); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(obj); }
public List <Stat> Search_Statistics(int id) { var obj = new List <Stat>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.Stats where t.StatId == id select t).ToList(); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(obj); }
public List <Stat> Search_Stat(int id) { var obj = new List <Stat>(); try { Entities1 PracticeEntities1 = new Entities1(); obj = (from t in PracticeEntities1.Stats where t.TeamId == id select t).ToList(); PracticeEntities1.SaveChanges(); } catch (Exception ex) { throw (ex); } return(obj); }