protected void GetSessionTapTin() { if (Session["TapTin"] != null) { DataTable dt = Session["TapTin"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); objTapTin.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString(); objTapTin.FILE_SIZE = Int32.Parse(dt.Rows[0]["FILE_SIZE"].ToString()); } dtTable = new DataTable(); dtTable.Columns.Add("FILE_NAME"); dtTable.Columns.Add("FILE_MOTA"); dtTable.Columns.Add("FILE_EXT"); dtTable.Columns.Add("FILE_SIZE"); DataRow row = dtTable.NewRow(); row["FILE_NAME"] = objTapTin.FILE_NAME; row["FILE_MOTA"] = objTapTin.FILE_MOTA; row["FILE_EXT"] = objTapTin.FILE_EXT; row["FILE_SIZE"] = objTapTin.FILE_SIZE; dtTable.Rows.Add(row); //Session["dgDanhSach"] = dtTable; GridView1.DataSource = dtTable; GridView1.DataBind(); } }
protected void btn_TaiXuong(object sender, EventArgs e) { try { HtmlAnchor html = (HtmlAnchor)sender; string FILE_NAME = html.HRef.ToString(); if (Session["TapTin"] != null) { DataTable dt = Session["TapTin"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); } } else { if (Session["dgDanhSach"] != null) { DataTable dt = Session["dgDanhSach"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); } } //BM_ID = Convert.ToInt32(Request.QueryString["BM_ID"]); //objTapTin = new QLCC_TAPTIN(); //objTapTin = objTAPTINController.Get_TapTin_By_ObjectID_BieuMau(BM_ID); } string sourceFile = Server.MapPath(ClassParameter.vPathDataBieuMau) + objTapTin.FILE_NAME; byte[] byteArray = File.ReadAllBytes(sourceFile); using (MemoryStream mem = new MemoryStream()) { mem.Write(byteArray, 0, (int)byteArray.Length); Response.Clear(); Response.Buffer = true; Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment; filename=" + objTapTin.FILE_MOTA + ".docx"); Response.Charset = ""; Response.ContentType = "application/octet-stream"; Response.BinaryWrite(mem.ToArray()); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); } } catch (Exception ex) { log.Error("", ex); } }
public void CapNhatTapTin(QLHD_TAPTIN objTapTin) { var obj = Get_TapTin(objTapTin.FILE_ID); obj.FILE_NAME = objTapTin.FILE_NAME; obj.FILE_MOTA = objTapTin.FILE_MOTA; obj.FILE_EXT = objTapTin.FILE_EXT; obj.FILE_NGAYCAPNHAT = objTapTin.FILE_NGAYCAPNHAT; obj.FILE_SIZE = objTapTin.FILE_SIZE; obj.FILE_USERID_CAPNHAT = objTapTin.FILE_USERID_CAPNHAT; obj.OBJECT_ID = objTapTin.OBJECT_ID; obj.OBJECT_LOAI = objTapTin.OBJECT_LOAI; context.SubmitChanges(); }
protected void btnCapNhat_Click(object sender, EventArgs e) { try { string o_Messages = ""; LinkButton btn = sender as LinkButton; string action = btn.CommandName; if (Check_ThoiGian(DateTime.Parse(txtNgayKhoiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanThiCong.SelectedDate.ToString()), out o_Messages) == false || Check_ThoiGian(DateTime.Parse(txtBLThucHienHopDongTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongDenNgay.SelectedDate.ToString()), out o_Messages) == false || Check_ThoiGian(DateTime.Parse(txtBLThanhToanVatTuTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuDenNgay.SelectedDate.ToString()), out o_Messages) == false || Check_ThoiGian(DateTime.Parse(txtBLTamUngTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngDenNgay.SelectedDate.ToString()), out o_Messages) == false || Check_ThoiGian(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false //|| Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtNgayKhoiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanThiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false //|| Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false //|| Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false //|| Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false ) { if (Check_ThoiGian(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Ngày hết hạn hợp đồng phải lớn hơn hoặc bằng ngày hiệu lực hợp đồng. Vui lòng kiểm tra lại."; txtNgayHetHanThiCong.Focus(); } if (Check_ThoiGian(DateTime.Parse(txtNgayKhoiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanThiCong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Ngày hết hạn thi công phải lớn hơn hoặc bằng ngày khởi công. Vui lòng kiểm tra lại."; txtNgayHetHanThiCong.Focus(); } if (Check_ThoiGian(DateTime.Parse(txtBLThucHienHopDongTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongDenNgay.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Bảo lãnh thực hiện hợp đồng đến ngày phải lớn hơn hoặc bằng từ ngày. Vui lòng kiểm tra lại."; txtBLThucHienHopDongDenNgay.Focus(); } if (Check_ThoiGian(DateTime.Parse(txtBLThanhToanVatTuTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuDenNgay.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Bảo lãnh thanh toán vật tư đến ngày phải lớn hơn hoặc bằng từ ngày. Vui lòng kiểm tra lại."; txtBLThanhToanVatTuDenNgay.Focus(); } if (Check_ThoiGian(DateTime.Parse(txtBLTamUngTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngDenNgay.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Bảo lãnh tạm ứng đến ngày phải lớn hơn hoặc bằng từ ngày. Vui lòng kiểm tra lại."; txtBLThanhToanVatTuDenNgay.Focus(); } if (Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLTamUngDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Thời gian bảo lãnh tạm ứng phải nằm trong thời gian của hợp đồng. Vui lòng kiểm tra lại."; txtBLTamUngTuNgay.Focus(); } if (Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThanhToanVatTuDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Thời gian bảo lãnh thanh toán vật tư phải nằm trong thời gian của hợp đồng. Vui lòng kiểm tra lại."; txtBLThanhToanVatTuTuNgay.Focus(); } if (Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongTuNgay.SelectedDate.ToString()), DateTime.Parse(txtBLThucHienHopDongDenNgay.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Thời gian bảo lãnh thực hiện hợp đồng phải nằm trong thời gian của hợp đồng. Vui lòng kiểm tra lại."; txtBLThucHienHopDongTuNgay.Focus(); } if (Check_ThoiGian_DuAn_GiaiDoan(DateTime.Parse(txtHieuLucHopDong.SelectedDate.ToString()), DateTime.Parse(txtNgayKhoiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanThiCong.SelectedDate.ToString()), DateTime.Parse(txtNgayHetHanHongDong.SelectedDate.ToString()), out o_Messages) == false) { pnThongBao.Visible = true; lblThongBao.Text = "Thời gian thi công phải nằm trong thời gian của hợp đồng. Vui lòng kiểm tra lại."; txtNgayKhoiCong.Focus(); } } else { if (HD_ID == 0) // Thêm mới { var objQLHD_HD = new QLHD_HD(); objQLHD_HD.HD_BLTAMUNG_TUNGAY = txtBLTamUngTuNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTAMUNG_DENNGAY = txtBLTamUngDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTAMUNG_TGNHAC = Int32.Parse(txtTGDenHanBLTamUng.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHANHTOANVATTU_DENNGAY = txtBLThanhToanVatTuDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTHANHTOANVATTU_TGNHAC = Int32.Parse(txtTGDenHanBLThanhToanVatTu.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHANHTOANVATTU_TUNGAY = txtBLThanhToanVatTuTuNgay.SelectedDate ?? DateTime.Now;; objQLHD_HD.HD_BLTHUCHIENHOPDONG_DENNGAY = txtBLThucHienHopDongDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTHUCHIENHOPDONG_TGNHAC = Int32.Parse(txtTGDenHanBLThucHienHD.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHUCHIENHOPDONG_TUNGAY = txtBLThucHienHopDongTuNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_COGIAHAN = false; objQLHD_HD.HD_GHICHU = txtGhiChu.Text; objQLHD_HD.HD_GIATRI = decimal.Parse(txtGiaTri.Text.ToString());; objQLHD_HD.HD_HIEULUC_HD = txtHieuLucHopDong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYHETHANTHICONG = txtNgayHetHanThiCong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYHETHAN_HD = txtNgayHetHanHongDong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYKHOICONG = txtNgayKhoiCong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYKY = txtNgayKy.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_SO = txtSoHopDong.Text; objQLHD_HD.HD_SOLANGIAHAN = 0; objQLHD_HD.HD_TEN = txtTenHopDong.Text; objQLHD_HD.HD_TENCONGTRINH = txtTenCongTrinh.Text; objQLHD_HD.HD_TENDONVITHICONG = txtDonViThiCong.Text; objQLHD_HD.HD_TGNHAC = Int32.Parse(txtTGDenHanHD.Text.ToString().Replace(".", ""));; objQLHD_HD.HD_THICONG_TGNHAC = Int32.Parse(txtTGDenHanThiCong.Text.ToString().Replace(".", "")); objQLHD_HD.HD_THOIGIANTHICONG = Int32.Parse(txtThoiGianThiCong.Text.ToString().Replace(".", "")); objQLHD_HD.HD_THOIGIANTHUCHIEN = Int32.Parse(txtThoiGianThucHien.Text.ToString().Replace(".", "")); objQLHD_HD.HD_TRANGTHAI = 2; objQLHD_HD.HD_XOA = false; objQLHD_HD.HD_SOLANGIAHAN = 0; InsertQLHD_HD(objQLHD_HD); //Tập tin DataTable dt = new DataTable(); if (Session["TapTin"] != null) { dt = Session["TapTin"] as DataTable; } else { if (Session["dgDanhSach"] != null) { dt = Session["dgDanhSach"] as DataTable; } } for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); objTapTin.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString(); objTapTin.FILE_SIZE = Int32.Parse(dt.Rows[i]["FILE_SIZE"].ToString()); objTapTin.FILE_USERID_CAPNHAT = _currentUser.UserID; objTapTin.FILE_NGAYCAPNHAT = DateTime.Now; objTapTin.OBJECT_LOAI = (int)CommonEnum.TapTinObjectLoai.BieuMau; objTapTin.OBJECT_ID = objQLHD_HD.HD_ID; objTAPTINController.ThemTapTin(objTapTin); } Session[TabId + "_Message"] = "Thêm mới hợp đồng thành công"; Session[TabId + "_Type"] = "success"; if (action == "TiepTuc") { Session.Remove("TapTin"); Response.Redirect(Globals.NavigateURL("edit", "mid=" + Request.Params["mid"].ToString(), "title=Thêm mới hợp đồng")); } else { Response.Redirect(Globals.NavigateURL()); } } else { var objQLHD_HD = new QLHD_HD(); objQLHD_HD.HD_ID = HD_ID; objQLHD_HD.HD_BLTAMUNG_TUNGAY = txtBLTamUngTuNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTAMUNG_DENNGAY = txtBLTamUngDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTAMUNG_TGNHAC = Int32.Parse(txtTGDenHanBLTamUng.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHANHTOANVATTU_DENNGAY = txtBLThanhToanVatTuDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTHANHTOANVATTU_TGNHAC = Int32.Parse(txtTGDenHanBLThanhToanVatTu.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHANHTOANVATTU_TUNGAY = txtBLThanhToanVatTuTuNgay.SelectedDate ?? DateTime.Now;; objQLHD_HD.HD_BLTHUCHIENHOPDONG_DENNGAY = txtBLThucHienHopDongDenNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_BLTHUCHIENHOPDONG_TGNHAC = Int32.Parse(txtTGDenHanBLThucHienHD.Text.ToString().Replace(".", "")); objQLHD_HD.HD_BLTHUCHIENHOPDONG_TUNGAY = txtBLThucHienHopDongTuNgay.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_COGIAHAN = false; objQLHD_HD.HD_GHICHU = txtGhiChu.Text; objQLHD_HD.HD_GIATRI = decimal.Parse(txtGiaTri.Text.ToString());; objQLHD_HD.HD_HIEULUC_HD = txtHieuLucHopDong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYHETHANTHICONG = txtNgayHetHanThiCong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYHETHAN_HD = txtNgayHetHanHongDong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYKHOICONG = txtNgayKhoiCong.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_NGAYKY = txtNgayKy.SelectedDate ?? DateTime.Now; objQLHD_HD.HD_SO = txtSoHopDong.Text; objQLHD_HD.HD_TEN = txtTenHopDong.Text; objQLHD_HD.HD_TENCONGTRINH = txtTenCongTrinh.Text; objQLHD_HD.HD_TENDONVITHICONG = txtDonViThiCong.Text; objQLHD_HD.HD_TGNHAC = Int32.Parse(txtTGDenHanHD.Text.ToString().Replace(".", "")); objQLHD_HD.HD_THICONG_TGNHAC = Int32.Parse(txtTGDenHanThiCong.Text.ToString().Replace(".", "")); objQLHD_HD.HD_THOIGIANTHICONG = Int32.Parse(txtThoiGianThiCong.Text.ToString().Replace(".", "")); objQLHD_HD.HD_THOIGIANTHUCHIEN = Int32.Parse(txtThoiGianThucHien.Text.ToString().Replace(".", "")); objQLHD_HD.HD_TRANGTHAI = 2; objQLHD_HD.HD_XOA = false; int vSoLanGiaHan = vDC.QLHD_GIAHANHDs.Where(x => x.HD_ID == HD_ID).ToList().Count; objQLHD_HD.HD_SOLANGIAHAN = vSoLanGiaHan; UpdateQLHD_HD(objQLHD_HD); //Tập tin var objTT = objTAPTINController.Get_TapTin_By_ObjectID(HD_ID); foreach (var it1 in objTT) { objTAPTINController.XOA_TAPTIN(it1.FILE_ID); } if (Session["TapTin"] != null) { DataTable dt = Session["TapTin"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); objTapTin.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString(); objTapTin.FILE_SIZE = Int32.Parse(dt.Rows[0]["FILE_SIZE"].ToString()); objTapTin.FILE_USERID_CAPNHAT = _currentUser.UserID; objTapTin.FILE_NGAYCAPNHAT = DateTime.Now; objTapTin.OBJECT_LOAI = (int)CommonEnum.TapTinObjectLoai.BieuMau; objTapTin.OBJECT_ID = HD_ID; objTAPTINController.ThemTapTin(objTapTin); } } else { if (Session["dgDanhSach"] != null) { DataTable dt = Session["dgDanhSach"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { objTapTin = new QLHD_TAPTIN(); objTapTin.FILE_NAME = dt.Rows[0]["FILE_NAME"].ToString(); objTapTin.FILE_MOTA = dt.Rows[0]["FILE_MOTA"].ToString().Replace("<i class='fa fa-file-word-o icon_upload'></i>", ""); objTapTin.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString(); objTapTin.FILE_SIZE = Int32.Parse(dt.Rows[0]["FILE_SIZE"].ToString()); objTapTin.FILE_USERID_CAPNHAT = _currentUser.UserID; objTapTin.FILE_NGAYCAPNHAT = DateTime.Now; objTapTin.OBJECT_LOAI = (int)CommonEnum.TapTinObjectLoai.BieuMau; objTapTin.OBJECT_ID = HD_ID; objTAPTINController.ThemTapTin(objTapTin); } } } Session[TabId + "_Message"] = "Cập nhật hợp đồng thành công"; Session[TabId + "_Type"] = "success"; Response.Redirect(Globals.NavigateURL(), false); } } } catch (Exception ex) { ClassCommon.THONGBAO_TOASTR(Page, ex, _currentUser, ClassParameter.unknownErrorMessage, "Thông báo lỗi", "error"); log.Error("", ex); } }
public void ThemTapTin(QLHD_TAPTIN objTapTin) { context.QLHD_TAPTINs.InsertOnSubmit(objTapTin); context.SubmitChanges(); }