protected void gvDSDiary_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gvDSDiary.Rows[e.RowIndex]; TextBox maclaim = row.Cells[1].Controls[0] as TextBox; TextBox diengiai = row.Cells[3].Controls[0] as TextBox; TextBox ts = row.Cells[4].Controls[0] as TextBox; TextBox date = row.Cells[5].Controls[0] as TextBox; TextBox start = row.Cells[6].Controls[0] as TextBox; TextBox end = row.Cells[7].Controls[0] as TextBox; TextBox re = row.Cells[8].Controls[0] as TextBox; int ma = int.Parse(gvDSDiary.DataKeys[e.RowIndex].Value.ToString()); DiaryDTO dr = new DiaryDTO(); dr.MaDiary = ma; dr.MaClaim = maclaim.Text; dr.DienGiai = diengiai.Text; dr.SoGio = int.Parse(ts.Text); dr.Ngay = DateTime.Parse(date.Text); dr.NgayGioBatDau = DateTime.Parse(start.Text); dr.NgayGioKetThuc = DateTime.Parse(end.Text); dr.KetQua = re.Text; bool up = drdao.CapNhatDiary(dr); if (up == true) { e.Cancel = true; gvDSDiary.EditIndex = -1; loadDiaryAll(); } }
/// <inheritdoc /> public async Task UpdateEntry(DiaryDTO diary) { var entry = new Diary() { Title = diary.Title, Entries = diary.Entries, UserId = diary.UserId, Id = diary.Id, Date = DateTime.Now }; _diaryRepository.Update(entry); await _diaryRepository.SaveChangesAsync(); }
public void AddDiary(DiaryDTO diaryDto, HttpFileCollectionBase Files) { Diary diary = Mapper.Map <DiaryDTO, Diary>(diaryDto); _diaryRepository.Add(diary); List <string> fileNames = SaveFiles(Files); AddAttachments(_attachmentRepository, diary, fileNames); _diaryRepository.UnitOfWork.Commit(); }
public async Task <IActionResult> Update([FromBody] DiaryDTO diaryDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _diaryService.UpdateEntry(diaryDto); _logger.LogInformation($"Diary has been update"); return(Ok()); }
public async Task <IActionResult> Create([FromBody] DiaryDTO diaryDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = _identityService.GetUserIdByNameAsync(User.Identity.Name).ToString(); await _diaryService.CreateNewEntry(diaryDto, userId); _logger.LogInformation($"{userId} add new entry"); return(Ok()); }
public async Task DiaryUpdate_WithValidModel_Return_OkResult() { //Arrange var diaryDto = new DiaryDTO { Entries = "Fake", Title = "Fake", Date = DateTime.Now }; //Act var result = await _controller.Update(diaryDto); //Assert Assert.IsType <OkResult>(result); }
/// <inheritdoc /> public async Task CreateNewEntry(DiaryDTO diaryDto, string userId) { var entry = _mapper.Map <Diary>(diaryDto); var profile = await _profileService.GetProfileIdByUserId(userId); entry.UserId = userId; if (profile != null) { entry.ProfileId = profile.Id.ToString(); } await _diaryRepository.AddAsync(entry); await _diaryRepository.SaveChangesAsync(); }
protected void btnThem_Click(object sender, EventArgs e) { DiaryDTO drdto = new DiaryDTO(); DiaryDAO drdao = new DiaryDAO(); string maclaim = txtThamChieu.Text; bool kt = cl.KiemTraThamChieu(maclaim); //string maGDV = Session["MaGDV"].ToString(); //string tengdv = Session["GDV"].ToString(); int maGDV = int.Parse(drGDV0.SelectedValue.ToString()); if (maGDV != null) { if (kt == true) { drdto.MaClaim = maclaim; } else { lbllThongBao.Text = "Chưa có claim này"; lbllThongBao.Visible = true; } drdto.MaGDV = maGDV; drdto.NgayThuc = DateTime.Now; drdto.Ngay = DateTime.Parse(txtNgay.Text); drdto.DienGiai = txtDienGiai.Text.Trim(); drdto.SoGio = float.Parse(txtSoGio.Text); drdto.NgayGioBatDau = DateTime.Parse(txtNgayBatDau.Text); drdto.NgayGioKetThuc = DateTime.Parse(txtNgayKetThuc.Text); drdto.KetQua = txtKetQuaGhiNhan.Text.Trim(); bool them = drdao.DiaryMoi(drdto); if (them == true) { Response.Write("<script>alert('Đã thêm!');</script>"); } else { lblThongBaoThem.Visible = true; lblThongBaoThem.Text = "Have something wrong here!"; } } else { Response.Redirect("~/Pages/Longin.aspx"); } }
public bool DiaryMoi(DiaryDTO dr) { string sql = "sp_Diary_insert2"; List <SqlParameter> ds = new List <SqlParameter>(); SqlParameter magdv = new SqlParameter("@maGDV", SqlDbType.Int); magdv.Value = dr.MaGDV; ds.Add(magdv); SqlParameter macl = new SqlParameter("@maClaim", SqlDbType.VarChar); macl.Value = dr.MaClaim; ds.Add(macl); SqlParameter ngaythuc = new SqlParameter("@ngaythuc", SqlDbType.DateTime); ngaythuc.Value = dr.NgayThuc; ds.Add(ngaythuc); SqlParameter ngay = new SqlParameter("@ngay", SqlDbType.DateTime); ngay.Value = dr.Ngay; ds.Add(ngay); SqlParameter diengiai = new SqlParameter("@diengiai", SqlDbType.NVarChar); diengiai.Value = dr.DienGiai; ds.Add(diengiai); SqlParameter sogio = new SqlParameter("@sogio", SqlDbType.Float); sogio.Value = dr.SoGio; ds.Add(sogio); SqlParameter batdau = new SqlParameter("@ngaygiobatdau", SqlDbType.DateTime); batdau.Value = dr.NgayGioBatDau; ds.Add(batdau); SqlParameter ketthuc = new SqlParameter("@ngaygioketthuc", SqlDbType.DateTime); ketthuc.Value = dr.NgayGioKetThuc; ds.Add(ketthuc); SqlParameter ketqua = new SqlParameter("@ketqua", SqlDbType.NVarChar); ketqua.Value = dr.KetQua; ds.Add(ketqua); bool kq = SqlDataAcessHelper.exNonStoreParas(sql, ds); return(kq); }
public ActionResult Create([Bind(Include = "Text")] DiaryVm diary) { if (ModelState.IsValid) { try { DiaryDTO diaryDto = Mapper.Map <DiaryVm, DiaryDTO>(diary); serviceProvider._diaryService.AddDiary(diaryDto, Request.Files); return(RedirectToAction("Index")); } catch { ViewBag.ErrorMsg = "Error occured"; return(View(diary)); } } return(View(diary)); }
public void UpdateDiary(DiaryDTO diaryDto) { throw new NotImplementedException(); }
protected void btnThem_Click(object sender, EventArgs e) { tsdto = new DiaryDTO(); string maclaim = txtThamChieu.Text; bool kt = cl.KiemTraThamChieu(maclaim); int maGDV = int.Parse(Session["MaGDV"].ToString()); string tengdv = Session["GDV"].ToString(); if (maGDV != null) { if (kt == true) { tsdto.MaClaim = maclaim; tsdto.MaGDV = maGDV; tsdto.NgayThuc = DateTime.Now; tsdto.Ngay = DateTime.Parse(txtNgay.Text); tsdto.DienGiai = txtDienGiai.Text.Trim(); tsdto.SoGio = float.Parse(txtSoGio.Text); tsdto.NgayGioBatDau = DateTime.Parse(txtNgayBatDau.Text); tsdto.NgayGioKetThuc = DateTime.Parse(txtNgayKetThuc.Text); tsdto.KetQua = txtKetQuaGhiNhan.Text.Trim(); bool them = drdao.DiaryMoi(tsdto); if (them == true) { #region KiemTra_GuiMail float gio = drdao.TongThoiLuongPhatSinh(maclaim); bool updw = wr.CapNhatGioTichLuy(maclaim, gio); #region BodysendLA string bodyGDV = "Xin chào " + tengdv; bodyGDV += "<br/> Bạn vừa cập nhật Diary mới. <br/> Thông tin Diary:<br/>"; bodyGDV += "<table width='100%' align='center' style='border-bottom-color:#CCC; border-bottom-style:solid; border-bottom-width:1px; " + " border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;" + " border-right-color:#CCC; border-right-style:solid; border-right-width:1px;'>"; bodyGDV += "<tr style='background-color: #040; color:#FFF; font-weight:bold;'>"; //bodyGDV += "<th width='10%'>Giám định viên</th>"; bodyGDV += "<th width='10%'>Tham chiếu</th>"; bodyGDV += "<th width='10%'>Ngày</th>"; bodyGDV += "<th width='30%'>Diễn giải</th>"; bodyGDV += "<th width='10%'>Số giờ</th>"; bodyGDV += "<th width='10%'>Start</th>"; bodyGDV += "<th width='10%'>Ended</th>"; bodyGDV += "<th width='30%'>Kết quả</th>"; bodyGDV += "</tr>"; bodyGDV += "<tr style='text-align:center'>"; //bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + //" border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tengdv + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.MaClaim + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.Ngay + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.DienGiai + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.SoGio + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.NgayGioBatDau + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.NgayGioKetThuc + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.KetQua + "</td>"; bodyGDV += "</tr>"; bodyGDV += "</table>"; #endregion #region BodyMailGiamDoc //timesheet gui giam doc string bodyGiamDoc = "Thông báo! "; bodyGiamDoc += "<br/>" + tengdv + " vừa cập nhật Dairy mới. <br/> Thông tin Diary:<br/>"; bodyGiamDoc += "<table width='100%' align='center' style='border-bottom-color:#CCC; border-bottom-style:solid; border-bottom-width:1px; " + " border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;" + " border-right-color:#CCC; border-right-style:solid; border-right-width:1px;'>"; bodyGiamDoc += "<tr style='background-color: #040; color:#FFF; font-weight:bold;'>"; bodyGiamDoc += "<th width='20%'>GĐV</th>"; bodyGiamDoc += "<th width='10%'>Tham chiếu</th>"; bodyGiamDoc += "<th width='10%'>Ngày Thực</th>"; bodyGiamDoc += "<th width='10%'>Ngày</th>"; bodyGiamDoc += "<th width='30%'>Diễn giải</th>"; bodyGiamDoc += "<th width='10%'>Số giờ</th>"; bodyGiamDoc += "<th width='10%'>Start</th>"; bodyGiamDoc += "<th width='10%'>Ended</th>"; bodyGiamDoc += "<th width='30%'>Kết quả</th>"; bodyGiamDoc += "</tr>"; bodyGiamDoc += "<tr style='text-align:center'>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tengdv + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.MaClaim + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.NgayThuc + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.Ngay + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.DienGiai + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.SoGio + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.NgayGioBatDau + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.NgayGioKetThuc + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.KetQua + "</td>"; bodyGiamDoc += "</tr>"; bodyGiamDoc += "</table>"; #endregion string sTo = ""; int idgdv = int.Parse(Session["MaGDV"].ToString()); GiamDinhVienDAO gdvdao = new GiamDinhVienDAO(); DataTable dt = new DataTable(); dt = gdvdao.GiamDinhVienTheoMa(idgdv); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; sTo = dr[3].ToString(); } string ktmgdv = "", ktmgiamdoc = ""; int month = int.Parse(DateTime.Now.Month.ToString()); //ktmgiamdoc = smdao.KiemTraMailChinh("Timesheet","*****@*****.**", bodyGiamDoc, "Thông báo Diary của tháng " + month); ktmgdv = smdao.KiemTraMailChinh("New_Claim", sTo, bodyGDV, "Thông báo cập nhật Diary"); if (updw == true && ktmgdv != "") { //Response.Redirect("~/Pages/DiaRy.aspx"); Response.Write("<script>alert('Updated!');</script>"); Response.Redirect(Request.Url.PathAndQuery, true); } #endregion Response.Write("<script>alert('Đã thêm!');</script>"); } else { lblThongBaoThem.Visible = true; lblThongBaoThem.Text = "Have something wrong here!"; } } else { Response.Write("<script>alert('Mã Claim không hợp lệ!');</script>"); lbllThongBao.Visible = true; } } else { Response.Redirect("~/Pages/Longin.aspx"); } }