private void fillProperties(classValidationQueryString objValidation, ref bool redirect)
        {
            objErro       = new classErro();
            lstEvaluation = new List <classEvaluation>();

            if (objValidation.lstQueryStrings.Count != 0)
            {
                //string valueInput = string.Empty;
                string strCustomerID = string.Empty;
                string strEvaluation = string.Empty;

                objValidation.getQueryParam("customerID", ref strCustomerID);
                objValidation.getQueryParam("cdEvaluation", ref strEvaluation);

                classClientes objCliente     = new classClientes();
                classClientes objClienteTemp = new classClientes();

                if (objCliente.getCustomerByID(ref objClienteTemp, Convert.ToInt32(strCustomerID)))
                {
                    this.objCustomer = objClienteTemp;

                    if (!string.IsNullOrEmpty(strCustomerID) && string.IsNullOrEmpty(strEvaluation))
                    {
                        listEvaluations();
                    }
                    else if (!string.IsNullOrEmpty(strEvaluation))
                    {
                        classEvaluation objEvaluation = new classEvaluation();
                        objEvaluation.id = Convert.ToInt32(strEvaluation);

                        if (objEvaluation.deleteByID())
                        {
                            redirect = true;
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                            listEvaluations();
                        }
                    }
                    else
                    {
                        objErro.erro    = true;
                        objErro.strErro = "Erro ao receber parametros";
                    }
                }
                else
                {
                    objErro = objCliente.objErro;
                }
            }
            else
            {
                objErro.erro    = true;
                objErro.strErro = "Erro ao receber parametros";
            }
        }
Exemplo n.º 2
0
        private bool userValidation(ref classClientes objCliente)
        {
            bool   valid    = false;
            string strValid = string.Empty;

            objCliente.id   = Convert.ToInt32(inpID);
            objCliente.nome = inpName;
            objCliente.cpf  = inpCPF;
            //fazer isso
            objCliente.cd_planoSaude     = slcPlanoSaude;
            objCliente.telefone          = inpTelephone;
            objCliente.endereco          = inpAdress;
            objCliente.midias            = inpMidias;
            objCliente.profissao         = inpJob;
            objCliente.numeroCarteirinha = (inpCarteirinhaNumber);

            // --------   validar data --------------

            if (classModulo.dateValidation(inpDate))
            {
                objCliente.dataNascimento = Convert.ToDateTime(inpDate, new CultureInfo("pt-BR").DateTimeFormat);
                valid = true;
            }
            else
            {
                valid    = false;
                strValid = "A data fornecida, " + inpDate + ", nao eh valida;";
                objCliente.dataNascimento = DateTime.MinValue;
            }

            // -------------- validar cpf --------------

            if (classModulo.cpfValidation(inpCPF))
            {
                objCliente.cpf = inpCPF;
            }
            else
            {
                valid = false;
                var strCPFinvalid = "O cpf fornecido, " + inpCPF + ", nao eh valido;";
                strValid       = string.IsNullOrEmpty(strValid) ? strCPFinvalid : strValid + Environment.NewLine + strCPFinvalid;
                objCliente.cpf = string.Empty;
            }

            if (valid)
            {
                return(true);
            }
            else
            {
                objErro.erro            = true;
                objErro.strErroAmigavel = strValid;
                return(false);
            }
        }
Exemplo n.º 3
0
 private void fillForms(classClientes objCliente)
 {
     strTitulo            = objCliente.id == 0 ? strTitulo : "Alterar dados";
     slcPlanoSaude        = objCliente.cd_planoSaude;
     inpID                = objCliente.id.ToString();
     inpName              = objCliente.nome;
     inpName              = objCliente.nome;
     inpAdress            = objCliente.endereco;
     inpCarteirinhaNumber = objCliente.numeroCarteirinha.ToString();
     inpJob               = objCliente.profissao;
     inpMidias            = objCliente.midias;
     inpCPF               = string.IsNullOrEmpty(objCliente.cpf) ? string.Empty : objCliente.cpf;
     inpTelephone         = string.IsNullOrEmpty(objCliente.telefone) ? string.Empty : objCliente.telefone;
     inpDate              = objCliente.dataNascimento == DateTime.MinValue ? string.Empty : objCliente.dataNascimento.ToString("dd/MM/yyyy");
 }
