Ejemplo n.º 1
0
 /// <summary>
 /// LoadByCountryIdClientIdStartDateEndDate
 /// </summary>
 /// <param name="country">country</param>
 /// <param name="clientId">clientId</param>
 /// <param name="startDate">startDate</param>
 /// <param name="endDate">endDate</param>
 /// <param name="companyId">companyId</param>
 public void LoadByCountryIdClientIdStartDateEndDate(int country, int clientId, DateTime startDate, DateTime endDate, int companyId)
 {
     ProductionReportGateway productionReportGateway = new ProductionReportGateway(Data);
     productionReportGateway.LoadByCountryIdClientIdStartDateEndDate(country, clientId, startDate, endDate, companyId);
 }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            int companyId = Int32.Parse(hdfCompanyId.Value);
            LiquiForce.LFSLive.BL.Projects.Projects.ProductionReport productionReport = new LiquiForce.LFSLive.BL.Projects.Projects.ProductionReport();

            if (ddlCountry.SelectedValue == "(All)")
            {
                if (ddlClient.SelectedValue == "-1")
                {
                    productionReport.LoadByStartDateEndDate(startDate, endDate, companyId);
                }
                else
                {
                    int clientId = int.Parse(ddlClient.SelectedValue);

                    if (ddlProject.SelectedValue == "-1")
                    {
                        productionReport.LoadByClientIdStartDateEndDate(clientId, startDate, endDate, companyId);
                    }
                    else
                    {
                        int projectId = int.Parse(ddlProject.SelectedValue);
                        productionReport.LoadByClientIdProjectIdStartDateEndDate(clientId, projectId, startDate, endDate, companyId);
                    }
                }
            }
            else
            {
                int country = Int32.Parse(ddlCountry.SelectedValue);

                if (ddlClient.SelectedValue == "-1")
                {
                    productionReport.LoadByCountryIdStartDateEndDate(country, startDate, endDate, companyId);
                }
                else
                {
                    int clientId = int.Parse(ddlClient.SelectedValue);

                    if (ddlProject.SelectedValue == "-1")
                    {
                        productionReport.LoadByCountryIdClientIdStartDateEndDate(country, clientId, startDate, endDate, companyId);
                    }
                    else
                    {
                        int projectId = int.Parse(ddlProject.SelectedValue);
                        productionReport.LoadByCountryIdClientIdProjectIdStartDateEndDate(country, clientId, projectId, startDate, endDate, companyId);
                    }
                }
            }

            LiquiForce.LFSLive.DA.Projects.Projects.ProductionReportGateway productionReportGateway = new LiquiForce.LFSLive.DA.Projects.Projects.ProductionReportGateway(productionReport.Data);

            // ... set properties to master page
            master.Data = productionReportGateway.Data;
            master.Table = productionReportGateway.TableName;

            // Get report
            if (productionReportGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.ProductionReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.ProductionReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... ...  user
                    int loginId = Convert.ToInt32(Session["loginID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }

                    // ... ... project
                    if (ddlProject.SelectedValue == "-1")
                    {
                        master.SetParameter("Project", "All");
                    }
                    else
                    {
                        int projectId2 = Int32.Parse(ddlProject.SelectedValue);
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(projectId2);
                        string project = projectGateway.GetName(projectId2);
                        master.SetParameter("Project", project);
                    }

                    // ... ... Date
                    string startDateParameter = tkrdpStartDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("StartDate", startDateParameter);

                    string endDateParameter = tkrdpEndDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("EndDate", endDateParameter);

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("Client", "All");
                    }
                    else
                    {
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);

                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                    }
                }
                else
                {
                    // ... ... Date
                    string startDateParameter = tkrdpStartDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("StartDate", startDateParameter);

                    string endDateParameter = tkrdpEndDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("EndDate", endDateParameter);
                }
            }
        }
Ejemplo n.º 3
0
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadByStartDateEndDate
 /// </summary>
 /// <param name="startDate">startDate</param>
 /// <param name="endDate">endDate</param>
 /// <param name="companyId">companyId</param>
 public void LoadByStartDateEndDate(DateTime startDate, DateTime endDate, int companyId)
 {
     ProductionReportGateway productionReportGateway = new ProductionReportGateway(Data);
     productionReportGateway.LoadByStartDateEndDate(startDate, endDate, companyId);
 }