Exemplo n.º 1
0
        public override void OnSave()
        {
            if (Convert.ToBoolean(PriEngine.Engine.Base.Clientes.NumeroContribuintesRepetidos(txtNif.Text)) && !chkEdit.Checked)
            {
                MessageBox.Show("Cannot continue because the NIF for the current entity already exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                BasBECliente customer = new BasBECliente();

                customer.Nome            = TxtDescription.Text;
                customer.Cliente         = txtName.Text;
                customer.Morada          = txtAdress.Text;
                customer.Morada2         = txtAdress2.Text;
                customer.Telefone        = txtphone.Text;
                customer.NumContribuinte = txtNif.Text;
                customer.Moeda           = "EUR";

                // Check if entity already exist.
                // If exists them set this flag to true to tell the system to perform an update operation.
                customer.EmModoEdicao = PriEngine.Engine.Base.Clientes.Existe(txtName.Text) ? true : false;

                try
                {
                    PriEngine.Engine.Base.Clientes.Actualiza(customer);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to save client. \n" + ex.Message);
                }
            }

            base.OnSave();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Find the costumer on Google maps based on the address.
        /// </summary>
        private void LoadCustomerLocation()
        {
            BasBECliente  cliente          = this.ContextService.Cliente;
            StringBuilder costumerLocation = new StringBuilder();
            StringBuilder costumerinfo     = new StringBuilder();

            // Build a string with the adress for google api.
            costumerLocation.Append(cliente.Morada + ",");
            costumerLocation.Append(cliente.Localidade);

            // Build a string wit additional information to show when click on the pin.
            costumerinfo.Append(cliente.Cliente + "<BR>");
            costumerinfo.Append(cliente.Nome + "<BR>");
            costumerinfo.Append(cliente.Telefone + "<BR>");

            // Read the HTML file template.
            // The file Maps.html will be copied to the extensions folder on build.
            string       percursoDadosComuns = this.ContextService.PSO.RegistryPrimavera.DaPercursoConfigEx("Default");
            StreamReader reader = new StreamReader(percursoDadosComuns + "Extensions\\DEMO10\\Resources\\maps.htm");

            string readFile = reader.ReadToEnd();

            // Replace all the tags on the javascript  with real information.
            readFile = readFile.Replace("@adress", costumerLocation.ToString());
            readFile = readFile.Replace("@pininformation", costumerinfo.ToString());

            reader.Close();

            MapsBrowser.DocumentText = readFile;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Manual save the customer user fields.
        /// </summary>
        private void CustomerFields_Saving()
        {
            BasBECliente cliente = this.ContextService.Cliente;

            cliente.CamposUtil["CDU_CampoVar1"].Valor = CDUCampoVar1.Text;
            cliente.CamposUtil["CDU_CampoVar2"].Valor = CDUCampoVar2.Text;
            cliente.CamposUtil["CDU_CampoVar3"].Valor = CDUCampoVar3.Text;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Manual load the customer user fields.
        /// </summary>
        private void CustomerFields_Loading()
        {
            BasBECliente cliente = this.ContextService.Cliente;

            StdBECampos cdu = cliente.CamposUtil;

            CDUCampoVar1.Text = Convert.ToString(cdu["CDU_CampoVar1"].Valor);
            CDUCampoVar2.Text = Convert.ToString(cdu["CDU_CampoVar2"].Valor);
            CDUCampoVar3.Text = Convert.ToString(cdu["CDU_CampoVar3"].Valor);
        }
Exemplo n.º 5
0
        public override void OnValidateParty()
        {
            BasBECliente  customer   = new BasBECliente();
            StringBuilder CamposUtil = new StringBuilder();
            List <string> row        = new List <string>();

            listViewCDU.Clear();
            listViewCDU.View        = View.Details;
            listViewCDU.HeaderStyle = ColumnHeaderStyle.Clickable;

            if (txtName.Text.Length != 0)
            {
                try
                {
                    if (PriEngine.Engine.Base.Clientes.Existe(txtName.Text))
                    {
                        customer = PriEngine.Engine.Base.Clientes.Edita(txtName.Text);

                        txtName.Text        = customer.Cliente;
                        TxtDescription.Text = customer.Nome;
                        txtAdress.Text      = customer.Morada;
                        txtAdress2.Text     = customer.Morada2;
                        txtphone.Text       = customer.Telefone;
                        txtNif.Text         = customer.NumContribuinte;

                        chkEdit.Checked = customer.EmModoEdicao;

                        // load user fields
                        foreach (StdBECampo objCDU in customer.CamposUtil)
                        {
                            ColumnHeader columnHeader = new ColumnHeader
                            {
                                Name  = objCDU.Nome,
                                Text  = objCDU.Nome,
                                Width = 100
                            };

                            listViewCDU.Columns.Add(columnHeader);

                            row.Add(Convert.ToString(objCDU.Valor));
                        }

                        ListViewItem listViewItem = new ListViewItem(row.ToArray());
                        listViewCDU.Items.Add(listViewItem);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("It was not possible to load the entity. \n" + ex.Message);
                }
            }

            base.OnValidateParty();
        }
        internal static List <String> UpdateEntity(ERPContext oERPContext, string EntityType, string Entity)
        {
            Dictionary <String, String> groupCompanies = CrossCompany.Platform.GetGroupCompanies(oERPContext);
            List <String> updatedCompanies             = new List <string>();

            //Exit if no companies where found
            if (groupCompanies.Count == 0)
            {
                return(updatedCompanies);
            }

            groupCompanies.Remove(oERPContext.BSO.Contexto.CodEmp);
            foreach (string groupCompany in groupCompanies.Keys)
            {
                ErpBS oCompany = new ErpBS();

                oCompany.AbreEmpresaTrabalho(
                    StdBE100.StdBETipos.EnumTipoPlataforma.tpEmpresarial,
                    groupCompany,
                    Properties.Settings.Default.User,
                    Properties.Settings.Default.Password);

                //get the last exercise (to create the entity accounts for each exercise)
                int lastYear = oERPContext.BSO.Contabilidade.ExerciciosCBL.DaUltimoAno();

                switch (EntityType)
                {
                case "C":
                    if (Convert.ToBoolean(oERPContext.BSO.Base.Clientes.DaValorAtributo(Entity, "CDU_EntidadeGrupo")))
                    {
                        //Entity
                        BasBECliente objNewEntity = oERPContext.BSO.Base.Clientes.Edita(Entity);
                        if (!oCompany.Base.Clientes.Existe(Entity))
                        {
                            objNewEntity.EmModoEdicao = false;
                        }
                        oCompany.Base.Clientes.Actualiza(objNewEntity);
                        updatedCompanies.Add(groupCompany);

                        //Connection to CBL
                        for (int currentYear = DateTime.Now.Year; currentYear <= lastYear; currentYear++)
                        {
                            CblBECnfTabLinhaLigCBL objNewLinhaCnfTabLigCBL = oERPContext.BSO.Contabilidade.ConfiguracaoTabCBL.Edita(CblBE100.CblBECnfTabLinhaLigCBL.TETipoTabela.GCPClientes, currentYear, "001", Entity, 1);
                            if (objNewLinhaCnfTabLigCBL != null)
                            {
                                if (oCompany.Contabilidade.ConfiguracaoTabCBL.ExisteID(objNewLinhaCnfTabLigCBL.Id))
                                {
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.ActualizaValorAtributoID(objNewLinhaCnfTabLigCBL.Id, "Conta", objNewLinhaCnfTabLigCBL.Conta);
                                }
                                else
                                {
                                    objNewLinhaCnfTabLigCBL.EmModoEdicao = false;
                                    CblBECnfTabLigCBL objNewCnfTabLigCBL = oCompany.Contabilidade.ConfiguracaoTabCBL.EditaTabela(CblBECnfTabLinhaLigCBL.TETipoTabela.GCPClientes);
                                    objNewCnfTabLigCBL.PlanoExercicios.GetEdita(1).Linhas.Insere(objNewLinhaCnfTabLigCBL);
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.Actualiza(objNewCnfTabLigCBL);
                                }
                            }
                        }
                    }
                    break;

                case "F":
                    if (Convert.ToBoolean(oERPContext.BSO.Base.Fornecedores.DaValorAtributo(Entity, "CDU_EntidadeGrupo")))
                    {
                        //Entity
                        BasBEFornecedor objNewEntity = oERPContext.BSO.Base.Fornecedores.Edita(Entity);
                        if (!oCompany.Base.Fornecedores.Existe(Entity))
                        {
                            objNewEntity.EmModoEdicao = false;
                        }
                        oCompany.Base.Fornecedores.Actualiza(objNewEntity);
                        updatedCompanies.Add(groupCompany);

                        //Connection to CBL
                        for (int currentYear = DateTime.Now.Year; currentYear <= lastYear; currentYear++)
                        {
                            CblBECnfTabLinhaLigCBL objNewLinhaCnfTabLigCBL = oERPContext.BSO.Contabilidade.ConfiguracaoTabCBL.Edita(CblBE100.CblBECnfTabLinhaLigCBL.TETipoTabela.GCPFornecedores, currentYear, "001", Entity, 1);
                            if (objNewLinhaCnfTabLigCBL != null)
                            {
                                if (oCompany.Contabilidade.ConfiguracaoTabCBL.ExisteID(objNewLinhaCnfTabLigCBL.Id))
                                {
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.ActualizaValorAtributoID(objNewLinhaCnfTabLigCBL.Id, "Conta", objNewLinhaCnfTabLigCBL.Conta);
                                }
                                else
                                {
                                    objNewLinhaCnfTabLigCBL.EmModoEdicao = false;
                                    CblBECnfTabLigCBL objNewCnfTabLigCBL = oCompany.Contabilidade.ConfiguracaoTabCBL.EditaTabela(CblBECnfTabLinhaLigCBL.TETipoTabela.GCPFornecedores);
                                    objNewCnfTabLigCBL.PlanoExercicios.GetEdita(1).Linhas.Insere(objNewLinhaCnfTabLigCBL);
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.Actualiza(objNewCnfTabLigCBL);
                                }
                            }
                        }
                    }
                    break;

                case "R":
                case "D":
                    if (Convert.ToBoolean(oERPContext.BSO.Base.OutrosTerceiros.DaValorAtributo(Entity, EntityType, "CDU_EntidadeGrupo")))
                    {
                        //Entity
                        BasBEOutroTerceiro objNewEntity = oERPContext.BSO.Base.OutrosTerceiros.Edita(Entity);
                        if (!oCompany.Base.OutrosTerceiros.Existe(Entity))
                        {
                            objNewEntity.EmModoEdicao = false;
                        }
                        oCompany.Base.OutrosTerceiros.Actualiza(objNewEntity);
                        updatedCompanies.Add(groupCompany);

                        //Connection to CBL
                        for (int currentYear = DateTime.Now.Year; currentYear <= lastYear; currentYear++)
                        {
                            CblBECnfTabLinhaLigCBL objNewLinhaCnfTabLigCBL = oERPContext.BSO.Contabilidade.ConfiguracaoTabCBL.Edita(CblBE100.CblBECnfTabLinhaLigCBL.TETipoTabela.GCPOutrosTerceiros, currentYear, "001", Entity, 1);
                            if (objNewLinhaCnfTabLigCBL != null)
                            {
                                if (oCompany.Contabilidade.ConfiguracaoTabCBL.ExisteID(objNewLinhaCnfTabLigCBL.Id))
                                {
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.ActualizaValorAtributoID(objNewLinhaCnfTabLigCBL.Id, "Conta", objNewLinhaCnfTabLigCBL.Conta);
                                }
                                else
                                {
                                    objNewLinhaCnfTabLigCBL.EmModoEdicao = false;
                                    CblBECnfTabLigCBL objNewCnfTabLigCBL = oCompany.Contabilidade.ConfiguracaoTabCBL.EditaTabela(CblBECnfTabLinhaLigCBL.TETipoTabela.GCPOutrosTerceiros);
                                    objNewCnfTabLigCBL.PlanoExercicios.GetEdita(1).Linhas.Insere(objNewLinhaCnfTabLigCBL);
                                    oCompany.Contabilidade.ConfiguracaoTabCBL.Actualiza(objNewCnfTabLigCBL);
                                }
                            }
                        }
                    }
                    break;

                case "E":
                    if (Convert.ToBoolean(oERPContext.BSO.CRM.EntidadesExternas.DaValorAtributo(Entity, "CDU_EntidadeGrupo")))
                    {
                        //Entity
                        CrmBEEntidadeExterna objNewEntity = oERPContext.BSO.CRM.EntidadesExternas.Edita(Entity);
                        if (!oCompany.CRM.EntidadesExternas.Existe(Entity))
                        {
                            objNewEntity.EmModoEdicao = false;
                        }
                        oCompany.CRM.EntidadesExternas.Actualiza(objNewEntity);
                        updatedCompanies.Add(groupCompany);
                    }
                    break;

                default:
                    break;
                }

                oCompany.FechaEmpresaTrabalho();
            }

            return(updatedCompanies);
        }