Exemplo n.º 4
0
        //public IActionResult OnPostBackPage()
        //{

        //    classValidationQueryString objValidation = new classValidationQueryString();

        //    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson<classUsuario>("user");

        //    //objValidation.insertQueryParam("inpSearch", inpSearch);

        //    var strObjValidation = JsonConvert.SerializeObject(objValidation);

        //    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

        //    return RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt });

        //}

        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                classValidationQueryString objValidation = new classValidationQueryString();
                objErro = new classErro();

                classClientes objCliente = new classClientes();

                if (!userValidation(ref objCliente))
                {
                    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                    objValidation.insertQueryParam("objErro", JsonConvert.SerializeObject(objErro));
                    objValidation.insertQueryParam("objCliente", JsonConvert.SerializeObject(objCliente));

                    var strObjValidation = JsonConvert.SerializeObject(objValidation);

                    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                    return(RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt }));
                }
                else
                {
                    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                    objValidation.insertQueryParam("objCliente", JsonConvert.SerializeObject(objCliente));

                    var strObjValidation = JsonConvert.SerializeObject(objValidation);

                    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                    return(RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt }));
                }
            }

            return(Page());
        }
Exemplo n.º 5
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            classPlanoSaude        objPlanoSaude     = new classPlanoSaude();
            List <classPlanoSaude> lstPlanoSaudeTemp = new List <classPlanoSaude>();

            if (objPlanoSaude.listPlanoSaude(ref lstPlanoSaudeTemp))
            {
                lstPlanoSaude = lstPlanoSaudeTemp.Select(c => new SelectListItem()
                {
                    Text = c.descricao, Value = c.codigo.ToString()
                }).ToList();

                if (ObjValidation.lstQueryStrings.Count != 0)
                {
                    string valueObjErro    = string.Empty;
                    string valueObjCliente = string.Empty;
                    string valueID         = string.Empty;

                    ObjValidation.getQueryParam("objErro", ref valueObjErro);
                    ObjValidation.getQueryParam("objCliente", ref valueObjCliente);
                    ObjValidation.getQueryParam("id", ref valueID);


                    if (!string.IsNullOrEmpty(valueObjErro))
                    {
                        objErro = JsonConvert.DeserializeObject <classErro>(valueObjErro);
                        classClientes objCliente = JsonConvert.DeserializeObject <classClientes>(valueObjCliente);

                        if (objCliente == null)
                        {
                            return;
                        }

                        fillForms(objCliente);
                    }
                    else if (!string.IsNullOrEmpty(valueObjCliente) && string.IsNullOrEmpty(valueObjErro))
                    {
                        classClientes objCliente = JsonConvert.DeserializeObject <classClientes>(valueObjCliente);

                        if (objCliente.insertAlterCliente())
                        {
                            if (objCliente.id == 0)
                            {
                                redirect = true;
                                TempData["alterSaveCustomerOK"] = "Cliente salvo com sucesso!";
                                TempData["inpSearch"]           = objCliente.nome;
                            }
                            else
                            {
                                redirect = true;
                                TempData["alterSaveCustomerOK"] = "Cliente alterado com sucesso!";
                            }
                        }
                        else
                        {
                            fillForms(objCliente);
                            objErro = objCliente.objErro;
                        }
                    }
                    else if (!string.IsNullOrEmpty(valueID) && string.IsNullOrEmpty(valueObjCliente) && string.IsNullOrEmpty(valueObjErro))
                    {
                        classClientes objCliente = new classClientes();

                        if (objCliente.getCustomerByID(ref objCliente, Convert.ToInt32(valueID)))
                        {
                            fillForms(objCliente);
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                }
            }
            else
            {
                objErro = objPlanoSaude.objErro;
            }
        }
Exemplo n.º 6
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            objErro     = new classErro();
            lstClientes = new List <classClientes>();

            if (ObjValidation.lstQueryStrings.Count != 0)
            {
                string valueInput = string.Empty;
                string valueID    = string.Empty;

                ObjValidation.getQueryParam("inpSearch", ref valueInput);
                ObjValidation.getQueryParam("id", ref valueID);

                if (!string.IsNullOrEmpty(valueInput))
                {
                    inpSearch = valueInput;

                    long cpf;
                    bool isCpf = long.TryParse(valueInput, out cpf);

                    if (!isCpf)
                    {
                        List <classClientes> lstClientesTemp = new List <classClientes>();
                        classClientes        objCliente      = new classClientes();

                        if (objCliente.listCustomerByName(ref lstClientesTemp, valueInput))
                        {
                            if (lstClientesTemp.Count == 0)
                            {
                                objCliente.objErro.erro            = true;
                                objCliente.objErro.strErroAmigavel = "Nenhum cliente encontrado com as palavras chaves: " + valueInput;
                                objErro = objCliente.objErro;
                            }
                            else
                            {
                                lstClientes = lstClientesTemp;
                            }
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                    else
                    {
                        List <classClientes> lstClientesTemp = new List <classClientes>();
                        classClientes        objCliente      = new classClientes();

                        if (objCliente.listCustomerByCPF(ref lstClientesTemp, cpf.ToString()))
                        {
                            if (lstClientesTemp.Count == 0)
                            {
                                objCliente.objErro.erro            = true;
                                objCliente.objErro.strErroAmigavel = "Nenhum cliente encontrado com CPF: " + cpf;
                                objErro   = objCliente.objErro;
                                inpSearch = string.Empty;
                            }
                            else
                            {
                                lstClientes = lstClientesTemp;
                            }
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                }
                else if (string.IsNullOrEmpty(valueInput) && !string.IsNullOrEmpty(valueID))
                {
                    classClientes objCliente = new classClientes();
                    objCliente.id = Convert.ToInt32(valueID);

                    if (objCliente.deleteCustomerByID())
                    {
                        redirect = true;
                    }
                    else
                    {
                        objErro = objCliente.objErro;
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            var cd_cliente = Convert.ToInt32(TempData["cdCliente"].ToString());

            inpCdCliente = cd_cliente.ToString();

            TempData["cdCliente"] = cd_cliente;

            classClientes objCustomerTemp = new classClientes();
            classClientes objCustomer     = new classClientes();

            classTreatmentTypes        objTypes = new classTreatmentTypes();
            List <classTreatmentTypes> lstTypes = new List <classTreatmentTypes>();

            if (objTypes.list(ref lstTypes))
            {
                this.lstTypesTreatment = lstTypes.Select(c => new SelectListItem()
                {
                    Text = c.descricao, Value = c.codigo.ToString()
                }).ToList();

                if (objCustomer.getCustomerByID(ref objCustomerTemp, cd_cliente))
                {
                    this.objCustomer = objCustomerTemp;


                    string valueObjEvaluation = string.Empty;
                    string valueCdEvaluation  = string.Empty;

                    ObjValidation.getQueryParam("objEvaluation", ref valueObjEvaluation);
                    ObjValidation.getQueryParam("cdEvaluation", ref valueCdEvaluation);

                    if (!string.IsNullOrEmpty(valueObjEvaluation))
                    {
                        classEvaluation objEvaluation = JsonConvert.DeserializeObject <classEvaluation>(valueObjEvaluation);

                        if (objEvaluation.insertAlter())
                        {
                            redirect = true;

                            if (objEvaluation.id == 0)
                            {
                                TempData["alterSaveEvaluationOK"] = "Avaliacao salva com sucesso!";
                            }
                            else
                            {
                                TempData["alterSaveEvaluationOK"] = "Avaliacao alterada com sucesso!";
                            }
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                        }
                    }
                    else if (string.IsNullOrEmpty(valueObjEvaluation) && !string.IsNullOrEmpty(valueCdEvaluation))
                    {
                        classEvaluation objEvaluation     = new classEvaluation();
                        classEvaluation objEvaluationTemp = new classEvaluation();

                        if (objEvaluation.getById(ref objEvaluationTemp, Convert.ToInt32(valueCdEvaluation)))
                        {
                            fillforms(objEvaluationTemp);
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                        }
                    }
                }
                else
                {
                    objErro = objCustomer.objErro;
                }
            }
            else
            {
                objErro = objTypes.objErro;
            }
        }