public ActionResult NguoiVayTraNo(DateTime ngaytra, int sotientra, int loaitaikhoan) { TraNo tn = new TraNo(); tn.KhoanVay = Convert.ToInt32(Session["IdKhoanNo"]); tn.NgayTra = ngaytra; tn.SoTienTra = sotientra; tn.TaiKhoan = loaitaikhoan; int id = Convert.ToInt32(Session["IdKhoanNo"]); using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseAddress); //HTTP POST var postTask = client.PostAsJsonAsync <TraNo>("TraNo", tn); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("NguoiVayTraNo", new { @id = id })); } else { ModelState.AddModelError("", "Không thêm được!"); } } return(Redirect("~/Error/Error")); }
public IHttpActionResult Post_TraNo(TraNo tn) { if (dao.TraNo(tn) == false) { return(BadRequest()); } return(Ok()); }
public List <TraNo> LichSuTraNo(int id) { const string proc = "SP_LichSuTraNo"; List <SqlParameter> para = new List <SqlParameter>() { new SqlParameter("id", id) }; IDataReader reader = DataProvider.ExecuteReader(proc, para); List <TraNo> result = new List <TraNo>(); TraNo tn; while (reader.Read()) { tn = new TraNo(); tn.NgayTra = Convert.ToDateTime(reader["NgayTra"]); tn.SoTienTra = Convert.ToInt32(reader["SoTienTra"]); result.Add(tn); } return(result); }
public bool TraNo(TraNo tn) { const string proc = "SP_TraNo"; List <SqlParameter> para = new List <SqlParameter>() { new SqlParameter("khoanvay", tn.KhoanVay), new SqlParameter("ngaytra", tn.NgayTra), new SqlParameter("sotien", tn.SoTienTra), new SqlParameter("taikhoan", tn.TaiKhoan) }; int res = DataProvider.ExecuteNonQuery(proc, para); if (res > 0) { return(true); } else { return(false); } }