コード例 #1
0
        private void Save()
        {
            // Validate data
            bool validData = false;

            Page.Validate("Data");
            if (Page.IsValid)
            {
                validData = true;
            }

            if (validData)
            {
                // Save data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int projectId = Int32.Parse(hdfProjectId.Value);
                int refId = Int32.Parse(hdfRefId.Value);
                Int64 countryId = Int64.Parse(hdfCountryId.Value);

                // ... Get subcontractor hors data
                DateTime? newDate = tkrdpDate_.SelectedDate;
                decimal newRateCad = 0;
                decimal newRateUsd = 0;

                if (countryId == 1) // Canada
                {
                    newRateCad = decimal.Parse(tbxRate.Text.Trim());
                }
                else
                {
                    newRateUsd = decimal.Parse(tbxRate.Text.Trim());
                }
                string newComment = tbxComments.Text.Trim();
                string category = hdfCategory.Value;

                // Update basic information data
                if (category == "Subcontractors")
                {
                    double newQuantity = double.Parse(tbxQuantity.Text.Trim());
                    decimal newTotalCad = 0;
                    decimal newTotalUsd = 0;

                    if (countryId == 1) // Canada
                    {
                        newTotalCad = decimal.Parse(tbxTotal.Text.Trim());
                    }
                    else
                    {
                        newTotalUsd = decimal.Parse(tbxTotal.Text.Trim());
                    }

                    ActualCostsInformationSubcontractorBasicInformation actualCostsInformationSubcontractorBasicInformation = new ActualCostsInformationSubcontractorBasicInformation(actualCostsInformationTDS);
                    actualCostsInformationSubcontractorBasicInformation.Update(projectId, refId, (DateTime)newDate, newQuantity, newRateCad, newTotalCad, newRateUsd, newTotalUsd, newComment);
                }
                else
                {
                    if (category == "Hotels")
                    {
                        ActualCostsInformationHotelCostsBasicInformation actualCostsInformationHotelCostsBasicInformation = new ActualCostsInformationHotelCostsBasicInformation(actualCostsInformationTDS);
                        actualCostsInformationHotelCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                    }
                    else
                    {
                        if (category == "Insurance")
                        {
                            ActualCostsInformationInsuranceCostsBasicInformation actualCostsInformationInsuranceCostsBasicInformation = new ActualCostsInformationInsuranceCostsBasicInformation(actualCostsInformationTDS);
                            actualCostsInformationInsuranceCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                        }
                        else
                        {
                            if (category == "Bonding")
                            {
                                ActualCostsInformationBondingCostsBasicInformation actualCostsInformationBondingCostsBasicInformation = new ActualCostsInformationBondingCostsBasicInformation(actualCostsInformationTDS);
                                actualCostsInformationBondingCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                            }
                            else
                            {
                                // other categories
                                ActualCostsInformationOtherCostsBasicInformation actualCostsInformationOtherCostsBasicInformation = new ActualCostsInformationOtherCostsBasicInformation(actualCostsInformationTDS);
                                actualCostsInformationOtherCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                            }
                        }
                    }
                }

                // Store datasets
                Session["actualCostsInformationTDS"] = actualCostsInformationTDS;

                // Update database
                UpdateDatabase();

                ViewState["update"] = "yes";

                // Redirect
                string url = "";
                if (Request.QueryString["source_page"] == "actual_costs_navigator2.aspx" )
                {
                    url = "./actual_costs_navigator2.aspx?source_page=actual_costs_edit.aspx&project_id=" + hdfProjectId.Value + "&ref_id=" + hdfRefId.Value + GetNavigatorState() + "&update=yes" + "&category=" + hdfCategory.Value;
                }

                if (Request.QueryString["source_page"] == "actual_costs_summary.aspx")
                {
                    url = "./actual_costs_summary.aspx?source_page=actual_costs_edit.aspx&project_id=" + hdfProjectId.Value + "&ref_id=" + hdfRefId.Value + GetNavigatorState() + "&update=yes" + "&category=" + hdfCategory.Value;
                }

                Response.Redirect(url);
            }
        }
コード例 #2
0
        private void Apply()
        {
            // Validate data
            bool validData = false;

            Page.Validate("Data");
            if (Page.IsValid)
            {
                validData = true;
            }

            if (validData)
            {
                // Save data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int projectId = Int32.Parse(hdfProjectId.Value);
                int refId = Int32.Parse(hdfRefId.Value);
                Int64 countryId = Int64.Parse(hdfCountryId.Value);

                // ... Get subcontractor hors data
                DateTime? newDate = tkrdpDate_.SelectedDate;

                decimal newRateCad = 0;
                decimal newRateUsd = 0;

                if (countryId == 1) // Canada
                {
                    newRateCad = decimal.Parse(tbxRate.Text.Trim());
                }
                else
                {
                    newRateUsd = decimal.Parse(tbxRate.Text.Trim());
                }
                string newComment = tbxComments.Text.Trim();
                string category = hdfCategory.Value;

                // Update basic information data
                if (category == "Subcontractors")
                {
                    double newQuantity = double.Parse(tbxQuantity.Text.Trim());
                    decimal newTotalCad = 0;
                    decimal newTotalUsd = 0;

                    if (countryId == 1) // Canada
                    {
                        newTotalCad = decimal.Parse(tbxTotal.Text.Trim());
                    }
                    else
                    {
                        newTotalUsd = decimal.Parse(tbxTotal.Text.Trim());
                    }

                    ActualCostsInformationSubcontractorBasicInformation actualCostsInformationSubcontractorBasicInformation = new ActualCostsInformationSubcontractorBasicInformation(actualCostsInformationTDS);
                    actualCostsInformationSubcontractorBasicInformation.Update(projectId, refId, (DateTime)newDate, newQuantity, newRateCad, newTotalCad, newRateUsd, newTotalUsd, newComment);
                }
                else
                {
                    if (category == "Hotels")
                    {
                        ActualCostsInformationHotelCostsBasicInformation actualCostsInformationHotelCostsBasicInformation = new ActualCostsInformationHotelCostsBasicInformation(actualCostsInformationTDS);
                        actualCostsInformationHotelCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                    }
                    else
                    {
                        if (category == "Insurance")
                        {
                            ActualCostsInformationInsuranceCostsBasicInformation actualCostsInformationInsuranceCostsBasicInformation = new ActualCostsInformationInsuranceCostsBasicInformation(actualCostsInformationTDS);
                            actualCostsInformationInsuranceCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                        }
                        else
                        {
                            if (category == "Bonding")
                            {
                                ActualCostsInformationBondingCostsBasicInformation actualCostsInformationBondingCostsBasicInformation = new ActualCostsInformationBondingCostsBasicInformation(actualCostsInformationTDS);
                                actualCostsInformationBondingCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                            }
                            else
                            {
                                // for other categories
                                ActualCostsInformationOtherCostsBasicInformation actualCostsInformationOtherCostsBasicInformation = new ActualCostsInformationOtherCostsBasicInformation(actualCostsInformationTDS);
                                actualCostsInformationOtherCostsBasicInformation.Update(projectId, refId, (DateTime)newDate, newRateCad, newRateUsd, newComment);
                            }
                        }
                    }
                }

                // Store datasets
                Session["actualCostsInformationTDS"] = actualCostsInformationTDS;

                // Update database
                UpdateDatabase();

                ViewState["update"] = "yes";
            }
        }