public async Task <IHttpActionResult> Update(int loaiTaiKhoanID, [FromBody] LoaiTaiKhoan loaiTaiKhoan) { if (loaiTaiKhoan.LoaiTaiKhoanID != loaiTaiKhoanID) { return(BadRequest("Id mismatch")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (var db = new ApplicationDbContext()) { db.Entry(loaiTaiKhoan).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ducEx) { bool exists = db.LoaiTaiKhoan.Count(o => o.LoaiTaiKhoanID == loaiTaiKhoanID) > 0; if (!exists) { return(NotFound()); } else { throw ducEx; } } return(Ok(loaiTaiKhoan)); } }
public TaiKhoan(int matk, string mail, string matkhau, LoaiTaiKhoan loai, int maLoaiTaiKhoan, string Ten, DateTime ngaysinh, string diachi, string dienthoai, DateTime ngaydk, TrangThaiTaiKhoan trangthai, int maTrangThai) { this.maTaiKhoan = matk; this.email = mail; this.matKhau = matkhau; this.loaiTaiKhoan = loai; this.maLoaiTaiKhoan = maLoaiTaiKhoan; this.ten = Ten; this.ngaySinh = ngaysinh; this.diaChi = diachi; this.dienThoai = dienthoai; this.ngayDangKy = ngaydk; this.trangThai = trangthai; this.maTrangThai = maTrangThai; }
public ActionResult DeleteConfirmed(decimal id) { LoaiTaiKhoan loaiTaiKhoan = db.LoaiTaiKhoans.Find(id); db.LoaiTaiKhoans.Remove(loaiTaiKhoan); db.SaveChanges(); return(RedirectToAction("Index")); }
public string GetTenLoaiTaiKhoan(string tenDangNhap) { NhanVien nv = qlcf.NhanViens.Where(tdn => tdn.TenDangNhap == tenDangNhap).FirstOrDefault(); string maLoaiTaiKhoan = nv.MaLoaiTaiKhoan; LoaiTaiKhoan ltk = qlcf.LoaiTaiKhoans.Where(mltk => mltk.MaLoaiTaiKhoan == maLoaiTaiKhoan).FirstOrDefault(); return(ltk.TenLoaiTaiKhoan.ToString()); }
public async Task <IActionResult> CreatePost(LoaiTaiKhoan model) { model.LoaiTaiKhoanId = RandomString.GenerateRandomString(_context.LoaiTaiKhoan.Select(o => o.LoaiTaiKhoanId)); await _context.AddAsync(model); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "LoaiTaiKhoanId,TenLoaiTaiKhoan")] LoaiTaiKhoan loaiTaiKhoan) { if (ModelState.IsValid) { db.Entry(loaiTaiKhoan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiTaiKhoan)); }
public ActionResult Create([Bind(Include = "LoaiTaiKhoanId,TenLoaiTaiKhoan")] LoaiTaiKhoan loaiTaiKhoan) { if (ModelState.IsValid) { db.LoaiTaiKhoans.Add(loaiTaiKhoan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiTaiKhoan)); }
public int AddNew(LoaiTaiKhoan obj) { var result = context.LoaiTaiKhoans.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdLoaiTaiKhoan); } return(-1); }
protected override void ShowObjectInformation() { item = UserServices.GetById(LongId); ViewState["CurrentObject"] = item; HoTen.Text = item.FullName; DonVi.SelectByValue(item.DepartmentID); TenTaiKhoan.Text = item.UserName; ChucVu.Text = item.Position; LoaiTaiKhoan.SelectByValue(item.Role); //ThuTuHienThi.Text = item.DisplayOrder.ToString(); ConSuDung.Checked = item.IsActive; }
public List <LoaiTaiKhoan> LayDSLoaiTK() { List <LoaiTaiKhoan> list = new List <LoaiTaiKhoan>(); string query = "SELECT * FROM dbo.LoaiTK"; DataTable data = DataProvider.Instance.ExcuteQuery(query); foreach (DataRow item in data.Rows) { LoaiTaiKhoan dsLoaiTK = new LoaiTaiKhoan(item); list.Add(dsLoaiTK); } return(list); }
public TaiKhoan() { this.maTaiKhoan = 0; this.email = ""; this.matKhau = ""; this.loaiTaiKhoan = 0; this.ten = ""; this.ngaySinh = DateTime.Now; this.diaChi = ""; this.dienThoai = ""; this.ngayDangKy = DateTime.Now; this.trangThai = 0; this.maLoaiTaiKhoan = 0; }
public bool Update(LoaiTaiKhoan obj) { var sp = context.LoaiTaiKhoans.SingleOrDefault(x => x.IdLoaiTaiKhoan == obj.IdLoaiTaiKhoan); if (sp != null) { sp.LoaiTaiKhoan1 = obj.LoaiTaiKhoan1; context.SaveChanges(); return(true); } return(false); }
public async Task <IHttpActionResult> Insert([FromBody] LoaiTaiKhoan loaiTaiKhoan) { if (loaiTaiKhoan.LoaiTaiKhoanID != 0) { return(BadRequest("Invalid LoaiTaiKhoanID")); } using (var db = new ApplicationDbContext()) { db.LoaiTaiKhoan.Add(loaiTaiKhoan); await db.SaveChangesAsync(); } return(Ok(loaiTaiKhoan)); }
private void btnSua_Click(object sender, EventArgs e) { LoaiTaiKhoan accountType = db.LoaiTaiKhoans.Find(int.Parse(txtId.Text)); accountType.TenLoaiTaiKhoan = txtTen.Text; try { db.SaveChanges(); MessageBox.Show("Cập nhật thành công"); LoadDtgv(); } catch (Exception) { MessageBox.Show("Cập nhật không thành công. Vui lòng kiểm tra lại"); } }
private void btnThem_Click(object sender, EventArgs e) { LoaiTaiKhoan accountType = new LoaiTaiKhoan(); accountType.TenLoaiTaiKhoan = txtTen.Text; try { db.LoaiTaiKhoans.Add(accountType); db.SaveChanges(); MessageBox.Show("Thêm mới thành công"); LoadDtgv(); } catch (Exception) { MessageBox.Show("Thêm mới không thành công. Vui lòng kiểm tra lại"); } }
// GET: LoaiTaiKhoan/Edit/5 public ActionResult Edit(decimal id) { if (!UserManager.Authenticated) { return(RedirectToAction("Login", "Admin")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LoaiTaiKhoan loaiTaiKhoan = db.LoaiTaiKhoans.Find(id); if (loaiTaiKhoan == null) { return(HttpNotFound()); } return(View(loaiTaiKhoan)); } }
private void btnXoa_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Bạn có chắc chắn muốn xóa", "Xác nhận!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { LoaiTaiKhoan accountType = db.LoaiTaiKhoans.Find(int.Parse(txtId.Text)); try { db.LoaiTaiKhoans.Remove(accountType); db.SaveChanges(); MessageBox.Show("Xóa thành công"); LoadDtgv(); } catch (Exception) { MessageBox.Show("Tồn tại Máy tính trong danh mục này"); } } }
public void AddToLoaiTaiKhoans(LoaiTaiKhoan loaiTaiKhoan) { base.AddObject("LoaiTaiKhoans", loaiTaiKhoan); }
public static LoaiTaiKhoan CreateLoaiTaiKhoan(int maLoaiTK) { LoaiTaiKhoan loaiTaiKhoan = new LoaiTaiKhoan(); loaiTaiKhoan.MaLoaiTK = maLoaiTK; return loaiTaiKhoan; }
public bool LuuLoaiTK(LoaiTaiKhoan LoaiTaiKhoan) { db.LoaiTaiKhoans.Add(LoaiTaiKhoan); db.SaveChanges(); return(true); }
protected override void SetDefaultValueOnCreate() { LoaiTaiKhoan.SelectByValue(UserRole.ChuyenVienVP); ConSuDung.Checked = true; }