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";
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
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;
                    }
                }
            }
        }
Beispiel #4
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;
            }
        }