TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
693
1.3k
219.4k
One logic for Time period...
Sep 29 2014 11:00 AM
Table: "CODE"
Password
42
Table: "CONTROL"
Data
8_12h
14_16h
Password
Result
14/09/2014
1
1
42
2
With these two tables I need to make some logic.
A)
In the "CODE" table there is the password 42. Then when this password it's found in it's should save it in the "CONTROL" table (column "password"). If its doesn't found it in the CODE table its cannot save it in the CONTROL table.
B)
but if the password it's found in the "CONTROL" table (mean that he already been in the table). Then it's should make a filter bringing to appropriate textboxes. Make an "update" to save the record (but in certain period as explain it in "C")
C)
But there is a condition: the record should be saved in some unique period. For example, ONLY between 8h-12h and between 14h-16h. Any records cannot be saved between 12h01-13h59 (MUST be rejected in this period)
D)
in making updating where there is already a number it's cannot save TWICE. Only on other column respecting period time.
Then see what I try to do: search, showing datas to textboxes and updating. The problem is ONLY on the point "C" (how to make saving in certain period ONLY one day ONCE)
Research process:
private void btnSearch_Click(object sender, EventArgs e)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\INAC\Documents\Windows_Application_Samples\Saving_in_table_choosing_time\\app_data\office.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from tempo where password ='" + textBox1.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
textBox2.Text = read["data"].ToString(); // it will show the code
textBox3.Text = read["8_12h"].ToString(); // it will show the code
textBox4.Text = read["14_16h"].ToString(); // it will show the code
textBox5.Text = read["password"].ToString(); // it will show the code
textBox6.Text = read["result"].ToString(); // it will show the code
}
}
else
{
MessageBox.Show("A record with a code of " + textBox1.Text + " was not found");
}
read.Close();
sqlCon.Close();
}
Saving process:
Conn.Open();
oleDbCmd.Connection = Conn;
oleDbCmd.CommandText = "insert into tempo (data, 8_12h, 14_16h, password, result) values ('" + this.textbox1.Text + "','" + this. Textbox2.Text + "', '"
+ this.Textbox3.Text + "','" + this.Textbox4.Text + "','"
+ this.Textbox5.Text.Text + "');";
int temp = oleDbCmd.ExecuteNonQuery();
if (temp > 0)
{
textbox1.Text = null;
textbox2.Text = null;
textbox3.Text = null;
textbox4.Text = null;
textbox5.Text = null;
MessageBox.Show("Saved");
}
else
{
MessageBox.Show("Not save");
}
Conn.Close();
}
Reply
Answers (
1
)
How to import file into gridview in C# windows?
How can we manage entities module wise in entity framework?