Id Emp_Id Category_IdI am using following code to get day from the given date
1 sss A
2 CCC A
3 VVV B
4 BBB B
Hide Copy Code
Int16 day = Convert.ToInt16(SafeConvert.ToDateTime(txtDate.Text).Day);i want that if day is even then change employee with category 'A' Change to category 'B' and Employee with category B CHANGE TO 'A',IF day is odd then opposite happen without changing the original table value that is store in table by user.

Sajid HussainPosted Apr 6, 2015, 4:57 AM
Gowtham RajamanickamPosted Apr 6, 2015, 4:26 AM
Syed ShanuPosted Apr 6, 2015, 4:20 AM
Sajid HussainPosted Apr 6, 2015, 4:06 AM
Syed ShanuPosted Apr 6, 2015, 2:25 AM
kiinly check the attached sample Source Program.In the Attached file Check for the Form2.Your solution is placed in Form2.
here is my code looks like.I have created using Winform.This can be used in both Win and Web form
Step 1) Add Datetime Picker,Button and datagridview Control to your form .
IN Form Load event.
DataTable DTable = new DataTable();
private void Form2_Load(object sender, EventArgs e)
{
//ServersTable - DataGridView
DTable.Columns.Add(new DataColumn("ID"));
DTable.Columns.Add(new DataColumn("Emp_Id"));
DTable.Columns.Add(new DataColumn("Category_Id"));
DataRow r = DTable.NewRow();
r.BeginEdit();
r["ID"] = "1";//writing values
r["Emp_Id"] = "SS";//writing values
r["Category_Id"] = "AA";//writing values
r.EndEdit();
DTable.Rows.Add(r);
r = DTable.NewRow();
r.BeginEdit();
r["ID"] = "2";//writing values
r["Emp_Id"] = "VV";//writing values
r["Category_Id"] = "AA";//writing values
r.EndEdit();
DTable.Rows.Add(r);
r = DTable.NewRow();
r.BeginEdit();
r["ID"] = "3";//writing values
r["Emp_Id"] = "KK";//writing values
r["Category_Id"] = "BB";//writing values
r.EndEdit();
DTable.Rows.Add(r);
r = DTable.NewRow();
r.BeginEdit();
r["ID"] = "4";//writing values
r["Emp_Id"] = "ZZ";//writing values
r["Category_Id"] = "BB";//writing values
r.EndEdit();
DTable.Rows.Add(r);
}
In Button Click
private void button1_Click(object sender, EventArgs e)
{
int value = Convert.ToInt32(dateTimePicker1.Value.Date.ToString("dd"));
string expression = "Category_Id = 'AA'";
if (value % 2 != 0)
{
expression = "Category_Id = 'AA'";
}
else
{
expression = "Category_Id = 'BB'";
}
DataView dv = new DataView(DTable);
dv.RowFilter = expression; // query example = "id = 10"
dataGridView1.DataSource = dv;
}