示例#1
0
        public void LoadContracts()
        {
            var agencyId = Agency.Id;

            rptContracts.DataSource = AgencyViewBLL.AgencyContractGetAllByAgency(agencyId);
            rptContracts.DataBind();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _editPermission             = Module.PermissionCheck(Permission.ACTION_EDITAGENCY, UserIdentity);
            _viewBookingPermission      = Module.PermissionCheck("VIEWBOOKINGBYAGENCY", UserIdentity);
            _contactsPermission         = Module.PermissionCheck("CONTACTS", UserIdentity);
            _recentActivitiesPermission = Module.PermissionCheck("RECENTACTIVITIES", UserIdentity);
            _contractsPermission        = Module.PermissionCheck("CONTRACTS", UserIdentity);

            if (!IsPostBack)
            {
                if (Request.QueryString["agencyid"] != null)
                {
                    var agency = Module.AgencyGetById(Convert.ToInt32(Request.QueryString["agencyid"]));

                    if (agency.Sale == UserIdentity)
                    {
                        _editPermission = true;
                    }
                    litName1.Text                  = agency.Name;
                    litName.Text                   = agency.Name;
                    litTradingName.Text            = agency.TradingName;
                    litRepresentative.Text         = agency.Representative;
                    litRepresentativePosition.Text = agency.RepresentativePosition;
                    litContact.Text                = agency.Contact;
                    litContactAddress.Text         = agency.ContactAddress;
                    litContactEmail.Text           = agency.ContactEmail;
                    litContactPosition.Text        = agency.ContactPosition;
                    if (agency.QAgentlevel != null)
                    {
                        litAgentLevel.Text = agency.QAgentlevel.Name;
                    }
                    litWebsite.Text = !String.IsNullOrEmpty(agency.Website) ? "<a href = " + agency.Website + ">" + agency.Website + "</a>" : "";
                    if (agency.Role != null)
                    {
                        litRole.Text = agency.Role.Name;
                    }
                    else
                    {
                        litRole.Text = "Customize Role";
                    }
                    if (agency.Sale != null)
                    {
                        litSale.Text = agency.Sale.AllName;
                    }
                    else
                    {
                        litSale.Text = @"Unbound";
                    }
                    litTax.Text = agency.TaxCode;
                    if (agency.Location != null)
                    {
                        litLocation.Text = agency.Location.Name;
                    }
                    litAddress.Text = agency.Address;

                    if (!string.IsNullOrEmpty(agency.Email))
                    {
                        hplEmail.NavigateUrl = string.Format("mailto:{0}", agency.Email);
                        hplEmail.Text        = agency.Email;
                    }
                    litPhone.Text = agency.Phone;

                    litPayment.Text = agency.PaymentPeriod.ToString();

                    litNote.Text = agency.Description;

                    var agencyId = Agency.Id;
                    rptContracts.DataSource = AgencyViewBLL.AgencyContractGetAllByAgency(agencyId);
                    rptContracts.DataBind();

                    rptContacts.DataSource = Module.ContactGetByAgency(agency, !_editPermission); // nếu không có quyền edit thì ko có quyền view
                    rptContacts.DataBind();

                    hplEditAgency.Visible     = _editPermission;
                    hplEditAgency.NavigateUrl = string.Format("AgencyEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}", Node.Id,
                                                              Section.Id, agency.Id);

                    hplAddContact.Visible     = _editPermission;
                    hplAddContact.NavigateUrl = "javascript:";
                    string url = string.Format("AgencyContactEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}",
                                               Node.Id, Section.Id, agency.Id);
                    hplAddContact.Attributes.Add("onclick", CMS.ServerControls.Popup.OpenPopupScript(url, "Contact", 300, 400));

                    url = string.Format("AgencyContractEdit.aspx?NodeId={0}&SectionId={1}&agencyid={2}",
                                        Node.Id, Section.Id, agency.Id);

                    hplBookingList.NavigateUrl = string.Format(
                        "BookingList.aspx?NodeId={0}&SectionId={1}&ai={2}", Node.Id, Section.Id, agency.Id);
                    hplReceivable.NavigateUrl =
                        string.Format("PaymentReport.aspx?NodeId={0}&SectionId={1}&ai={2}&from={3}&to={4}",
                                      Node.Id, Section.Id, agency.Id, DateTime.Today.AddMonths(-3).ToOADate(), DateTime.Today.ToOADate());

                    rptActivities.DataSource = Module.GetObject <Activity>(Expression.And(Expression.Eq("ObjectType", "MEETING"), Expression.Eq("Params", Convert.ToString(agency.Id))), 0, 0,
                                                                           Order.Desc("DateMeeting"));
                    rptActivities.DataBind();
                }
            }
            LoadContracts();
            RenderViewBookingByThisAgency();
            RenderContacts();
            RenderRecentActivities();
            RenderContracts();
            ddlContractTemplate.DataSource     = AgencyViewBLL.ContractGetAll();
            ddlContractTemplate.DataTextField  = "Name";
            ddlContractTemplate.DataValueField = "Id";
            ddlContractTemplate.DataBind();
            //ddlQuotationTemplate.DataSource = AgencyViewBLL.QuotationGetAll();
            //ddlQuotationTemplate.DataTextField = "Name";
            //ddlQuotationTemplate.DataValueField = "Id";
            //ddlQuotationTemplate.DataBind();
            ddlCruise.DataSource     = AgencyViewBLL.CruiseGetAll();
            ddlCruise.DataTextField  = "Name";
            ddlCruise.DataValueField = "Id";
            ddlCruise.DataBind();
            var agencyNotes = AgencyViewBLL.AgencyNotesGetAllByAgency(Agency);

            rptAgencyNotes.DataSource = agencyNotes.OrderBy(an => an.Role.Id);
            rptAgencyNotes.DataBind();
            var roles = AgencyViewBLL.RolesGetAll();

            ddlAgencyNotesRole.DataSource     = roles.Where(r => r.IsUsedInAgencyNotes == true);
            ddlAgencyNotesRole.DataTextField  = "Name";
            ddlAgencyNotesRole.DataValueField = "Id";
            ddlAgencyNotesRole.DataBind();
        }