Exemplo n.º 1
0
        public void BindCostSheet(string CostSheetID, string NetworkID, string WorkOrderID, bool IsNew = false, int PreviousCostSheet = 0, int Archive = 1)
        {
            try
            {
                bIsLoading = true;

                if (PreviousCostSheet == 0)
                {
                    IsAdjusted(WorkOrderID);
                }

                myForecast.LoadFromSqlServer(CostSheetID, NetworkID, WorkOrderID, PreviousCostSheet, Archive);

                ForecastDetail_GridControl.DataSource = DataTableFromList(myForecast.forecastCostSheetDetails, null, null);

                Parts_GridControl.DataSource = DataTableFromList(null, myForecast.Parts, null);

                Disciplines_GridControl.DataSource = DataTableFromList(null, null, myForecast.forecastCostSheetDisciplines);

                Revision_barStaticItem.Caption = "Revision: " + myForecast.AddedOn.ToString("MM/dd/yyyy") + " added by " + GetFullName(myForecast.AddedBy);

                QuoteWorkOrder_barListItem.Caption = "Q-" + myForecast.QuoteID + "\r\n" + "W-" + myForecast.WorkOrderID;

                ProjectManager_Label.Text = myForecast.ProjectManager;

                MonthsToComplete_Label.Text = String.Format("{0:N}", myForecast.MonthsToComplete);
                HoursPerMonth_Label.Text    = String.Format("{0:N}", myForecast.HoursPerMonth);
                MenPerMonth_Label.Text      = String.Format("{0:N}", myForecast.MenPerMonth);

                Target_DateEdit.EditValue  = myForecast.TargetDate;
                EndDate_DateEdit.EditValue = myForecast.EndDate;

                LabourCost_Label.Text    = String.Format("{0:C}", myForecast.TotalLabourCost);
                PartsCost_Label.Text     = String.Format("{0:C}", myForecast.TotalPartsCost);
                TotalCost_Label.Text     = String.Format("{0:C}", myForecast.TotalCost);
                Contribution_Label.Text  = String.Format("{0:C}", myForecast.Contribution);
                TotalLabour_Label.Text   = String.Format("{0:C}", myForecast.TotalLabour);
                TotalParts_Label.Text    = String.Format("{0:C}", myForecast.TotalParts);
                TotalHours_Label.Text    = myForecast.TotalHours.ToString();
                ContPerHour_Label.Text   = String.Format("{0:C}", myForecast.ContributionPerHour);
                ContPercent_Label.Text   = String.Format("{0:P}", myForecast.ContributionPercent);
                TotalForecast_Label.Text = String.Format("{0:C}", myForecast.TotalForecast);

                foreach (ListBoxItem item in JobStatus_ComboBox.Items)
                {
                    if (item.ID == myForecast.JobStatus)
                    {
                        JobStatus_ComboBox.SelectedItem = item;
                        break;
                    }
                }

                FormatForecastDetail();

                if (IsNew)
                {
                    myForecast.Save();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                bIsLoading = false;
            }
        }