Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table in sql like following structure
C#
Id   Emp_Id       Category_Id    
1     sss             A
2     CCC             A
3     VVV             B
4     BBB             B

I am using following code to get day from the given date
C#
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.
Posted

1 solution

 
Share this answer
 
Comments
Sajid227 6-Apr-15 4:08am    
i am using following code
DateTime date = SafeConvert.ToDateTime(txtDate.Text);
Int16 day = Convert.ToInt16(SafeConvert.ToDateTime(txtDate.Text).Day);
if (day % 2 == 0)
{
var empcatone = (from ec in entities.EmployeeCategories where ec.Category_Id == 1 select ec).ToList();
foreach (var Empcatone in empcatone)
{

Empcatone.Category_Id = 2;



}
var empcattwo = _service.GetAllEmployeeCategory().Where(x => x.Category_Id == 2).ToList();
foreach (var Empcattwo in empcattwo)
{
Empcattwo.Category_Id = 1;

}

}
else if (day % 2 != 0)
{
var empcatone = _service.GetAllEmployeeCategory().Where(x => x.Category_Id == 2).ToList();
foreach (var Empcatone in empcatone)
{
Empcatone.Category_Id = 1;

}
var empcattwo = _service.GetAllEmployeeCategory().Where(x => x.Category_Id == 1).ToList();
foreach (var Empcattwo in empcattwo)
{
Empcattwo.Category_Id = 2;

}


}
pro\blem is that data is not updaing in respective column

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900