protected void rptAgencies_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is vAgency)
            {
                vAgency agency = (vAgency)e.Item.DataItem;
                index++;
                Literal litNo = e.Item.FindControl("litNo") as Literal;
                if (litNo != null)
                {
                    litNo.Text = index.ToString();
                }

                HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;
                if (hplName != null)
                {
                    hplName.Text        = agency.Name;
                    hplName.NavigateUrl = string.Format("PaymentReport.aspx?NodeId={0}&SectionId={1}&agencyid={2}&mode=all",
                                                        Node.Id, Section.Id, agency.Id);
                }

                Literal litTotal = e.Item.FindControl("litTotal") as Literal;
                if (litTotal != null)
                {
                    double receivable = (agency.Total - agency.Paid) * _currentRate.Rate - agency.PaidBase;
                    litTotal.Text = receivable.ToString("#,0.#");
                    _total       += receivable;
                }
            }
            else if (e.Item.ItemType == ListItemType.Footer)
            {
                Literal litTotal = e.Item.FindControl("litTotal") as Literal;
                if (litTotal != null)
                {
                    litTotal.Text = _total.ToString("#,0.#");
                }
            }
        }
        protected void rptPayables_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is vAgency)
            {
                vAgency agency = (vAgency)e.Item.DataItem;
                index++;
                Literal litNo = e.Item.FindControl("litNo") as Literal;
                if (litNo != null)
                {
                    litNo.Text = index.ToString();
                }

                HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;
                if (hplName != null)
                {
                    hplName.Text        = agency.Name;
                    hplName.NavigateUrl = string.Format("PayableList.aspx?NodeId={0}&SectionId={1}&supplierid={2}&mode=all",
                                                        Node.Id, Section.Id, agency.Id);
                }

                Literal litTotal = e.Item.FindControl("litTotal") as Literal;
                if (litTotal != null)
                {
                    double payable = agency.Payable;
                    litTotal.Text = payable.ToString("#,0.#");
                    _payable     += payable;
                }
            }
            else if (e.Item.ItemType == ListItemType.Footer)
            {
                Literal litTotal = e.Item.FindControl("litTotal") as Literal;
                if (litTotal != null)
                {
                    litTotal.Text = _payable.ToString("#,0.#");
                }
            }
        }
        protected void rptAgencies_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is vAgency)
            {
                vAgency   agency  = (vAgency)e.Item.DataItem;
                HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;
                if (hplName != null)
                {
                    hplName.Text        = agency.Name;
                    hplName.NavigateUrl = string.Format("AgencyView.aspx{0}&AgencyId={1}", GetBaseQueryString(), agency.Id);
                }

                HtmlAnchor aName = e.Item.FindControl("aName") as HtmlAnchor;
                if (aName != null)
                {
                    aName.InnerHtml = agency.Name;
                    aName.Attributes.CssStyle.Add("cursor", "pointer");

                    string script = string.Format("Done('{0}','{1}')", agency.Name.Replace("'", @"\'"), agency.Id);
                    aName.Attributes.Add("onclick", script);
                }

                HyperLink hplEdit = e.Item.FindControl("hplEdit") as HyperLink;
                if (hplEdit != null)
                {
                    hplEdit.NavigateUrl = string.Format("AgencyEdit.aspx{0}&AgencyId={1}", GetBaseQueryString(), agency.Id);
                }

                Literal litRole = e.Item.FindControl("litRole") as Literal;
                if (litRole != null)
                {
                    var hyperLink = e.Item.FindControl("hplPriceSetting") as HyperLink;
                    if (hyperLink != null)
                    {
                        if (agency.Role != null)
                        {
                            litRole.Text      = agency.Role.Name;
                            hyperLink.Visible = false;
                        }
                        else
                        {
                            litRole.Text      = "Customize Role";
                            hyperLink.Visible = true;
                        }
                    }
                    else
                    {
                        Debug.WriteLine("hplPriceSetting = null");
                    }
                }

                Literal litContract = e.Item.FindControl("litContract") as Literal;
                if (litContract != null)
                {
                    switch (agency.ContractStatus)
                    {
                    case 0:
                        litContract.Text = @"No contract";
                        break;

                    case 1:
                        litContract.Text = @"Expired";
                        break;

                    case 2:
                        litContract.Text = @"Contract in valid";
                        break;

                    case 3:
                        litContract.Text = @"Expire soon";
                        break;

                    case 4:
                        litContract.Text = @"Contract sent";
                        break;
                    }
                }

                var trItem = e.Item.FindControl("trItem") as HtmlTableRow;
                if (trItem != null)
                {
                    switch (agency.ContractStatus)
                    {
                    case 0:     // No contract
                        trItem.Attributes.Add("class", "danger");
                        break;

                    case 1:     // Contract expired
                        trItem.Attributes.Add("class", "active");
                        break;

                    case 2:     // Có hợp đồng và chưa hết hạn trong vòng 30 ngày
                        trItem.Attributes.Add("class", "success");
                        break;

                    case 3:     // Có hợp đồng nhưng sẽ hết hạn trong vòng 30 ngày
                        trItem.Attributes.Add("class", "warning");
                        break;

                    case 4:
                        trItem.Attributes.CssStyle.Add("background-color", "greenyellow");
                        break;
                    }
                }

                if (agency.ContractStatus != 0)
                {
                    if (string.IsNullOrEmpty(agency.Contract))
                    {
                        HyperLink hplContract = e.Item.FindControl("hplContract") as HyperLink;
                        if (hplContract != null)
                        {
                            hplContract.Visible = false;
                        }
                    }
                    else
                    {
                        HyperLink hplContract = e.Item.FindControl("hplContract") as HyperLink;
                        if (hplContract != null)
                        {
                            hplContract.Text        = @"[View]";
                            hplContract.NavigateUrl = agency.Contract;
                        }
                    }
                }

                ValueBinder.BindLiteral(e.Item, "litPayment", agency.PaymentPeriod);

                var litIndex = e.Item.FindControl("litIndex") as Literal;
                if (litIndex != null)
                {
                    litIndex.Text = (e.Item.ItemIndex + pagerBookings.PageSize * pagerBookings.CurrentPageIndex + 1) + ".";
                }

                var litSale = e.Item.FindControl("litSale") as Literal;
                if (litSale != null)
                {
                    if (agency.Sale != null)
                    {
                        litSale.Text = agency.Sale.UserName;
                    }
                }

                var hplPriceSetting = e.Item.FindControl("hplPriceSetting") as HyperLink;
                if (hplPriceSetting != null)
                {
                    hplPriceSetting.NavigateUrl =
                        string.Format("PriceConfiguration.aspx?NodeId={0}&SectionId={1}&agentid={2}", Node.Id, Section.Id,
                                      agency.Id);
                }

                HtmlTableCell tdLastBooking = e.Item.FindControl("tdLastBooking") as HtmlTableCell;
                if (tdLastBooking != null)
                {
                    if (agency.LastBooking.HasValue)
                    {
                        tdLastBooking.InnerHtml = string.Format("{0} (<a href='{1}'>list</a>) ",
                                                                agency.LastBooking.Value.ToString("dd/MM/yyyy"),
                                                                string.Format(
                                                                    "BookingList.aspx?NodeId={0}&SectionId={1}&ai={2}",
                                                                    Node.Id, Section.Id, agency.Id));
                    }
                    else
                    {
                        tdLastBooking.InnerText = "Never";
                    }
                }
            }
        }
