protected void btnRegisterClient_Click(object sender, EventArgs e)
        {
            try
            {
                ClientDTO clientDTO = new ClientDTO();
                ClientBLL clientBLL = new ClientBLL();
                clientDTO.Name     = txtRegisterName.Text;
                clientDTO.Type     = dropRegisterType.SelectedValue;
                clientDTO.Cpf      = txtRegisterCpf.Text;
                clientDTO.Phone    = txtRegisterPhone.Text;
                clientDTO.Email    = txtRegisterEmail.Text;
                clientDTO.Password = txtRegisterPass.Text;
                string clientId = clientBLL.ReturnID(clientDTO.Email);
                if (clientId == "NOT_FOUND")
                {
                    clientBLL.Insert(clientDTO);
                    clientId = clientBLL.ReturnID(clientDTO.Email);
                    string clientType = clientBLL.ConsultID(int.Parse(clientId)).Rows[0]["type"].ToString();
                    Session["UserEmail"] = clientDTO.Email;
                    Session["UserId"]    = clientId;
                    Session["UserType"]  = clientType;
                    string msg = string.Format($@"Seja bem vindo ao nosso sistema '{clientDTO.Name}'");
                    SuccessMessage(msg);

                    switch (clientType)
                    {
                    case "client":
                        Response.Redirect("clientHome.aspx");
                        break;

                    case "admin":
                        Response.Redirect("home.aspx");
                        break;

                    default:
                        Response.Redirect("clientHome.aspx");
                        break;
                    }
                }
                else
                {
                    string msg = string.Format($@"Não foi possível finalizar o cadastro. Já existe um usuário com o e-mail: '{clientDTO.Email}'");
                    ErrorMessage(msg);
                }
            }
            catch (Exception error)
            {
                ErrorMessage(error.Message);
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                clientDTO.Email    = txtLoginEmail.Text;
                clientDTO.Password = txtLoginPass.Text;
                if (clientBLL.Authenticator(clientDTO.Email, clientDTO.Password))
                {
                    string clientId   = clientBLL.ReturnID(clientDTO.Email);
                    string clientType = clientBLL.ConsultID(int.Parse(clientId)).Rows[0]["type"].ToString();

                    Session["UserEmail"] = clientDTO.Email;
                    Session["UserId"]    = clientId;
                    Session["UserType"]  = clientType;
                    SuccessMessage("Seja bem-vindo");

                    switch (clientType)
                    {
                    case "client":
                        Response.Redirect("clientHome.aspx");
                        break;

                    case "admin":
                        Response.Redirect("home.aspx");
                        break;

                    default:
                        Response.Redirect("clientHome.aspx");
                        break;
                    }
                }
                else
                {
                    ErrorMessage("Cliente não encontrado");
                }
            }
            catch (Exception error)
            {
                ErrorMessage(error.Message);
            }
        }
        protected void ClientGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                string defaultType = clientBLL.ConsultID(Convert.ToInt32(ClientGrid.DataKeys[e.RowIndex].Value.ToString())).Rows[0]["type"].ToString();
                clientDTO.Id       = Convert.ToInt32(ClientGrid.DataKeys[e.RowIndex].Value.ToString());
                clientDTO.Name     = e.NewValues[0]?.ToString().Length > 0 ? e.NewValues[0].ToString() : "";
                clientDTO.Type     = defaultType;
                clientDTO.Cpf      = e.NewValues[1]?.ToString().Length > 0 ? e.NewValues[1].ToString() : "";
                clientDTO.Phone    = e.NewValues[2]?.ToString().Length > 0 ? e.NewValues[2].ToString() : "";
                clientDTO.Email    = e.NewValues[3]?.ToString().Length > 0 ? e.NewValues[3].ToString() : "";
                clientDTO.Password = e.NewValues[4]?.ToString().Length > 0 ? e.NewValues[4].ToString() : "";

                clientBLL.Update(clientDTO);
                ClientGrid.EditIndex = -1;
                string successMsg = "Atualização cadastrada com sucesso!";
                SuccessMessage(successMsg);
                GridViewLoadDataByUser();
            }
            catch (Exception error)
            {
                ErrorMessage(error.Message);
            }
        }