Beispiel #1
0
        public void SaveBudget(ProjectDto project, List<TaskDto> taskList)
        {
            if (project != null)
            {
                var code = Convert.ToDouble(project.Code);
                var prePresupuestos = Asgard._Foreing.PRE_PRESUPUESTOS.Where(x => x.PRE_NUMERO.Equals(code)).SingleOrDefault();

                if (prePresupuestos != null)
                {// Edit
                    Map(project, prePresupuestos, taskList);
                }
                else
                {// Add
                    if (project.Code != null)
                    {
                        prePresupuestos = new PRE_PRESUPUESTOS();
                        Map(project, prePresupuestos, taskList);
                        Asgard._Foreing.PRE_PRESUPUESTOS.AddObject(prePresupuestos);
                    }
                }
                Asgard._Foreing.SaveChanges();
            }
        }
Beispiel #2
0
        private void FixupProject(ProjectDto previousValue)
        {
            if (previousValue != null && previousValue.ProjectInforms.Contains(this))
            {
                previousValue.ProjectInforms.Remove(this);
            }

            if (Project != null)
            {
                if (!Project.ProjectInforms.Contains(this))
                {
                    Project.ProjectInforms.Add(this);
                }
                if (ProjectId != Project.Id)
                {
                    ProjectId = Project.Id;
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Return the sumary of the resources cost
 /// </summary>
 /// <param name="project">The Project with resources</param>
 /// <returns>The sum of the cost</returns>
 private decimal CalcSubtotal(ProjectDto project)
 {
     var resources = new List<ResourceDto>();
     GetResources(project.Tasks, resources);
     return resources.Sum(x => x.TotalCost);
 }
Beispiel #4
0
        private void Map(ProjectDto source, PRE_PRESUPUESTOS destination, IEnumerable<TaskDto> taskList)
        {
            #region Map
            destination.CIA_CODIGO = "01";
            destination.PRE_NUMERO = Convert.ToDouble(source.Code);
            destination.CLI_CLIENTE = source.BudgetRequest.Customer.BindCustomer.AlienId;
            destination.SVR_CODIGO = "00";                         // Necesario por ser llave foranea {No existe en SGP}{NO APLICA}
            destination.PRE_FECHA = DateTime.Today;
            destination.VEN_VENDEDOR = "SGP";                        //Se utiliza un estandar, en este caso es el sitema SGP
            destination.PRE_NOMBREPROYECTO = source.Name;
            destination.PRE_OBSERVACIONES = source.Comments;
            destination.PRE_ACTIVIDADES = "GENERADO MEDIANTE SGP";
            destination.PRE_TOTALMETROS = source.TotalMeters;

            destination.PRE_SUBTOTAL_H = 0.0;                      //{Pendiente}
            destination.PRE_SUBTOTAL_I = 0.0;                      //{Pendiente}
            destination.PRE_SUBTOTAL_J = 0.0;                      //{Pendiente}
            destination.PRE_APLICADO = 0;                        //{Pendiente}
            destination.PRE_PORC_UTILIDAD = 0.0;
            destination.PRE_UTILIDAD = 0.0;
            destination.PRE_PORC_MUP = 0.0;

            destination.PRE_SUBTOTAL_K = Convert.ToDouble(CalcSubtotal(source));
            destination.PRE_PORC_IMPREVISTOS = source.ContingenciesRate;
            destination.PRE_IMPREVISTOS = destination.PRE_SUBTOTAL_K * destination.PRE_PORC_IMPREVISTOS / 100;
            destination.PRE_PORC_GARANTIA = source.GuaranteeRate;
            destination.PRE_GARANTIA = destination.PRE_SUBTOTAL_K * destination.PRE_PORC_GARANTIA / 100;

            var other = destination.PRE_SUBTOTAL_K * source.OthersRate / 100; // + % Otros que no aparece en dialcom

            destination.PRE_TOTALSERVICIO = destination.PRE_SUBTOTAL_K + destination.PRE_IMPREVISTOS + destination.PRE_GARANTIA + other;
            destination.PRE_PORC_UTIL_GNRL = source.TotalUtilityRate;
            destination.PRE_UTILIDAD_GNRL = destination.PRE_TOTALSERVICIO * destination.PRE_PORC_UTIL_GNRL / 100;

            var discount = (destination.PRE_TOTALSERVICIO + destination.PRE_UTILIDAD_GNRL) * source.DiscountRate / 100;

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /**/
            destination.PRE_TOTAL_GNRL = destination.PRE_TOTALSERVICIO + destination.PRE_UTILIDAD_GNRL - discount;/**/
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

            if (destination.PRE_TOTALMETROS <= 0)
                destination.PRE_COSTOXMETRO = 0;
            else
                destination.PRE_COSTOXMETRO = destination.PRE_TOTAL_GNRL / destination.PRE_TOTALMETROS;

            destination.FAM_Codigo = source.BudgetRequest.Family.Id;        // Necesario por ser llave foranea
            destination.TIP_Codigo = 33;                                    // Necesario por ser llave foranea {No existe en SGP}{Otros}
            destination.SUB_Codigo = 999;                                   // Necesario por ser llave foranea {No existe en SGP}{Ninguno}
            destination.USR_Usuario_Inclusion = "SGP";
            destination.USR_Fecha_Inclusion = DateTime.Today;
            destination.USR_Usuario_Modificacion = "SGP";
            destination.USR_Fecha_Modificacion = DateTime.Today;
            #endregion

            GetBudgetDetail(taskList, destination.PRE_DETALLE);
            GetBudgetTask(taskList, destination.TaskByBudgets);
            GetTotalDetail(destination.PRE_TOTALESDETALLE_X_HOJAPRESUPUESTO, destination.PRE_DETALLE);
        }
Beispiel #5
0
        private ProjectDto CopyProject(ProjectDto project)
        {
            var tasks = new List<TaskDto>();
            var tmpProject = Mapper.Map<ProjectDto, ProjectDto>(project);

            GetListOfTask(project.Tasks, tasks);
            tmpProject.Tasks.Clear();

            tmpProject.Tasks = tasks;
            return tmpProject;
            //return Mapper.Map<ProjectDto, ProjectDto>(project);
        }
Beispiel #6
0
        /// <summary>
        /// Carga los datos que se envian a la interfaz grafica
        /// </summary>
        /// <param name="p">Proyecto con los datos a cambiar</param>
        private void LoadProject(ProjectDto p)
        {
            _project = p;

            _budgetRequest.Id = _project.BudgetRequestId;
            _budgetRequest.CustomerId = _project.CustumerId;

            //Screen One
            txtQuoteNumber.Text = p.BudgetRequestId.ToString();
            dtCreateDate.DateTime = p.CreateDate;
            txtCode.Text = p.Code;
            txtProject.Text = p.Name;
            txtCustumer.Text = p.Customer.Name;
            txtSalesConsultant.Text = p.BudgetRequest != null ? p.BudgetRequest.Employee.Person.Name : @"Verificando";
            chkManagementApproval.Checked = p.ManagementApproval;
            chkCxcApproval.Checked = p.CxcApproval;
            if (p.BudgetRequest != null) txtFamily.Text = p.BudgetRequest.Family.Name;
            txtState.Text = p.State.Name;

            //Screen Two
            if (p.BudgetRequest != null) ConfigureMinMaxValues(p.BudgetRequest.Family);
            spinContingenciesRate.Value = (decimal)p.ContingenciesRate;
            spinGuaranteeRate.Value = (decimal)p.GuaranteeRate;
            spinTotalUtilityRate.Value = (decimal)p.TotalUtilityRate;
            spinDiscountRate.Value = (decimal)p.DiscountRate;
            spinSubTotalB.Value = (decimal)p.SalesTax;
            spinOthersRate.Value = (decimal)p.OthersRate;
            spinTotalMeters.Value = (decimal)p.TotalMeters;
            Calcs();

            //Screen Three
            memoComments.Text = p.Comments;
        }
Beispiel #7
0
 /// <summary>
 /// Sets the value of the local variable _project and then load
 /// </summary>
 /// <param name="project"></param>
 public void LoadProject(ProjectDto project)
 {
     _project = project;
     LoadProject();
 }
Beispiel #8
0
        private void SaveProject()
        {
            var request = new ProjectRequest();

            _project.Tasks = GetTask();
            request.Project = _project;

            var id = new ProjectFactory().SaveProject(request).ProjectId;
            _project = new ProjectFactory().GetProject( new ProjectRequest { ProjectId = id}).Project;
        }