protected void btnCapNhat_Click(object sender, EventArgs e) { if (IsPostBack) { //string maclaim = ""; //if (lblThamChieu.Text != "") // maclaim = lblThamChieu.Text; //if (txtThamChieu.Text != "") // maclaim = txtThamChieu.Text; string maclaim = Session["ThamChieu"].ToString(); bool kq = wrdao.KiemTraWR(maclaim); bool kt = tsdao.KiemTraTimeSheetTonTai(maclaim); if (kq == false) //chua co weekly report { //them moi wr //maclaim = lblThamChieu.Text; wrdto.MaClaim = maclaim; //wrdto.MaGDV = int.Parse(drGDV.SelectedValue); if (kt == true) { float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); wrdto.GioTichLuy = gio; } else { wrdto.GioTichLuy = (float)0; } string dexuatgiamdinh = txtDeXuatGiamDinh.Text; if (dexuatgiamdinh != "") { wrdto.DeXuatGiamDinh = dexuatgiamdinh; } else { wrdto.DeXuatGiamDinh = ""; } bool kqt = wrdao.Them(wrdto); if (kqt == true) { //string thamchieu = cldao.TenClaim(maclaim); //Session["ThamChieu"] = thamchieu; int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdv.LayTenTheoMa(maGDV) + " created a weeklyreport of case" + maclaim + " ."; SaveLogTracking(maGDV, noidung, maclaim); Response.Write("<script> window.parent.closeDialog(); </script>"); Response.Write("<script> window.parent.location.reload();</script>"); } } else { //cap nhat wr wrdto = new WeeklyReportDTO(); wrdto.Ma = wrdao.LayMa(maclaim); //wrdto.DuPhongTonThat = txtDuPhongTonThat.Text.Trim(); wrdto.DeXuatGiamDinh = txtDeXuatGiamDinh.Text.Trim(); //wrdto.GioTichLuy = float.Parse(txtGioTichLuy.Text); bool kqcn = wrdao.CapNhat(wrdto); if (kqcn == true) { // string tc = cldao.TenClaim(maclaim); // Session["ThamChieu"] = tc; int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdv.LayTenTheoMa(maGDV) + " edited weeklyreport of case" + maclaim + " ."; SaveLogTracking(maGDV, noidung, maclaim); Response.Write("<script> window.parent.closeDialog(); </script>"); Response.Write("<script> window.parent.location.reload();</script>"); } } } }
protected void btnCapNhat_Click(object sender, EventArgs e) { if (IsPostBack) { string maclaim = ""; if (lblThamChieu.Text != "") { maclaim = lblThamChieu.Text; } if (txtThamChieu.Text != "") { maclaim = txtThamChieu.Text; } bool kq = wrdao.KiemTraWR(maclaim); bool kt = tsdao.KiemTraTimeSheetTonTai(maclaim); if (kq == false) //chua co weekly report { //them moi wr maclaim = txtThamChieu.Text; wrdto.MaClaim = maclaim; //wrdto.MaGDV = int.Parse(drGDV.SelectedValue); if (kt == true) { float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); wrdto.GioTichLuy = gio; } else { wrdto.GioTichLuy = (float)0; } string dexuatgiamdinh = ckDeXuatGiamDinh.Text; if (dexuatgiamdinh != "") { wrdto.DeXuatGiamDinh = dexuatgiamdinh; } else { wrdto.DeXuatGiamDinh = ""; } bool kqt = wrdao.Them(wrdto); if (kqt == true) { string thamchieu = cldao.TenClaim(maclaim); Session["ThamChieu"] = thamchieu; Response.Redirect("~/Pages/XemWeeklyReport.aspx?viewthamchieu=" + thamchieu); } } else { //cap nhat wr wrdto = new WeeklyReportDTO(); wrdto.Ma = wrdao.LayMa(maclaim); //wrdto.DuPhongTonThat = txtDuPhongTonThat.Text.Trim(); wrdto.DeXuatGiamDinh = ckDeXuatGiamDinh.Text.Trim(); //wrdto.GioTichLuy = float.Parse(txtGioTichLuy.Text); bool kqcn = wrdao.CapNhat(wrdto); if (kqcn == true) { string tc = cldao.TenClaim(maclaim); Session["ThamChieu"] = tc; Response.Redirect("~/Pages/XemWeeklyReport.aspx?viewthamchieu=" + tc); //Response.RedirectLocation("~/Pages/ViewWR.aspx"); } } //} //else // lblThongBao.Text = "Sai tham chiếu."; //} //else // lblThongBao.Text = "Chưa nhập tham chiếu."; } }