public async Task <IActionResult> Edit(int id, [Bind("ID,FullName,Birthday,Gender,Email,UserName,Password,DonViID")] ReportSLCLCBTheoDoTuoi reportSLCLCBTheoDoTuoi) { if (id != reportSLCLCBTheoDoTuoi.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reportSLCLCBTheoDoTuoi); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReportSLCLCBTheoDoTuoiExists(reportSLCLCBTheoDoTuoi.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(reportSLCLCBTheoDoTuoi)); }
public async Task <IActionResult> Create([Bind("ID,FullName,Birthday,Gender,Email,UserName,Password,DonViID")] ReportSLCLCBTheoDoTuoi reportSLCLCBTheoDoTuoi) { if (ModelState.IsValid) { _context.Add(reportSLCLCBTheoDoTuoi); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(reportSLCLCBTheoDoTuoi)); }
public List <ReportSLCLCBTheoDoTuoi> GetListSLCLCBTheoDoTuoi() { List <ReportSLCLCBTheoDoTuoi> lts = new List <ReportSLCLCBTheoDoTuoi>(); using (SqlConnection con = new SqlConnection(config.Value.myconn.ToString())) { var DenNgay = DateTime.Now; con.Open(); SqlCommand cmd = new SqlCommand("RP_SLCLCB", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@DenNgay", SqlDbType.DateTime).Value = DenNgay; cmd.CommandTimeout = 90; SqlDataAdapter adapter = new SqlDataAdapter(cmd); ReportSLCLCBTheoDoTuoi obj; DataSet ds = new DataSet(); adapter.Fill(ds); DataTable dt = ds.Tables[0]; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { obj = new ReportSLCLCBTheoDoTuoi(); obj.DonViID = dt.Rows[i]["ID"].ToString().Equals("") ? 0 : int.Parse(dt.Rows[i]["ID"].ToString()); obj.TenDonVi = dt.Rows[i]["TenDonVi"].ToString(); obj.TongSo = dt.Rows[i]["TongSo"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["TongSo"].ToString()); obj.PhuNu = dt.Rows[i]["PhuNu"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["PhuNu"].ToString()); obj.Nam = dt.Rows[i]["Nam"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Nam"].ToString()); obj.Total20den30 = dt.Rows[i]["Total20den30"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Total20den30"].ToString()); obj.Nam20den30 = dt.Rows[i]["Namtu20den30"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Namtu20den30"].ToString()); obj.Nu20den30 = dt.Rows[i]["Nutu20den30"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Nutu20den30"].ToString()); obj.Total30den50 = dt.Rows[i]["Total30den50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Total30den50"].ToString()); obj.Nam30den50 = dt.Rows[i]["Namtu30den50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Namtu30den50"].ToString()); obj.Nu30den50 = dt.Rows[i]["Nutu30den50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Nutu30den50"].ToString()); obj.Totaltren50 = dt.Rows[i]["Totaltren50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Totaltren50"].ToString()); obj.Namtren50 = dt.Rows[i]["Namtren50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Namtren50"].ToString()); obj.Nutren50 = dt.Rows[i]["Nutren50"].ToString().Equals("") ? (int?)null : int.Parse(dt.Rows[i]["Nutren50"].ToString()); lts.Add(obj); } } return(lts); } }