Posts by Rovann Linhalis • 14,881 points
567 posts
-
1
votes1
answer126
viewsA: Where with date and time - Entity Framework
I see no reason to separate Date of Time... in C# Datetime treats both, so if you convert "08:10" to Datetime, the value will be 01/01/0001 08:10:00. You need to inform Date as well. Also, you can…
-
0
votes1
answer139
viewsA: Simultaneous insertion of items and sales with C#, Windows Forms and Postgresql
You need to open a transaction, in the first Insert returns the code that was inserted and then uses it to insert the items. If all goes well, run Commit, otherwise Rollback. Example: using…
-
2
votes1
answer61
viewsA: How to get the value of a property with Expression?
You can split the string and go through the array generating a Expression and passing itself as a parameter: public static string ObterValorExp(object obj, string prop) { string[] props =…
c#answered Rovann Linhalis 14,881 -
2
votes3
answers124
viewsA: How can I use or name constants for response type fields?
In such cases, we should use constants? I don’t think so. "Constants are fields whose values are defined at compile time and can never be changed.". An example of constant is PI, where whenever you…
-
3
votes2
answers134
viewsA: Error creating a Custom Exception
You must be running the program, not just compiling. When running the program and typing 0, the exception shown as an exception not dealt with by the visual studio debug is generated. As I commented…
c#answered Rovann Linhalis 14,881 -
3
votes1
answer74
viewsA: IF record = X, LEFT JOIN in table 1, IF record = Y, LEFT JOIN in table 2
You have to do the Join with both, and the data you select what you need: SELECT ass.*, (CASE WHEN ass.TipoUsuario = 'A' THEN a.[campo] WHEN ass.TipoUsuario = 'C' THEN c.[campo] ELSE '?' END) as…
mysqlanswered Rovann Linhalis 14,881 -
-1
votes2
answers828
viewsA: Doubt when creating table with dates in postgresql
As I mentioned in the comments, I do not see why Tabela1 seems to me only parameter of the query. Anyway, I used only the smaller date to be displayed as the initial of the first record. The query…
-
0
votes2
answers3274
viewsA: C# - XML return from Webservice with encoding error (ISO-8859-1)
You can add a Web Reference instead of a Service Reference: Add Service Reference -> Advanced... -> Add Web Reference... -> Type WSDL / URL -> Add Reference Then set the request…
-
3
votes2
answers1521
viewsA: Query SQL - put result in a row only
You need to use the STRING_AGG aggregation function: SELECT pga.Titulo, STRING_AGG(e.Codigo,', ') as Codigos FROM Qualidade_Diagrama_Processo_Grupo_Acao pga JOIN Qualidade_Diagrama_Acao_Entidade ae…
-
1
votes1
answer471
viewsA: How to select the contents of a column coming from a Dataset C#
There is a better way to search the contents of a specific column? Yes, if you already have the name of the column, just do: row["modelo"].ToString(); or could do just…
-
1
votes2
answers256
viewsA: Configuration file for C# Winforms
As Maniero said, the Windows Forms, You use the inheritance. A Singleton, or create "a file where I can define ... a color with the name 'Background' and add the value '#fff'" may even work, but it…
-
4
votes2
answers96
viewsA: Postgresql database restrictions on commercial application
Licensing restrictions: None, the source is open. Maximum size for a database: unlimited (there are databases of 32 TB) Maximum size for a table: 32 TB Maximum length of a line: 1,6 TB Maximum size…
-
0
votes1
answer100
viewsA: String with Mark in C#
In your Form, set the following properties: BackColor = 218; 255; 195; FormBorderStyle = None; Opacity = 70%; ShowInTaskbar = False; StartPosition = Manual; TopMost = True; Height = 50; All these…
c#answered Rovann Linhalis 14,881 -
1
votes1
answer214
viewsA: Count and group by day range
I recommend making a track table or a view, where you configure the desired ranges. Then just make a SELECT with COUNT grouping by band. Example: create table faixas ( faixa varchar(10), inicio…
-
0
votes1
answer224
viewsA: How to define the space a string will occupy in C# / Pdfsharp
As we can see in pdfsharp code, the constructor is defined as: public XRect(double x, double y, double width, double height). Thinking of the two axes, X (Horizontal from left to right) and Y…
-
0
votes2
answers117
viewsA: How to turn an array of bytes into an image in WPF?
Use a Memorystream: System.Drawing.Image img = null; using (MemoryStream ImageDataStream = new MemoryStream()) { ImageDataStream.Write(bData, 0, bData.Length); ImageDataStream.Position = 0; bData =…
-
1
votes2
answers493
viewsA: How to do if in sql - Postgres
The way it is in the question, you don’t need to use if or case. @Lisângelo Berti’s answer solves your problem. You do not need to check that the value of a column is null, and then apply a filter.…
-
0
votes1
answer388
viewsA: Treeview with Nodes & Childs via SQL database
I made this method that I use a few years ago, and even so I still used a Datatable as input data, if I were to do it again, I would use a List of an object. Would be easier. You can take advantage…
-
0
votes2
answers463
viewsA: System.Nullreferenceexception error when trying to pass Value from one Form to another Winforms C#
Forms are classes like any other, just create properties or make the controls public to access. The method you used works because all the controls are stored in the collection Controls form and are…
-
4
votes1
answer13099
viewsA: 3-letter abbreviation table for cities by state
Officially, I also searched and found nothing about, I believe that if there was, would be in IBGE. The solution could be an algorithm of its own, and of course, keep these records stored in case…
stringanswered Rovann Linhalis 14,881 -
1
votes1
answer391
viewsA: With email attachment via ASP.NET application
Only you use the class System.Net.Mail.Attachment: using (SmtpClient smtpCliente = new SmtpClient()) { MailMessage mail = new MailMessage(); smtpCliente.Host = param.Smtp; smtpCliente.Port =…
-
5
votes2
answers453
viewsA: Increment variable while holding a button
Put a Timer in your form, and set the range that the variable will increment while with the mouse pressed. Done this, you use the Event MouseDown Button, to enable the timer, and the event MouseUp…
-
1
votes3
answers1026
viewsA: Query SQL, Always show record of a repeating field first
You can filter through Id with a sub-select by the revision number: SELECT p.processo, p.revisao, p.titulo, p.id, p.data_criacao FROM processos p WHERE p.id = ( SELECT top 1 x.id FROM processos x…
-
1
votes2
answers141
viewsA: How to create a class and pass an attribute value in the class constructor in C#
The ideal would be an inheritance, so: public class Response { [JsonProperty("paging")] public ResponsePaging Paging { get; set; } [JsonProperty("sort")] public Dictionary<string, string> Sort…
-
1
votes1
answer136
viewsA: Cross Table in Mysql
Vyou can use multiple sub-selects for this, as I understand it, the order of the columns is given by the date column, and will always be 4 columns. So: select distinct h.ticket, (select x.fila from…
-
2
votes1
answer36
viewsA: Calling a method
First point is that the two strings are not with access modifiers, soon are private and will only be accessible within the class itself. Taking advantage and changing the code, because it makes no…
-
2
votes1
answer509
viewsA: Call Form2 with Circular Progress Bar while another action is executed C#
There are several ways to make the progress bar, but I believe that when it comes to Windows Forms, the ideal is to use the BackgroundWorker that performs the work in the background, leaving the…
-
1
votes1
answer53
viewsA: Replacing Checkbox with a String
I’m going to assume that your object carried on DataGridView be the ConvenioNegocio. Then, you create a read-only property that will display the value as string: public class ConvenioNegocio {…
-
1
votes2
answers926
viewsA: How to reference the webservices of eSocial by Visual Studio?
In the Technical Documentation made available, has the "Communication Package". Inside it, you have the WSDL to use the Webservice. In Visual Studio, just add the "Webreference" the same way you are…
-
2
votes1
answer789
viewsA: The operator "==" cannot be applied to operators of type "string" and "long"
This happens because the property Id of the product is a string and the parameter passed codigoProduto is long and you can’t compare a number to a text. In this situation, you can pass as parameter…
-
2
votes2
answers1554
viewsA: Mask CURRENCY {en-BR} in Gridview C#
The First problem is that you are using RowCount and not .Rows.Count in this way he is only going through the lines that are being displayed and not all the lines of the collection. But this is also…
-
0
votes1
answer39
viewsA: Take 1 record per date, without repeating the date
First you select the Day (Date without time) and then you use the MIN function on the date and time, grouping by day. Example: select cast(c.data as date) as dia, min(c.data) as abertura from caixas…
-
0
votes3
answers674
viewsA: how to count integers in c#
Sometimes I like to ask these questions of exercises that appear, only for memories of college, but I’m afraid to, instead of helping, disturb you (giving you a glue to solve the task). As I imagine…
c#answered Rovann Linhalis 14,881 -
4
votes3
answers902
viewsA: RETURN THE SUM OF MAXIMUM 3 SQL VALUES
Another approach, using row_number(): select x.recipient, sum(x.amount) as soma from (select t.recipient, t.amount, row_number() over (partition by recipient order by amount desc) as i from…
-
6
votes1
answer9809
viewsA: Oracle - Filter by date
Error says that the given format (DD/MM/YYYY) ends before converting the input string, because in the format it has no time and in the given parameter it has. So just take the time (00:00:00): AND…
-
9
votes1
answer1024
viewsQ: Generate classes with XSD or import WSDL [ANS / TISS]
To ANS provides the files .XSD, and the .WSDL for the implementation of the protocol TISS. Sand I type the code by . XSD, I have the classes structured correctly. Example: namespace TissV3 { class…
-
0
votes1
answer161
viewsA: How to view data from various tables in Datagridview?
You have to create a new class, to be used as a "ViewModel", or use anonymous objects: Class: public class PessoaViewModel { public string Nome {get;set;} public string Endereco {get;set;} } Source:…
-
0
votes1
answer624
viewsA: Sum values in a Select (postgres)
You take the lucro group by, and places this column inside the function Sum() Would look like this: select i.empresa, i.exercicio, Sum(case when c.lucrocontabil=0 then c.lucrosimples else…
-
1
votes2
answers456
viewsA: String Field List Sorting
Create a enum for the classifications and order by it: public enum Avaliacoes { Excelente = 0, Bom = 1, Regular = 2, Ruim = 3, Pessimo = 4 } I made an example code: using System; using System.Linq;…
-
2
votes1
answer1374
viewsA: Leave Selected specific item Combobox C# Winforms Visual Studio 2017
You can set the property SelectedValue: CbCidade.SelectedValue = 1; //supondo que 1 seja código de Sao Paulo or you can set Text as well: CbCidade.Text = "SAO PAULO"; Although I find it unnecessary…
-
1
votes1
answer1250
viewsA: Identify selected item Listview
You can use the SelectedIndexChanged. Example: private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { MessageBox.Show("Código do…
c#answered Rovann Linhalis 14,881 -
0
votes3
answers251
viewsA: How to separate in pairs the digits of a variable in C#?
The question is very vague, you can not know the type of the variable and what would be the purpose of this, but considering that it is a string, you can do so: Example using 5 values to illustrate:…
c#answered Rovann Linhalis 14,881 -
2
votes3
answers2371
viewsA: Download all columns of all tables containing a text
I’ve done this job thinking of your need: Basically selects all the columns of all the tables of the schema informed, and which are varchar or text. Then go through mounting a query, and return the…
-
1
votes1
answer143
viewsA: How to download direct from TXT file
Set the header for WebClient for Text/Plain: using (WebClient wc = new WebClient()) { wc.Headers.Set("Content-Type", "text/plain"); url = "http://www.dominio.com.br/teste.txt"; string retorno =…
-
2
votes1
answer36
viewsA: C# - High memory consumption when calling method
Try while removing the controls from the panel (painel.Controls.Clear();) discard the forms: painel.ControlRemoved += (ss, ee) => { ee.Control.Dispose(); };…
-
1
votes1
answer29
viewsA: C# - Add Mousehover to each Button in a Flowlayout
You have to first go through the controls of FlowLayoutPanel but only the kind Button, and then associate the event using the sender of the method: private void frmMain_Load(object sender, EventArgs…
-
2
votes2
answers247
viewsA: Query in the same table
You did not specify which database you are using, but you can do this in several ways. I used the example Mysql and made 2 ways to do this: Using EXISTS: select distinct m.registro from movimento m…
-
2
votes2
answers494
viewsA: SQL Left Join - shorter date longer than current date
Only use Subselect: SELECT p.Id, p.Scope, p.EntryDate, p.Applicant, p.Status, (SELECT MAX(ev.EventDateTime) FROM event ev WHERE ev.processId = p.id) as evento_recente, (SELECT MIN(a.ExpireDate) FROM…
-
0
votes2
answers391
viewsA: Bring the second and third line of a query
It depends a lot on how your system works... and if the person hits the point more than 4x in the day... would see how it looks there... Following the code you’ve already set for example, it could…
-
0
votes2
answers88
viewsA: Foreign key in Webapi with dotnet core
In the Entity Framework Core, you don’t need to create property for foreign key. Just do: public class Curso { public int Id { get; set; } public string Nome { get; set; } public…