示例#4
0
        protected void rptAgencies_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is vAgency)
            {
                vAgency   agency  = (vAgency)e.Item.DataItem;
                HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;
                if (hplName != null)
                {
                    hplName.Text        = agency.Name;
                    hplName.NavigateUrl = string.Format("AgencyView.aspx{0}&AgencyId={1}", GetBaseQueryString(), agency.Id);
                }

                HtmlAnchor aName = e.Item.FindControl("aName") as HtmlAnchor;
                if (aName != null)
                {
                    aName.InnerHtml = agency.Name;
                    aName.Attributes.CssStyle.Add("cursor", "pointer");

                    string script = string.Format("Done('{0}','{1}')", agency.Name.Replace("'", @"\'"), agency.Id);
                    aName.Attributes.Add("onclick", script);
                }

                HyperLink hplEdit = e.Item.FindControl("hplEdit") as HyperLink;
                if (hplEdit != null)
                {
                    hplEdit.NavigateUrl = string.Format("AgencyEdit.aspx{0}&AgencyId={1}", GetBaseQueryString(), agency.Id);
                }

                Literal litRole = e.Item.FindControl("litRole") as Literal;
                if (litRole != null)
                {
                    if (agency.Role != null)
                    {
                        litRole.Text = agency.Role.Name;
                    }
                }

                Literal litContract = e.Item.FindControl("litContract") as Literal;
                if (litContract != null)
                {
                    switch (agency.ContractStatus)
                    {
                    case 0:
                        litContract.Text = "No";
                        break;

                    case 1:
                        litContract.Text = "Pending";
                        break;

                    case 2:
                        litContract.Text = "Yes";
                        break;
                    }
                }

                if (agency.ContractStatus != 0)
                {
                    if (string.IsNullOrEmpty(agency.Contract))
                    {
                        HyperLink hplContract = e.Item.FindControl("hplContract") as HyperLink;
                        if (hplContract != null)
                        {
                            hplContract.Visible = false;
                        }
                    }
                    else
                    {
                        HyperLink hplContract = e.Item.FindControl("hplContract") as HyperLink;
                        if (hplContract != null)
                        {
                            hplContract.Text        = "[View]";
                            hplContract.NavigateUrl = agency.Contract;
                        }
                    }
                }

                Literal litIndex = e.Item.FindControl("litIndex") as Literal;
                if (litIndex != null)
                {
                    litIndex.Text = (e.Item.ItemIndex + pagerBookings.PageSize * pagerBookings.CurrentPageIndex + 1) + ".";
                }

                Literal litSale = e.Item.FindControl("litSale") as Literal;
                if (litSale != null)
                {
                    if (agency.Sale != null)
                    {
                        litSale.Text = agency.Sale.UserName;
                    }
                }

                HyperLink hplPriceSetting = e.Item.FindControl("hplPriceSetting") as HyperLink;
                if (hplPriceSetting != null)
                {
                    hplPriceSetting.NavigateUrl =
                        string.Format("SailsTripList.aspx?NodeId={0}&SectionId={1}&agencyid={2}", Node.Id, Section.Id,
                                      agency.Id);
                }

                HtmlTableCell tdLastBooking = e.Item.FindControl("tdLastBooking") as HtmlTableCell;
                if (tdLastBooking != null)
                {
                    if (agency.LastBooking.HasValue)
                    {
                        tdLastBooking.InnerText = agency.LastBooking.Value.ToString("dd/MM/yyyy");
                    }
                    else
                    {
                        tdLastBooking.InnerText = "Never";
                    }
                }
            }
        }