16,011,839 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by denis.larocque (Top 6 by date)
denis.larocque
29-Apr-19 18:25pm
View
Thank you everyone all , work great now :)
denis.larocque
29-Apr-19 12:55pm
View
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
SqlConnection con;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: cette ligne de code charge les données dans la table 'isothermicDataSet.USR_ProdMonitor'. Vous pouvez la déplacer ou la supprimer selon les besoins.
this.uSR_ProdMonitorTableAdapter.FillBy(this.isothermicDataSet.USR_ProdMonitor);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
bool selected = !Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells["check"].Value);
dataGridView1.Rows[1].Selected = true;
DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
if (selected)
{
//change row color on Tab and change row
int next = this.dataGridView1.CurrentRow.Index + 1;
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
this.dataGridView1.CurrentCell = this.dataGridView1.Rows[next].Cells[this.dataGridView1.CurrentCell.ColumnIndex];
//add date to Date_pec
SqlConnection con = new SqlConnection(@"Data Source=srvqcsql-01;Initial Catalog=Isothermic;Integrated Security=True");
SqlCommand cmd = new SqlCommand("update USR_ProdMonitor SET Date_PEC = GETDATE() where Poste = 'PARCLOSE' and Date_PEC is null and ScanDate = (select top 1 MIN(ScanDate) from USR_ProdMonitor where Poste = 'PARCLOSE' and Date_PEC is null)", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
else
{
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightGreen;
dataGridView1.Rows[e.RowIndex].Cells["check"].Value = !Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells["check"].Value);
}
this.uSR_ProdMonitorTableAdapter.FillBy(this.isothermicDataSet.USR_ProdMonitor);
}
}
}
denis.larocque
29-Apr-19 12:54pm
View
i have symplify and modify my code i now that work but..
when i want to refresh the datagrid nothing what i try work.
if i put datagrid1.refresh(); nothing refresh
and if i put this.uSR_ProdMonitorTableAdapter.FillBy(this.isothermicDataSet.USR_ProdMonitor);
that give me error:System.NullReferenceException the object reference is not define an object instance.
denis.larocque
26-Apr-19 8:51am
View
ok i will start from zero, i have a BD on sql server and this db have already data on it.
on my program i have a datagrid to show this data. in this datagrid i have put a checkbox.
when i check this checkbox that will change the color of the row and go to next row. (this portion of code work great)
But i want in same time, add date and hour on cell in this selected row.(Date_pec) and in same time update the sql database and refresh the datagrid.
I dont no if im clear (my english is poor loll)
denis.larocque
26-Apr-19 8:39am
View
ok i have try that to, but that give me a error System.Data.SqlClient.SqlException : 'Incorrect syntax near '('.'
if (selected)
{
SqlConnection con = new SqlConnection(CONNECTION.CONNECTION_STRING_1);
SqlCommand cmd = new SqlCommand("UPDATE USR_ProdMonitor (Date_Pec) VALUES (@DATE)", con);
con.Open();
cmd.Parameters.AddWithValue("@DATE", DateTime.Now);
cmd.ExecuteNonQuery();
con.Close();
denis.larocque
26-Apr-19 7:46am
View
that if what i have try, but doent work,
what i want is when a click the checkbox in datagrid that input current date to the row in cell Date_pec, and update sql database (USR_Prodmonitor)
if (selected)
{
SqlConnection con = new SqlConnection(CONNECTION.CONNECTION_STRING_1);
string SqlCmdText = "INSERT INTO USR_ProdMonitor(Date_Pec)" + DateTime.Now
Show More