Exemplo n.º 1
0
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     try
     {
         string fileStored = Server.MapPath("~/files");
         int    id         = 0;
         Int32.TryParse(hidId.Value, out id);
         logic.createAttachment(fileStored, hidPrefix.Value, fulAttach.PostedFile.FileName, fulAttach, id);
         Button btn = sender as Button;
         string cmd = "";
         if (btn != null)
         {
             cmd = btn.CommandArgument.ToUpper();
         }
         if (cmd.Equals("CONTINUE"))
         {
             Response.Redirect("QLFileDinhKem.aspx?ObjectID=" + hidId.Value + "&ObjectType=" + hidPrefix.Value + "&RootId = " + hidRootId.Value, false);
         }
         else
         {
             if (AttachmentLogic.ATTACHMENT_TYPE_HS.Equals(hidPrefix.Value))
             {
                 Session[HoSoLogic.SESSION_SEC_ID] = null;
                 Response.Redirect("ThemMoiHoSo.aspx", false);
             }
             else if (AttachmentLogic.ATTACHMENT_TYPE_VB.Equals(hidPrefix.Value))
             {
                 Session[VanBanTrongHoSoLogic.SESSION_SEC_ID] = null;
                 Response.Redirect("ThemVBTrongHoSo.aspx?hid=" + hidRootId.Value, false);
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error("btnUpload_Click error: ", ex);
         Response.Redirect("~/ThongBaoLoi.aspx", false);
     }
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        protected void btAddApprover_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isUpdate())
                {
                    sec = new HoSo();

                    sec.Coquan   = ddlCoQuan.SelectedValue;
                    sec.MaPhong  = ddlPhong.SelectedValue;
                    sec.MucLucSo = txtMucLuc.Text;
                    sec.HopSo    = txtHopSo.Text;
                    sec.HoSoSo   = txtHoSoSo.Text;
                    sec.NgonNgu  = ddlNgonNgu.SelectedValue;

                    sec.KyHieu          = txtKyHieu.Text;
                    sec.TieuDe          = txtTieude.Text;
                    sec.GhiChu          = txtGhiChu.Text;
                    sec.ThoiGianBatDau  = Request.Form[txtThoiGianBatDau.UniqueID];
                    sec.ThoiGianKetThuc = Request.Form[txtThoiGiankT.UniqueID];

                    sec.ButTich        = txtButtich.Text;
                    sec.SoLuong        = txtSoluongto.Text;
                    sec.ThoiHanBaoQuan = ddlThoiHan.SelectedValue;
                    sec.CheDoSuDung    = ddlChedoSD.SelectedValue;
                    sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue;
                }
                else
                {
                    sec          = um.getHoSo(Int32.Parse(Session[HoSoLogic.SESSION_SEC_ID].ToString()));
                    sec.Coquan   = ddlCoQuan.SelectedValue;
                    sec.MaPhong  = ddlPhong.SelectedValue;
                    sec.MucLucSo = txtMucLuc.Text;
                    sec.HopSo    = txtHopSo.Text;
                    sec.HoSoSo   = txtHoSoSo.Text;
                    sec.NgonNgu  = ddlNgonNgu.SelectedValue;

                    sec.KyHieu          = txtKyHieu.Text;
                    sec.TieuDe          = txtTieude.Text;
                    sec.GhiChu          = txtGhiChu.Text;
                    sec.ThoiGianBatDau  = Request.Form[txtThoiGianBatDau.UniqueID];
                    sec.ThoiGianKetThuc = Request.Form[txtThoiGiankT.UniqueID];

                    sec.ButTich        = txtButtich.Text;
                    sec.SoLuong        = txtSoluongto.Text;
                    sec.ThoiHanBaoQuan = ddlThoiHan.SelectedValue;
                    sec.CheDoSuDung    = ddlChedoSD.SelectedValue;
                    sec.TinhTrangVatLy = ddlTinhTrang.SelectedValue;
                }
                if (!isUpdate())
                {
                    if (validateObject(sec))
                    {
                        int newId = um.addHoSo(sec);
                        sec.ID = newId;
                        if (fulAttach.HasFile)
                        {
                            string filePath = attachLogic.createAttachment(Server.MapPath("~/files"), AttachmentLogic.ATTACHMENT_TYPE_HS, fulAttach.PostedFile.FileName, fulAttach, newId);
                            Logger.logmessage(classobject, "btAddApprover_Click", "Attach success " + fulAttach.PostedFile.FileName);
                        }
                    }
                    else
                    {
                        Logger.logmessage(classobject, "btAddApprover_Click", "Ho so validate fail " + sec.HoSoSo);
                    }
                    // listAllSec();
                }
                else
                {
                    if (validateObject(sec))
                    {
                        sec.ID = Int32.Parse(SecID);
                        um.updateHoSo(sec);
                        if (fulAttach.HasFile)
                        {
                            string filePath = attachLogic.createAttachment(Server.MapPath("~/files"), AttachmentLogic.ATTACHMENT_TYPE_HS, fulAttach.PostedFile.FileName, fulAttach, sec.ID);
                            Logger.logmessage(classobject, "btAddApprover_Click", "Attach success " + fulAttach.PostedFile.FileName);
                        }
                        //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.deleteAttachmentFromHoSo(sec.ID, k);
                                }
                            }
                        }
                    }
                    else
                    {
                        Logger.logmessage(classobject, "btAddApprover_Click", "Ho so validate fail " + sec.HoSoSo);
                    }
                }
                if (chkUploadMore.Checked)
                {
                    Response.Redirect("QLFileDinhKem.aspx?ObjectID=" + sec.ID.ToString() + "&ObjectType=" + AttachmentLogic.ATTACHMENT_TYPE_HS, false);
                }
                else
                {
                    Response.Redirect("QLHoSo.aspx", false);
                }
            }
            catch (Exception ex)
            {
                Logger.logmessage(classobject, "btAddApprover_Click", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
            }
        }