private void Buttonz_Click(object sender, RoutedEventArgs e) { string account_ = AccountTextBox.Text; string password_ = PasswordTextBox.Text; if (account_ == "" || account_ == null || password_ == "" || password_ == null) { add_fail(); return; } // SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DormEntities"].ConnectionString.ToString()); var c = new DormEntities(); var q = from t in c.AdminTable select t; int count = q.Count(); AdminTable adminTable = new AdminTable { Id = count + 1, account = account_, password = password_ }; c.AdminTable.Add(adminTable); c.SaveChanges(); showAdmin(); add_ok(); }
protected void btnLogin_Click(object sender, EventArgs e) { String user = txtUsername.Text; String pass = txtPassword.Text; AdminModel model = new AdminModel(); AdminTable info = new AdminTable(); info = model.GetUserInfoByUserName(user); if (info != null) { if (info.Password == pass) { Session["id"] = info.GUID; Session["role"] = "admin"; Response.Redirect("~/Pages/Index.aspx"); } else { litStatus.Text = "Invalid Password"; } } else { litStatus.Text = "Invalid Username"; } }
public ActionResult Create(AdminTable adminTable, HttpPostedFileBase KategoriFoto) { try { if (KategoriFoto != null) { WebImage image = new WebImage(KategoriFoto.InputStream); FileInfo imageInfo = new FileInfo(KategoriFoto.FileName); string newfoto = Guid.NewGuid().ToString() + imageInfo.Extension; image.Resize(800, 350); image.Save("~/Upload/KategoriPhoto/" + newfoto); adminTable.KategoriFoto = "/Upload/KategoriPhoto/" + newfoto; } db.AdminTable.Add(adminTable); db.SaveChanges(); return(RedirectToAction("Index")); } catch { ViewBag.Id = new SelectList(db.AdminTable, "Id", "KategoriAdi"); ViewBag.Basarisiz = "Kategori Eklenemedi !!!"; return(View()); } }
public ActionResult Autherize(AdminTable adminModel) { using (DbModels dbModel = new DbModels()) { var adminDetails = dbModel.AdminTables.Where(x => x.Email == adminModel.Email && x.Password == adminModel.Password).FirstOrDefault(); if (adminDetails == null) { adminModel.LoginErrorMessage = "Wrong email or password"; return(View("AdminLogin", adminModel));; } else { Session["adminId"] = adminDetails.AdminId; Session["FirstName"] = adminDetails.FirstName; return(RedirectToAction("AdminHomeView", "AdminHome")); } // dbModel.UserTables.Add(userModel); // dbModel.SaveChanges(); } // ModelState.Clear(); //ViewBag.SuccessMessage = "Success!"; // return View(); }
public ActionResult AddAdmin() { string phone = Request["phone"]; string password = Request["password"]; using (var context = new AllUserModel()) { var q = from t1 in context.AdminTable where t1.phone == phone select t1; if (q.Count() != 0) { Response.Write("<script>alert('手机号已经被注册');</script>"); return(View("Create")); } AdminTable myadmin = new AdminTable() { phone = phone, password = password }; try { context.AdminTable.Add(myadmin); context.SaveChanges(); Response.Write("<script>alert('注册成功');</script>"); return(View("Create")); } catch (Exception e) { Response.Write("<script>alert('" + e.Message + "');</script>"); return(View("Create")); } } }
private void FormClientTable(int pInput) { AdminTable.Clear(); AdminViewHelper admViewHelper = new AdminViewHelper(); string input = admViewHelper.GetClientData(pInput); AdminTable.View = View.Details; AdminTable.GridLines = true; AdminTable.FullRowSelect = true; AdminTable.Columns.Add("Flight ID", 100); AdminTable.Columns.Add("From", 100); AdminTable.Columns.Add("To", 100); AdminTable.Columns.Add("Cost", 100); AdminTable.Columns.Add("Booked", 100); AdminTable.Columns.Add("Spent Time", 100); AdminTable.Columns.Add("Num. of views", 100); AdminTable.Columns.Add("Last view date", 150); string[] arr = new string[10]; ListViewItem itm; string[] words = input.Split(';'); for (int itr = 0; itr < words.Length - 1; itr += 8) { for (int initr = 0; initr < 8; initr++) { arr[initr] = words[initr + itr]; } itm = new ListViewItem(arr); AdminTable.Items.Add(itm); } }
public void InsertUserInformation(AdminTable info) { ModelDataContext db = new ModelDataContext(); db.AdminTables.InsertOnSubmit(info); db.SubmitChanges(); }
public void ForAdd(string ticker) { string tableName = "tlb_" + ticker + "Log"; using (SqlConnection con = new SqlConnection(connectString)) { string myQuery = @"select case when exists((select * from mydb.INFORMATION_SCHEMA.TABLES where TABLE_NAME = '" + tableName + @"' )) then 1 else 0 end"; try { SqlCommand command = new SqlCommand(myQuery, con); con.Open(); int result = (Int32)command.ExecuteScalar(); //Console.WriteLine(result); con.Close(); if (result == 1) { return; } // return true; else { Console.WriteLine("Creating new tables for the new stock."); AdminTable adTb = new AdminTable(); adTb.Create(ticker); } } catch (SqlException ex) { Console.WriteLine("SQL Error " + ex.Message.ToString()); // return false; } } }
public void RemoveAdmin(long Id) { var admin = AdminTable.Where(x => x.UserId == Id).ToList(); AdminTable.RemoveRange(admin); SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { AdminTable adminTable = db.AdminTables.Find(id); db.AdminTables.Remove(adminTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public AdminTable GetUserInfoByEmail(String email) { ModelDataContext db = new ModelDataContext(); AdminTable info = (from x in db.AdminTables where x.Email == email select x).FirstOrDefault(); return(info); }
public AdminTable GetUserInfoByUserName(String username) { ModelDataContext db = new ModelDataContext(); AdminTable info = (from x in db.AdminTables where x.Username == username select x).FirstOrDefault(); return(info); }
public AdminTable GetUserInfoByGUID(String guID) { ModelDataContext db = new ModelDataContext(); AdminTable info = (from x in db.AdminTables where x.GUID == guID select x).FirstOrDefault(); return(info); }
public void AddAdmin(Admin admin) { try { AdminTable.Add(admin); SaveChanges(); } catch (MySqlException e) when(e.Message == "Field 'Id' doesn't have a default value") { Console.WriteLine("Write to the database is not possible, disable Strict SQL mode"); } }
public IHttpActionResult loginvalid(AdminTable log) { var a = (from n in db.AdminTables where n.AdminId == log.AdminId && n.AdminPassword == log.AdminPassword && n.AdminName == log.AdminName select n).FirstOrDefault(); if (a == null) { return(NotFound()); } return(Ok(a)); }
public ActionResult Edit([Bind(Include = "Admin_ID,Admin_Name,Admin_Password,DateOfBirth,Admin_Contact")] AdminTable adminTable) { if (ModelState.IsValid) { db.Entry(adminTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminTable)); }
public ActionResult Create([Bind(Include = "Admin_ID,Admin_Name,Admin_Password,DateOfBirth,Admin_Contact")] AdminTable adminTable) { if (ModelState.IsValid) { db.AdminTables.Add(adminTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminTable)); }
public bool AddCustomer(AdminTable entity) { if (entity != null) { //dbcontext.AdminTables.Add(entity); dbcontext.SaveChanges(); return(true); } else { return(false); } }
// GET: AdminTables/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AdminTable adminTable = db.AdminTables.Find(id); if (adminTable == null) { return(HttpNotFound()); } return(View(adminTable)); }
//add new admin public void AddAdmin(string userName, string password, string fullName, string birthDate, string age, string email, string contactNo, string cityName) { AdminTable at = new AdminTable(); at.UserName = userName; at.Password = password; at.FullName = fullName; at.Birthdate = birthDate; at.Age = age; at.Email = email; at.ContactNo = contactNo; at.CityName = cityName; context.AdminTables.InsertOnSubmit(at); context.SubmitChanges(); }
public ActionResult Delete(int id) { try { AdminTable adminTable = db.AdminTable.Find(id); db.AdminTable.Remove(adminTable); db.SaveChanges(); return(RedirectToAction("Index")); } catch { ViewBag.Basarisiz = "Silme işlemi başarısız oldu !!"; return(View()); } }
public ActionResult SignUp(AdminTable admin) { try { // TODO: Add insert logic here admin.AdminPassword = getHash(admin.AdminPassword); db.Admins.Add(admin); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
public ActionResult Index(string Username, string Password) { AdminTable user = af.Login(Username, Password); if (user.Username != null) { Session["id"] = user.ID; Session["role"] = user.Role; return(Redirect("/CMS/")); } else { ViewBag.Msg = "<b>Forkert login</b>"; return(View()); } }
public ActionResult Admin_DangNhap(string txtTaiKhoan, string txtMatKhau) { AdminTable ad = db.AdminTables.SingleOrDefault(t => t.TaiKhoan == txtTaiKhoan && t.MatKhau == txtMatKhau); if (ad != null) { HttpCookie maAD = new HttpCookie("MaAd", ad.MaAdmin.ToString()); HttpCookie tenAD = new HttpCookie("TenAd", ad.TenHienThi.ToString()); maAD.Expires.AddDays(10); tenAD.Expires.AddDays(10); Response.Cookies.Set(maAD); Response.Cookies.Set(tenAD); return(RedirectToAction("Index")); } ViewBag.ThongBao = "Sai tài khoản hoặc mật khẩu!"; return(View()); }
public ActionResult AdminLogin(AdminTable user1) { //var userexists = usr.GraduateDetails.FirstOrDefault(t => t.email == user1.email && t.password1==user1.password1); //var userexists = usr.AdminTables.FirstOrDefault(t => t.email == user1.email && t.password1 == user1.password1); var userexists = usr.AdminTables.FirstOrDefault(t => t.email == user1.email && t.password1 == user1.password1); if (userexists != null) { Session["uname"] = user1.email; return(RedirectToAction("AdminLoginSuccessfull")); } else { return(View()); } }
protected void Button1_Click(object sender, EventArgs e) { if ((txtPassword.Text).Equals(txtConfrmPassword.Text)) { AdminModel model = new AdminModel(); AdminTable info = new AdminTable(); Guid g = Guid.NewGuid(); info.GUID = g.ToString(); info.FirstName = txtFirstname.Text; info.LastName = txtLastName.Text; info.Username = txtUsername.Text; info.Password = txtPassword.Text; info.Email = txtEmail.Text; model.InsertUserInformation(info); litStatus.Text = "Registration Successful"; } else { litStatus.Text = "Both password should be same"; } }
public ActionResult Details(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AdminTable adminTable = db.AdminTable.Find(id); if (adminTable == null) { return(HttpNotFound()); } return(View(adminTable)); } catch { ViewBag.Basarisiz = "Detaylar sayfası yüklenmedi !!!"; return(View()); } }
public ActionResult Edit(int id, HttpPostedFileBase kategoriFoto, AdminTable adminTable, AdminTable oldTable) { try { var EditKategori = db.AdminTable.Where(m => m.Id == id).SingleOrDefault(); if (kategoriFoto != null) { if (System.IO.File.Exists(Server.MapPath(EditKategori.KategoriFoto))) { System.IO.File.Delete(Server.MapPath(EditKategori.KategoriFoto)); } WebImage image = new WebImage(kategoriFoto.InputStream); FileInfo imageInfo = new FileInfo(kategoriFoto.FileName); string newfoto = Guid.NewGuid().ToString() + imageInfo.Extension; image.Resize(800, 350); image.Save("~/Upload/KategoriFoto/" + newfoto); EditKategori.KategoriFoto = "/Upload/KategoriFoto/" + newfoto; } EditKategori.KategoriAdi = oldTable.KategoriAdi; EditKategori.Dolar = oldTable.Dolar; EditKategori.Dinar = oldTable.Dinar; EditKategori.TransferMiktari = oldTable.TransferMiktari; EditKategori.Kargo = oldTable.Kargo; EditKategori.Nakliye = oldTable.Nakliye; EditKategori.Katki = oldTable.Katki; db.SaveChanges(); return(RedirectToAction("Index")); } catch { ViewBag.CategoryId = new SelectList(db.AdminTable, "Id", "kategoriAdi", oldTable.Id); ViewBag.Basarisiz = "Güncelleme işlemi başarısız oldu !!"; return(View(oldTable)); } }
/// <summary> /// 更新一条数据 /// </summary> public void UpdateAdminTable(AdminTable entity) { linqHelper.UpdateEntity <AdminTable>(entity); }
/// <summary> /// 增加一条数据 /// </summary> public void AddAdminTable(AdminTable entity) { linqHelper.InsertEntity <AdminTable>(entity); }