Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string id     = Request["ObjectID"];
                string type   = Request["ObjectType"];
                string idRoot = Request["RootId"];

                int iId = 0;
                Int32.TryParse(id, out iId);
                hidId.Value     = id;
                hidPrefix.Value = type;
                if (idRoot != null)
                {
                    hidRootId.Value = idRoot;
                }
                //load dropbox
                bindingDDLs();
                if (AttachmentLogic.ATTACHMENT_TYPE_HS.Equals(type))
                {
                    try
                    {
                        curHoSo                 = dataContext.Su_HoSos.Where(p => p.ID == iId).First();
                        row1VB.Visible          = false;
                        row2VB.Visible          = false;
                        row3VB.Visible          = false;
                        vbTaiLieu.Visible       = false;
                        ddlCoQuan.SelectedValue = curHoSo.Coquan;
                        ddlPhong.SelectedValue  = curHoSo.MaPhong;
                        ddlMucLuc.SelectedValue = curHoSo.MucLucSo;
                        txtHoSoSo.Text          = curHoSo.HoSoSo;
                        //txtKyHieu.Text = curHoSo.KyHieu;
                        //txtSoluongto.Text = curHoSo.SoLuong;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Page_Load error: ", ex);
                    }
                }
                else if (AttachmentLogic.ATTACHMENT_TYPE_VB.Equals(type))
                {
                    try
                    {
                        curVanBan = dataContext.Su_VanbanTrongHoSos.Where(p => p.ID == iId).First();
                        int hsId = 0;
                        Int32.TryParse(curVanBan.Hoso_ID, out hsId);
                        curHoSo = dataContext.Su_HoSos.Where(p => p.ID == hsId).First();
                        ddlCoQuan.SelectedValue = curHoSo.Coquan;
                        ddlPhong.SelectedValue  = curHoSo.MaPhong;
                        ddlMucLuc.SelectedValue = curHoSo.MucLucSo;
                        txtHoSoSo.Text          = curHoSo.HoSoSo;
                        txtKyHieu.Text          = curVanBan.KyHieuVanBan;
                        txtSoluongto.Text       = curVanBan.SoLuongTo;
                        vbHoSo.Visible          = false;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Page_Load error: ", ex);
                    }
                }
                else
                {
                    throw new Exception("Request data error");
                }
                List <Su_Attachment> lstAttach = logic.getAttachment(type, iId);
                rptDocs.DataSource = lstAttach;
                rptDocs.DataBind();
            }
            catch (Exception ex)
            {
                logger.Error("Page load error: ", ex);
                Response.Redirect("~/ThongBaoLoi.aspx", false);
            }
        }
Esempio n. 2
0
        protected void onDgvDatabind(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    Su_VanbanTrongHoSo item = (Su_VanbanTrongHoSo)e.Row.DataItem;
                    if (item != null)
                    {
                        List <Su_Attachment> lstAttachment = attachLogic.getAttachment(AttachmentLogic.ATTACHMENT_TYPE_VB, item.ID);
                        Repeater             rpt           = (Repeater)e.Row.Cells[6].FindControl("rptAttachment");
                        if (rpt != null)
                        {
                            rpt.DataSource = lstAttachment;
                            rpt.DataBind();
                        }
                        Label lblCoQuan = null, lblLoaiVanBan = null, lblDoMat = null, lblSTT = null;
                        lblCoQuan     = (Label)e.Row.FindControl("lblCoQuan");
                        lblLoaiVanBan = (Label)e.Row.FindControl("lblLoaiVanBan");
                        lblDoMat      = (Label)e.Row.FindControl("lblDoMat");
                        lblSTT        = (Label)e.Row.FindControl("lblSTT");
                        if (lblSTT != null)
                        {
                            stt++;
                            lblSTT.Text = stt.ToString();
                        }
                        if (lblCoQuan != null)
                        {
                            lblCoQuan.Text = item.TacGia;
                            //foreach (Su_CoQuanLuuTru cq in lstCoQuan)
                            //{
                            //    if (cq.Code.Equals(item.CoQuan))
                            //    {
                            //        lblCoQuan.Text = cq.Name;
                            //        break;
                            //    }
                            //}
                        }
                        if (lblLoaiVanBan != null)
                        {
                            foreach (Su_LoaiVanban cq in lstLoaiVanBan)
                            {
                                if (cq.ID.ToString().Equals(item.LoaiVanBan))
                                {
                                    lblLoaiVanBan.Text = cq.Name;
                                    break;
                                }
                            }
                        }
                        if (lblDoMat != null)
                        {
                            foreach (Su_DoMat cq in lstDoMat)
                            {
                                if (cq.ID.ToString().Equals(item.DoMat))
                                {
                                    lblDoMat.Text = cq.Name;
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (e.Row.RowType == DataControlRowType.Pager)
                {
                    e.Row.Visible = true;
                    DropDownList pageList  = (DropDownList)e.Row.FindControl("PageDropDownList");
                    Label        pageLabel = (Label)e.Row.FindControl("CurrentPageLabel");

                    if (pageList != null)
                    {
                        // Create the values for the DropDownList control based on
                        // the  total number of pages required to display the data
                        // source.
                        for (int i = 0; i < pageCount; i++)
                        {
                            // Create a ListItem object to represent a page.
                            int      pageNumber = i + 1;
                            ListItem li         = new ListItem(pageNumber.ToString());

                            // If the ListItem object matches the currently selected
                            // page, flag the ListItem object as being selected. Because
                            // the DropDownList control is recreated each time the pager
                            // row gets created, this will persist the selected item in
                            // the DropDownList control.
                            if (i == pageIndex - 1)
                            {
                                li.Selected = true;
                            }

                            // Add the ListItem object to the Items collection of the
                            // DropDownList.
                            pageList.Items.Add(li);
                        }
                    }

                    if (pageLabel != null)
                    {
                        // Calculate the current page number.
                        int currentPage = pageIndex;

                        // Update the Label control with the current page information.
                        pageLabel.Text = "Page " + currentPage.ToString() +
                                         " of " + pageCount;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Dgv data bind error: ", ex);
                Response.Redirect("~/ThongBaoLoi.aspx", false);
            }
        }