protected void btAddApprover_Click(object sender, EventArgs e) { try { bool updateVB = false; bool executeSuccess = false; if (!isUpdate()) { sec = new VanBanTrongHoSo(); sec.Coquan = ddlCoQuan.SelectedValue; sec.MaPhong = ddlPhong.SelectedValue; sec.MucLucSo = txtMucLuc.Text; sec.NgonNgu = ddlNgonNgu.SelectedValue; sec.HoSoSo = txtHoSoSo.Text; sec.KyHieuVanBan = txtKyHieu.Text; sec.GhiChu = txtGhiChu.Text; sec.ButTich = txtButtich.Text; sec.SoLuongTo = txtSoluongto.Text; sec.ThoiGian = Request.Form[txtThoiGian.UniqueID]; sec.KiHieuThongTin = txtKyhieuThongtin.Text; sec.ToSo = txtToSo.Text; sec.TrichYeu = txtTrichYeu.Text; sec.TacGia = txtTacgia.Text; sec.LoaiVanBan = ddlLoaivanban.SelectedValue; sec.MucDoTinCay = ddlMucDoTinCay.SelectedValue; sec.DoMat = ddlDomat.SelectedValue; sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue; sec.Hoso_ID = Request.QueryString["hid"].ToString(); sec.ThoiHanBaoQuan = ddlThoiHan.SelectedValue; //sec.FilePath = uploadfile(); } else { updateVB = true; sec = um.getVanBanTrongHoSo(Int32.Parse(Session[VanBanTrongHoSoLogic.SESSION_SEC_ID].ToString())); sec.Coquan = ddlCoQuan.SelectedValue; sec.MaPhong = ddlPhong.SelectedValue; sec.MucLucSo = txtMucLuc.Text; sec.NgonNgu = ddlNgonNgu.SelectedValue; sec.HoSoSo = txtHoSoSo.Text; sec.KyHieuVanBan = txtKyHieu.Text; sec.GhiChu = txtGhiChu.Text; sec.ButTich = txtButtich.Text; sec.SoLuongTo = txtSoluongto.Text; sec.ThoiGian = Request.Form[txtThoiGian.UniqueID]; sec.KiHieuThongTin = txtKyhieuThongtin.Text; sec.ToSo = txtToSo.Text; sec.TrichYeu = txtTrichYeu.Text; sec.TacGia = txtTacgia.Text; sec.LoaiVanBan = ddlLoaivanban.SelectedValue; sec.MucDoTinCay = ddlMucDoTinCay.SelectedValue; sec.DoMat = ddlDomat.SelectedValue; sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue; sec.ThoiHanBaoQuan = ddlThoiHan.SelectedValue; //sec.ID = } if (!isUpdate()) { string validateMessage = ""; if (um.validateVanBan(sec, out validateMessage)) { int newID = um.addVanBanTrongHoSo(sec); sec.ID = newID; executeSuccess = true; lstInfo.Add("Thêm mới văn bản thành công."); Session[VanBanTrongHoSoLogic.SESSION_VANBAN_CACHE] = sec; } else { Logger.logmessage(classobject, "btAddApprover_Click", "Validate fail 4 insert VB " + sec.KyHieuVanBan); lstError.Add(validateMessage); executeSuccess = false; Session[VanBanTrongHoSoLogic.SESSION_VANBAN_CACHE] = sec; } } else { string validateMessage = ""; if (um.validateVanBan(sec, out validateMessage)) { sec.ID = Int32.Parse(SecID); um.updateVanBanTrongHoSo(sec); //Xóa đính kèm foreach (GridViewRow r in dgvAttachment.Rows) { if (r.RowType == DataControlRowType.DataRow) { CheckBox chkDel = (CheckBox)r.FindControl("chkDeleteAttachment"); if (chkDel != null && chkDel.Checked) { int k = 0; string sK = dgvAttachment.DataKeys[r.RowIndex].Value.ToString(); Int32.TryParse(sK, out k); attachLogic.deleteAttachmentFromVanBan(sec.ID, k); } } } lstInfo.Add("Cập nhật văn bản thành công."); executeSuccess = true; Session[VanBanTrongHoSoLogic.SESSION_VANBAN_CACHE] = sec; } else { executeSuccess = false; Logger.logmessage(classobject, "btAddApprover_Click", "Validate fail 4 update VB " + sec.KyHieuVanBan); lstError.Add("Văn bản chưa được cập nhật, bạn hãy kiểm tra lại các thông tin đầu vào."); } //Response.Redirect("ThongKeTaiLieu.aspx", false); } Session[Constants.SESSION_INFO] = lstInfo; Session[Constants.SESSION_ERROR] = lstError; if (FileUpload1.HasFile) { attachLogic.createAttachment(Server.MapPath("~/files"), AttachmentLogic.ATTACHMENT_TYPE_VB, FileUpload1.PostedFile.FileName, FileUpload1, sec.ID); Logger.logmessage(classobject, "btAddApprover_Click", "Uploaded file " + FileUpload1.PostedFile.FileName); } Button btn = sender as Button; string cmd = ""; if (btn != null) { cmd = btn.CommandArgument; } if (cmd.ToUpper().Equals("CONTINUE")) { Response.Redirect("QLFileDinhKem.aspx?ObjectID=" + sec.ID.ToString() + "&ObjectType=" + AttachmentLogic.ATTACHMENT_TYPE_VB + "&RootId=" + hidHoSo.Value, false); } else { if (executeSuccess) { Session[VanBanTrongHoSoLogic.SESSION_SEC_ID] = null; Session[VanBanTrongHoSoLogic.SESSION_VANBAN_CACHE] = sec; } Response.Redirect("ThemVBTrongHoSo.aspx?hid=" + hidHoSo.Value, false); } } catch (Exception ex) { Logger.logmessage(classobject, "btAddApprover_Click", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false); } }
protected void btAddApprover_Click(object sender, EventArgs e) { if (!isUpdate()) { sec = new VanBanTrongHoSo(); sec.Coquan = ddlCoQuan.SelectedValue; sec.MaPhong = ddlPhong.SelectedValue; sec.MucLucSo = ddlMucLuc.SelectedValue; sec.NgonNgu = ddlNgonNgu.SelectedValue; sec.HoSoSo = txtHoSoSo.Text; sec.KyHieuVanBan = txtKyHieu.Text; sec.GhiChu = txtGhiChu.Text; sec.ButTich = txtButtich.Text; sec.SoLuongTo = txtSoluongto.Text; sec.ThoiGian = txtThoiGian.Text; sec.KiHieuThongTin = txtKyhieuThongtin.Text; sec.ToSo = txtToSo.Text; sec.TrichYeu = txtTrichYeu.Text; sec.TacGia = txtTacgia.Text; sec.LoaiVanBan = ddlLoaivanban.SelectedValue; sec.MucDoTinCay = ddlMucDoTinCay.SelectedValue; sec.DoMat = ddlDomat.SelectedValue; sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue; sec.FilePath = uploadfile(); } else { sec.Coquan = ddlCoQuan.SelectedValue; sec.MaPhong = ddlPhong.SelectedValue; sec.MucLucSo = ddlMucLuc.SelectedValue; sec.NgonNgu = ddlNgonNgu.SelectedValue; sec.HoSoSo = txtHoSoSo.Text; sec.KyHieuVanBan = txtKyHieu.Text; sec.GhiChu = txtGhiChu.Text; sec.ButTich = txtButtich.Text; sec.SoLuongTo = txtSoluongto.Text; sec.ThoiGian = txtThoiGian.Text; sec.KiHieuThongTin = txtKyhieuThongtin.Text; sec.ToSo = txtToSo.Text; sec.TrichYeu = txtTrichYeu.Text; sec.TacGia = txtTacgia.Text; sec.LoaiVanBan = ddlLoaivanban.SelectedValue; sec.MucDoTinCay = ddlMucDoTinCay.SelectedValue; sec.DoMat = ddlDomat.SelectedValue; sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue; } if (!isUpdate()) { if (validateObject(sec)) { um.addVanBanTrongHoSo(sec); } // listAllSec(); } else { if (validateObject(sec)) { sec.ID = Int32.Parse(SecID); um.updateVanBanTrongHoSo(sec); } } Response.Redirect("QLHoSo.aspx", false); }