Posts by Rovann Linhalis • 14,881 points
567 posts
-
1
votes1
answer28
viewsA: Update the last record with WHERE MYSQL
With this query, only the update will be performed if the last record in the table login_agent is owned by Agent 4827. If you want to update the column data_hora_login_saida from the last agent…
-
1
votes2
answers37
viewsA: How can I apply increase and percentage reduction over unit value
Considering only what is requested in the question... Do a Case on this stretch: ( SELECT VALOR1 FROM SPBRAVEN(5, L.ITEM, current_date, 1) ) * (1.10)),0) Staying: ( SELECT VALOR1 FROM SPBRAVEN(5,…
-
1
votes1
answer19
viewsA: Convert generic to specific type in DB set
Its interface has to be generic... public interface IbaseRepository<T> { void Criar(T obj); void Editar(T obj); void Deletar(T obj); } And then you pass the kind on the inheritance: public…
-
0
votes1
answer74
viewsA: C# - Clear all form fields at once
This is the method I use, is already recursive and will clear all screen controls: public static void ClearControl(Control ctrl) { foreach (Control c in ctrl.Controls) { if (c is TextBox) {…
-
2
votes1
answer32
viewsA: Calling method by string command
I do not know if there is a better way in WPF, but could use a dictionary with commands, See: using System; using System.Collections.Generic; public class Program { public static void Main() {…
-
1
votes2
answers116
viewsA: Recover value if null in Flutter Sharedpreferences
Test if there’s a key first: _recuperar() async { final prefs = await SharedPreferences.getInstance(); if (prefs.containsKey("nome")) { setState(() { _textoSalvo = prefs.getString("nome"); }); } }…
-
0
votes1
answer65
viewsA: C# Recover all dynamic buttons
you can scroll through all the buttons of the form, using a foreach. I made an example that you can adapt to your situation; Avoid posting code print, show the formatted code and preferably full (in…
c#answered Rovann Linhalis 14,881 -
0
votes1
answer44
viewsA: Operationcompleted had already been called in the operation and other calls are illegal. Background Worker
The problem is that you are calling an asynchronous method within the backgroundWorker. When he is called, the backgroundWorker finalize its execution, and within LoadSpreadsheetAsync you call the…
-
0
votes2
answers30
viewsA: Grab text from Linklabel created in Runtime C#
And click event gets two parameters, sender and e which are respectively who shot the event and his arguments. So if you access Sender, it will be the linklabel itself: for (int i = 0; i <…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer250
viewsA: Mysql extract from INPUT and OUTPUT tables
There are some problems in this model, it may be that it’s just a conceptual exercise, it wouldn’t use it in a real problem. Surely you will have problems with retroactive movements or chargebacks.…
-
0
votes1
answer88
viewsA: Link 3 tables in an SQL query
In this specific case, you can use a sub-select, since it is selecting only one column from the foreign table, which avoids you placing all the other columns in the group by. If you do not want a…
-
3
votes1
answer201
viewsA: SELECT MAX With more than three columns
Use a Window Function Use partitioning by jobname, and the decreasing order of duration: select t.*, rank() over w as i from t WINDOW w AS (PARTITION BY jobname ORDER BY duracao DESC) Upshot: Note…
-
3
votes1
answer35
viewsA: R and Postgresql - AND/OR and BEETWEN/NOT BEETWEN how to help logic?
You need to separate the OR and conditions, if they are aligned, any OR that is true will ignore the other AND. Use ( ) and separate all Ors: SELECT * FROM cnpj.cnae WHERE ( (cnae_fiscal BETWEEN…
-
0
votes1
answer94
viewsA: Fill GRID with JSON - Deserialized (Metrogrid - Metroframework)
You have several options: Generating the columns automatically, you will need to inform which name will be displayed: public class MyClas { [DisplayName("Dados A")] public string A { get; set; }…
-
3
votes2
answers86
viewsA: How best to separate the two lists in C# by doing an operation with each side of the split
using {} you can create a scope inside the lambda function, and inside put an If lista.ForEach(x=> { if (x == "") FazX(); else FazY();}); In your case: objeto.ForEach(o => { if (o.Data >…
c#answered Rovann Linhalis 14,881 -
0
votes1
answer177
viewsA: Get last ID value and add +1 in SQL Database
It could be something like: "INSERT INTO t_saida (id,data,os,tech,descri,pag,valor) VALUES ((select coalesce(max(id),0)+1 from t_saida),'$data','$os','$tech','$descri','$pag','$valor')"; But the…
sqlanswered Rovann Linhalis 14,881 -
0
votes2
answers104
viewsA: Combobox redeem ID value
You need to fill out the Combobox with the details of the specialties: Supposing your class is something like this: public class Especialidade { public int Id {get;set;} public string Nome…
-
1
votes1
answer28
viewsA: Insert combobox items using Entity Framework
you are initiating the list with each loop iteration for (int i = 0; i < listBox1.Items.Count; i++) { sala.SalaAlunos = new List<SalaAluno>();…
-
1
votes1
answer363
viewsA: Variable double receiving comma value in API - . Netcore
You need to define in the API which will be the accepted pattern, particularly, would use an integer representing centimeters, and then divide by 100 for the calculation. When you do [double].…
-
0
votes1
answer266
viewsA: C# - Form track Panel size
Define the properties TopLevel, FormBorderStyle and WindowState: Form2 frm = new Form2(); frm.TopLevel = false; frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; frm.WindowState =…
-
1
votes1
answer159
viewsA: List part of a JSON file using C#
I made an example using a combobox, and when changing the combo is performed select: private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedIndex == 0) {…
-
0
votes1
answer195
viewsA: Filter Json Using C#
You can create a class that represents json and deserialize it in this class, or deserialize in an anonymous object: You will need to reference the library Newtonsoft.Json static void Main(string[]…
-
0
votes1
answer96
viewsA: How to Cloud Forms in C#
You can use another form that opens behind the message, follow an example I use in my projects: public partial class FormShadow : Form { //Form Pai onde está o controle a ser exibido public Form…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer33
viewsA: Send hyperlink by email - link break
You have to encode your path to a URL. For this use Httputility.Urlencode: https://docs.microsoft.com/pt-br/dotnet/api/system.web.httputility.urlencode?view=netframework-4.8 string url=…
-
0
votes2
answers160
viewsA: How to delete duplicate lines in Postgres database?
Select duplicate records in a temporary table with duplicadas as (SELECT codigotransportadora, especificacoesresiduos, count(*) FROM tabela GROUP BY codigotransportadora,especificacoesresiduos…
-
2
votes1
answer109
viewsA: Creation of Trigger that saves information on file
I do not know if in postgresql it is possible to just edit a file, the logic would be to read the current file, add the new information and write it again: I used an example txt, with the following…
-
2
votes2
answers493
viewsA: Count number of rows of different tables doing LEFT JOIN using the Count() function
You can use a sub-query: select tipo_midia.tipo, videos.titulo, (select count(cliques.id_midia) from cliques where cliques.id_midia = videos.id) as cliques, (select count(curtidas.id_midia) from…
-
4
votes1
answer108
viewsA: Display <list> in Datagrid with 2 different classes c#
One option is to replace the method ToString class Pessoa or Cliente to display the property Cod instead of Full Qualified Name. Example: public class Pet { public int CodPet { get; set; } public…
c#answered Rovann Linhalis 14,881 -
2
votes1
answer301
viewsA: Creating a String in Postgresql
I do not know what the objective is, and what could be advantages and disadvantages of this; I had never thought about it until I saw your question and through curiosity I elaborated the answer. I…
-
3
votes1
answer135
viewsA: How to go through an array at each click on C#?
You don’t need a loop inside the button, you just have to assign the new image in the click. Example: int idx1 = 0; //Primeira imagem, posição 0 string[] filestiff; private void downbut_Click(object…
-
2
votes1
answer56
viewsA: Problem with Datareader together with Thread
Use a typed collection to represent this data. Example: public class ClienteCtaReceberModel { public string CdCliente {get;set;} public string NomeCliente {get;set;} public string Loja {get;set;} }…
-
2
votes2
answers799
viewsA: Read multiple text files using System.IO and Visual C# . NET and writing to these files
Like Victor said, the problem is you’re not clearing the list. Other than that, another code option: static void Main(string[] args) { string path = @"D:\Teste\"; string[] files =…
-
1
votes2
answers835
viewsA: How to make an auto ID increment relative to another field in Postgresql "Postgresql"?
At first, as rLinhares said, it’s not a PK, so you should send it to the bank. a simple sub-query solves the problem: insert into pedidos (id_pedido,id_empresa) values ((select…
-
2
votes1
answer2214
viewsA: How to add values within an array?
You will need to scroll through each element, turn into numerical, and add: public static void Main() { string input = "1230a"; int t = 0; foreach (char c in input) { int x; if…
-
1
votes1
answer2001
viewsA: Object cannot be converted to dbnull in other types
The field in question is returning Dbnull and you try to convert it to integer. Do checks before a conversion: public static Usuario Mapear(DataRow registro) { var usuario = new Usuario();…
-
2
votes3
answers5576
viewsQ: Incorrect daylight saving time on Postgresql
With the change of date of the start of daylight saving time this year, postgresql database are experiencing problems (as well as several other systems), going on to inform the timezone with dls…
-
3
votes3
answers5576
viewsA: Incorrect daylight saving time on Postgresql
This is because the bank’s Timezone files are outdated: Access the postgres, and download the latest version available (binaries only, no installer needed); Stop the service Copy the desired…
-
4
votes2
answers4833
viewsA: Error: Invalid thread operation
Possibly the event NewFrame is asynchronous, and when trying to access the pictureBox1 the exception is fired. You can use an invoke for this: video.NewFrame += (s, b) =>…
c#answered Rovann Linhalis 14,881 -
0
votes1
answer268
viewsA: C# Webbrowser How can I get innerHTML from a span within a div
In a perfect scenario, just take your id, and then the first span element after the document is loaded: private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs…
-
2
votes1
answer47
viewsA: How to pass a parameter to Dataprpetyname (in Datagrid) C#
When you add a column to DataGridView, you create an object DataGridViewColumn, which in your code is called codigo (there on the property Name). Then, you can change any object value. Example:…
-
0
votes3
answers58
viewsA: Condition does not contain in Datagridview
You first have to think about the problem without displaying the data, after solved use Datagridview only for display. I made a small example, I hope it helps to understand the problem: First you…
c#answered Rovann Linhalis 14,881 -
3
votes1
answer77
viewsA: Listbox items out of range
You don’t need all that code, just the troublesome part that has to do with it. In C# or VB.net, indexes start at 0, so the last position is equal to the number of items - 1. Example: Item: 1, 2, 3,…
vb.netanswered Rovann Linhalis 14,881 -
0
votes2
answers146
viewsA: C# - Datagridview does not change Defaultcellstyle.Backcolor property sent from a class to Form
As I said in the comments can not know very well how your program is, so I set an example to color the lines of Datagridview. The logic that will be used to define colors, you can put in the class,…
-
0
votes1
answer100
viewsA: Scan multiple checkboxes in a C#groupbox
You are displaying the message inside the loop. Just display it outside: String meat = ""; foreach (Control gb in this.Controls) { if (gb is GroupBox) { foreach (Control chk in gb.Controls) { if…
c#answered Rovann Linhalis 14,881 -
3
votes1
answer536
viewsA: Problem with Saving Image in Mysql C#
With a button you upload the file to PictureBox, right? Then, at the time of saving, you can take the Image of PictureBox, convert it into byte[] and execute the query passing as parameter. Example:…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer58
viewsA: Result of the come zeroed query
As I said, you need to select the months, and then select your data. The months you can generate numerical sequences from 1 to 12, or go giving select Union. Considering the following scenario:…
-
2
votes2
answers534
viewsA: Fill List with sql return
Just complementing the response, and explaining better the problem reported in the chat: Create a class for your results: public class PedidosDistribuidos { public string Protocolo {get;set;} public…
-
0
votes1
answer284
viewsA: Format numeric field with 2 decimal places in datagridview c#
The column you created, has no associated property, so Datagridview treats as a string and does not format with the N2. You can change your class ClasseItensXml to add the property PesoBruto and…
-
0
votes1
answer130
viewsA: Show xml nfe tag value in datagridview columns
First let’s change your class, just for aesthetic reasons: public class ClasseItensXml { public string CodigoProduto {get;set;} public string NomeProduto {get;set;} public string…
c#answered Rovann Linhalis 14,881 -
2
votes2
answers61
viewsA: How to display the values of two-class fields in a Datagridview?
You can use several ways: Anonymous object: dataGridView1.DataSource = cursos.Select(x=> new { Descrição = x.Descricao, Instituição = x.Instituicao.Nome }).ToList(); Add a Course property that…