コード例 #1
0
ファイル: MaterialReportDTO.cs プロジェクト: juinti/juinti
            public static TotalPriceReportDTOCollection GetTotalPricesGroupedByMonthByActivityID(long CaseID, DateTime?DateFrom, DateTime?DateTo, Int64 ActivityID)
            {
                TotalPriceReportDTOCollection c = new TotalPriceReportDTOCollection();

                SqlCommand             cmd    = new SqlCommand();
                SqlParameterCollection Params = cmd.Parameters;

                Params.Add(new SqlParameter("CaseID", CaseID));
                Params.Add(new SqlParameter("ActivityID", ActivityID));
                if (DateFrom != null)
                {
                    Params.Add(new SqlParameter("DateFrom", DateFrom));
                }
                if (DateTo != null)
                {
                    Params.Add(new SqlParameter("DateTo", DateTo));
                }

                DataTable dt = Execute.FillDataTable(StoredProcedures.GetTotalPricesGroupedByMonthByActivityID, Params);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        TotalPriceReportDTO o = new TotalPriceReportDTO();
                        LoadTotalPriceDTOByReader(row, o);
                        c.Add(o);
                    }
                }

                return(c);
            }
コード例 #2
0
ファイル: MaterialReportDTO.cs プロジェクト: juinti/juinti
            public static TotalPriceReportDTOCollection GetTotalPricesByDate(long CaseID, DateTime?DateFrom, DateTime?DateTo, long?ContractID, long?ActivityID, long?PartID, long?MaterialID, bool?IsOrdered)
            {
                TotalPriceReportDTOCollection c = new TotalPriceReportDTOCollection();

                SqlCommand             cmd    = new SqlCommand();
                SqlParameterCollection Params = cmd.Parameters;

                Params.Add(new SqlParameter("CaseID", CaseID));
                if (DateFrom != null)
                {
                    Params.Add(new SqlParameter("DateFrom", DateFrom));
                }
                if (DateTo != null)
                {
                    Params.Add(new SqlParameter("DateTo", DateTo));
                }
                if (ContractID != null)
                {
                    Params.Add(new SqlParameter("ContractID", ContractID));
                }
                if (ActivityID != null)
                {
                    Params.Add(new SqlParameter("ActivityID", ActivityID));
                }
                if (PartID != null)
                {
                    Params.Add(new SqlParameter("PartID", PartID));
                }
                if (MaterialID != null)
                {
                    Params.Add(new SqlParameter("MaterialID", MaterialID));
                }
                if (IsOrdered != null)
                {
                    Params.Add(new SqlParameter("IsOrdered", IsOrdered));
                }


                DataTable dt = Execute.FillDataTable(StoredProcedures.GetTotalPricesByDate, Params);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        TotalPriceReportDTO o = new TotalPriceReportDTO();
                        LoadTotalPriceDTOByReader(row, o);
                        c.Add(o);
                    }
                }

                return(c);
            }
コード例 #3
0
    protected void btnGetReport_Click(object sender, EventArgs e)
    {
        DateTime dateFrom   = !String.IsNullOrEmpty(txtDateFrom.Text) ? Convert.ToDateTime(txtDateFrom.Text) : Convert.ToDateTime("1790-01-01 00:00:00");
        DateTime dateTo     = !String.IsNullOrEmpty(txtDateTo.Text) ? Convert.ToDateTime(txtDateTo.Text) : DateTime.MaxValue.AddYears(-1);
        Int64    materialID = Convert.ToInt64(ddlMaterial.SelectedValue);
        Int64    activityID = Convert.ToInt64(ddlActivity.SelectedValue);
        Int64    partID     = Convert.ToInt64(ddlPart.SelectedValue);
        string   title      = "";

        try
        {
            TotalPriceReportDTOCollection prices    = new TotalPriceReportDTOCollection();
            MaterialReportDTOCollection   materials = new MaterialReportDTOCollection();

            if (materialID > 0)
            {
                prices    = TotalPriceReportDTO.Utils.GetTotalPricesGroupedByMonthByMaterialID(caseID, dateFrom, dateTo, materialID);
                materials = MaterialReportDTO.Utils.GetAllWaiveMaterialsByDate(caseID, dateFrom, dateTo, null, null, null, materialID, null);
                title     = new Material(materialID).Title;
            }
            else if (partID > 0)
            {
                prices = TotalPriceReportDTO.Utils.GetTotalPricesGroupedByMonthByPartID(caseID, dateFrom, dateTo, partID);
                title  = new Part(partID).Title;
            }
            else if (activityID > 0)
            {
                prices = TotalPriceReportDTO.Utils.GetTotalPricesGroupedByMonthByActivityID(caseID, dateFrom, dateTo, activityID);
                title  = new Activity(activityID).Title;
            }
            else
            {
                prices = TotalPriceReportDTO.Utils.GetTotalPricesGroupedByMonth(caseID, dateFrom, dateTo);
                title  = "Total";
            }

            renderPrices(prices, title);



            RenderChartScript(materials);
        }
        catch (Exception ex)
        {
            Response.Write(ex);
        }
    }
コード例 #4
0
    private void renderPrices(TotalPriceReportDTOCollection prices, string Title)
    {
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter writer = new HtmlTextWriter(sw))
            {
                decimal TotalTotalPrice = 0;

                litTitle.Text = Title;

                writer.AddAttribute("class", "reporttable");
                writer.RenderBeginTag(HtmlTextWriterTag.Table);

                foreach (var item in prices)
                {
                    TotalTotalPrice += item.Totalprice;
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.Write(Convert.ToDateTime(item.Year + "-" + item.Month).ToString("yyyy MMM"));
                    writer.RenderEndTag(); // Td
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.Write(item.Totalprice.ToString("N2"));
                    writer.RenderEndTag(); // Td
                    writer.RenderEndTag(); // Tr
                }
                writer.AddAttribute("class", "total");
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write("Total");
                writer.RenderEndTag(); // Td
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write(TotalTotalPrice.ToString("N2"));
                writer.RenderEndTag(); // Td
                writer.RenderEndTag(); // Tr
                writer.RenderEndTag(); // Table
            }
            litTotalPrices.Text = sw.ToString();
        }
    }