Ejemplo n.º 1
0
    private void CreatePackagesList()
    {
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter writer = new HtmlTextWriter(sw))
            {
                PackageCollection packages = Package.Utils.GetPackagesByWaiveID(waiveID);

                Waive waive = new Waive(waiveID);
                if (packages.Count() > 0)
                {
                    writer.AddAttribute("class", "listview");
                    writer.AddAttribute("cellspacing", "0");
                    writer.AddAttribute("cellpadding", "0");
                    writer.RenderBeginTag(HtmlTextWriterTag.Table);
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.AddAttribute("class", "package");
                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write(Resources.PackageTexts.Package);
                    writer.RenderEndTag(); // Th


                    writer.AddAttribute("class", "amount");
                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write(Resources.PackageTexts.Amount);
                    writer.RenderEndTag(); // Th

                    writer.AddAttribute("class", "produtionweeks");
                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write(Resources.PackageTexts.ListHeaderProductionWeeks);
                    writer.RenderEndTag(); // Th

                    writer.AddAttribute("class", "delete");
                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write(Resources.Global.ListHeaderButtons);
                    writer.RenderEndTag(); // Th
                    writer.RenderEndTag(); // Tr
                    foreach (var package in packages)
                    {
                        Activity activity = new Activity(package.ActivityID);

                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        writer.AddAttribute("class", "package");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.AddAttribute("href", Urls.PackageUrl + "?caseid=" + caseID + "&packageid=" + package.ID + "&activityid=" + package.ActivityID + "&pagetype=package");
                        writer.RenderBeginTag(HtmlTextWriterTag.A);
                        writer.AddAttribute("class", "title");
                        writer.RenderBeginTag(HtmlTextWriterTag.Span);
                        writer.Write(package.Title + " - " + activity.Title);
                        writer.RenderEndTag(); //Span
                        writer.RenderEndTag(); // A
                        writer.RenderEndTag(); // Td
                        writer.AddAttribute("class", "amount");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.AddAttribute("class", "amount");
                        writer.RenderBeginTag(HtmlTextWriterTag.Span);
                        writer.Write(package.WaiveAmount);
                        if (!waive.IsOrdered)
                        {
                            writer.AddAttribute("class", "fa fa-pencil edit");
                            writer.AddAttribute("onclick", "return editPackageAmount(" + package.ID + ", '" + package.Title + "', " + package.WaiveAmount + ", " + package.WaiveProductionWeeks + ");");
                            writer.RenderBeginTag(HtmlTextWriterTag.I);
                            writer.RenderEndTag(); // I
                        }
                        writer.RenderEndTag();     // Span
                        writer.RenderEndTag();     // Td

                        writer.AddAttribute("class", "amount");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.AddAttribute("class", "amount");
                        writer.RenderBeginTag(HtmlTextWriterTag.Span);
                        writer.Write(package.WaiveProductionWeeks);
                        if (!waive.IsOrdered)
                        {
                            writer.AddAttribute("class", "fa fa-pencil edit");
                            writer.AddAttribute("onclick", "return editPackageProdutionWeeks(" + package.ID + ", '" + package.Title + "', " + package.WaiveAmount + ", " + package.WaiveProductionWeeks + ");");
                            writer.RenderBeginTag(HtmlTextWriterTag.I);
                            writer.RenderEndTag(); // I
                        }
                        writer.RenderEndTag();     // Span
                        writer.RenderEndTag();     // Td

                        writer.AddAttribute("class", "delete");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        if (!waive.IsOrdered)
                        {
                            writer.AddAttribute("class", "fa fa fa-times remove");
                            writer.AddAttribute("onclick", "return removePackage(" + package.ID + ", '" + package.Title + "');");
                            writer.RenderBeginTag(HtmlTextWriterTag.I);
                            writer.RenderEndTag(); // I
                        }
                        writer.RenderEndTag();     //Td

                        writer.RenderEndTag();     // Tr
                    }

                    writer.RenderEndTag(); // Table
                }
                litPackagesList.Text = sw.ToString();
            }
        }
    }