protected void btnTim_Click(object sender, EventArgs e) { int magdv = int.Parse(drGDV0.SelectedItem.Value.ToString()); //GiamDinhVienDAO gdvdao = new GiamDinhVienDAO(); //DataTable dtgdv = gdvdao.MaGiamDinhVienTheoTen(tengdv); //int idgdv = 0; //if (dtgdv.Rows.Count > 0) //{ // DataRow dr = dtgdv.Rows[0]; // idgdv = int.Parse(dr[0].ToString()); //} ClaimDAO cdao = new ClaimDAO(); string matc = txtMaThamChieuT.Text; string thamchieu = cdao.TenClaim(matc); //DataTable dtc = cdao.ClaimTheoTen(thamchieu); if (matc != "") { bool kt = cl.KiemTraThamChieu(matc); if (kt == true) { loadDSTimeSheet(magdv, matc); gvDSTimeSheet.Visible = true; } } //if (matc == "") //{ // LoadTSTheoThamchieu(matc); //} if (matc == "") { loadTheoGDV(magdv); } //if (dtgdv.Rows.Count == 0) //{ // loadTheoThamChieu(matc); //} }
protected void btnThemMoi_Click(object sender, EventArgs e) { try { string tc = txtThamChieu.Text.Trim(); bool kt = clda.KiemTraThamChieu(tc); if (kt == true) { bool kttcsu = sdao.KiemTraClaim(txtThamChieu.Text); if (kttcsu == false) { string mathamchieu = clda.LayMa(tc); sdao.Them(mathamchieu); } lblThamChieu.Text = tc; } else { lblThamChieu.Text = "Tham chiếu này chưa có ở Claim!"; } } catch (Exception ex) { lblThamChieu.Text = ex.Message; } }
protected string GETMaThamChieu() { string matc = cldao.LayMaTheoTen(txtReferencenumber.Text); bool kttc = cldao.KiemTraThamChieu(matc); if (kttc == true) { return(matc); } else { return("NULL"); } }
protected void btnNhap_Click(object sender, EventArgs e) { string mathamchieu = txtThamChieu.Text; bool kq = cldao.KiemTraThamChieu(mathamchieu); if (kq == true) { Session["ThamChieu"] = mathamchieu; Response.Redirect("~/Pages/InformationForm.aspx?Reference=" + mathamchieu); } else { Response.Write("<script>alert('Nhập sai tham chiếu!');</script>"); } }
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"); } }
protected void btnThem_Click(object sender, EventArgs e) { if (this.IsPostBack) { TimeSheetDTO tsdto = new TimeSheetDTO(); GiamDinhVienDAO gdv = new GiamDinhVienDAO(); int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); tsdto.MaGDV = maGDV; string tengdv = lblGiamDinhVien.Text; string maclaim = txtThamChieu.Text; bool kt = cl.KiemTraThamChieu(maclaim); float h = 0; if (txtSoGio.Text != "" && float.TryParse(txtSoGio.Text, out h)) { string diengiai = txtDienGiaiChiTiet.Text;; // string diengiaidetail = txtDienGiaiChiTiet.Text; string loaidiengiai = ""; if (diengiai != "") { tsdto.DienGiai = diengiai; } else { tsdto.DienGiai = ""; } string extr = txtEtraFee.Text; if (extr != "") { tsdto.ExtraFee = extr; } else { tsdto.ExtraFee = ""; } if (kt == true) { tsdto.ThamChieu = maclaim; tsdto.Ngay = txtNgay.Text; tsdto.IdCongTacTimeSheet = drDienGiai.SelectedItem.Value.ToString(); loaidiengiai = drDienGiai.SelectedItem.ToString(); if (int.Parse(drDienGiai.SelectedValue) != 0) { tsdto.ThoiLuongPhatSinh = float.Parse(txtSoGio.Text); tsdto.GioThuc = DateTime.Now; bool them = tsdao.ThemTimeSheet(tsdto); if (them == true) { float time = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); wr.CapNhatGioTichLuy(maclaim, time); string noidung = gdv.LayTenTheoMa(maGDV) + " created timesheet of case " + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); #region KiemTra_GuiMail float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(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 TimeSheet mới. <br/> Thông tin TimeSheet:<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='25%'>Diễn giải</th>"; bodyGDV += "<th width='25%'>Chi tiết</th>"; bodyGDV += "<th width='10%'>Số giờ</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;'>" + tsdto.ThamChieu + "</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;'>" + loaidiengiai + "</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;'>" + 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.ThoiLuongPhatSinh + "</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 TimeSheet mới. <br/> Thông tin Timesheet :<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%'>LA</th>"; bodyGiamDoc += "<th width='10%'>Reference</th>"; bodyGiamDoc += "<th width='10%'>Date Update</th>"; bodyGiamDoc += "<th width='10%'>Date</th>"; bodyGiamDoc += "<th width='30%'>Description</th>"; bodyGiamDoc += "<th width='10%'>Time-Spent</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.ThamChieu + "</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.GioThuc + "</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;'>" + 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.ThoiLuongPhatSinh + "</td>"; bodyGiamDoc += "</tr>"; bodyGiamDoc += "</table>"; #endregion string sTo = ""; int idgdv = int.Parse(Request.Cookies["MaGDV"].Value); 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()); //Send_Email("*****@*****.**", sTo, "Thông báo timesheet mới", bodyGiamDoc, "[email protected],[email protected]"); //sm.KiemTraMailChinhCC(sTo, bodyGiamDoc, "Timesheet Notification", "Timesheet", "*****@*****.**"); sm.KiemTraMailChinhCC(sTo, bodyGDV, "Timesheet Notification", "Timesheet", "*****@*****.**"); #endregion ClearInputs(Page.Controls); //Response.Write("<script> window.parent.closeDialog(); </script>"); //Response.Write("<script> window.parent.location.reload();</script>"); } } else { Response.Write("<script>alert('Chưa chọn loại công tác!');</script>"); } } } else { Response.Write("<script>alert('Nhập sai định dạng giờ lẻ!');</script>"); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { TimeSheetDTO ts = new TimeSheetDTO(); ts.ID = int.Parse(lblID.Text); if (drGDV.Visible == true) { ts.MaGDV = int.Parse(drGDV.SelectedItem.Value.ToString()); } else { ts.MaGDV = int.Parse(lblID_GDV.Text); } bool kttc = cl.KiemTraThamChieu(txtThamChieu.Text); if (kttc == true) { ts.ThamChieu = txtThamChieu.Text; } else { Response.Write("<script>alert('Case no. isn't true!');</script>"); } ts.Ngay = txtNgay.Text; if (drCongTac.Visible == true) { ts.IdCongTacTimeSheet = drCongTac.SelectedItem.Value.ToString(); } else { ts.IdCongTacTimeSheet = lblID_CongTac.Text; } ts.DienGiai = txtDienGiaiChiTiet.Text; string extr = txtEtraFee.Text; if (extr != "") { ts.ExtraFee = extr; } else { ts.ExtraFee = ""; } ts.ThoiLuongPhatSinh = float.Parse(txtSoGio.Text); ts.TimeIssue = float.Parse(txtTIssue.Text); bool up = tsdao.UpdateMa(ts); if (up == true) { int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdvdao.LayTenTheoMa(maGDV) + " updated a timesheet of case " + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); Response.Write("<script> window.parent.closeDialog(); </script>"); Response.Write("<script> window.parent.location.reload();</script>"); } else { int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdvdao.LayTenTheoMa(maGDV) + " failed to update timesheet of case" + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); Response.Write("<script>alert('Update fail!');</script>"); } }
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"); } }