我遇到了一个我目前陷入困境的问题。例子:
EmployeeShiftID | ShiftTime_Start | hiftTime_Stop | Name | Emp_Start | Emp_Stop
|(linked with foreign key)| (linked with FK) | | |
1 | 0000 | 1000 | Ken | 0000 | 1000
这些数据显示在数据网格视图中,外键链接。并且 Shift start 和 stop 也匹配 Emp_Start 和 stop。问题是当我更新 Emp_start 和 stop 时,ShiftTime_Start 和 stop 不与 Emp_Start 和 Stop 比较,并且在我尝试将 Emp_Start 和 stop 更改为 0430 和 2100 时保持为 0000 和 1000。
我保存在数据库中的时间类型是字符串而不是“时间”类型。任何人都可以帮助我吗?我将展示我为它所做的任何代码。
private void btnUpdate_Click(object sender, EventArgs e)
{
using (testEntities Setupctx = new testEntities())
{
int ID = Int32.Parse(lblID.Text);
var ESquery = (from es in Setupctx.employeeshifts
where es.EmployeeShiftID == ID
select es).First();
ESquery.StartTime = txtStart.Text;
ESquery.EndTime = txtStop.Text;
ESquery.Date = txtDate.Text;
Setupctx.SaveChanges();
txtStart.Text = "";
txtStop.Text = "";
txtDate.Text = "";
this.Edit_Employee_Shift_Load(null, EventArgs.Empty);
MessageBox.Show("Employee's Shift Has Been Updated.");
}
}
private void LoadAllEditEmpShift()
{
using (testEntities Setupctx = new testEntities())
{
BindingSource BS = new BindingSource();
var Viewemp = from ES in Setupctx.employeeshifts
join shifthour sh in Setupctx.shifthours on ES.ShiftHourID equals sh.idShiftHours
select new
{
ES.EmployeeShiftID,
ShiftHour_Start = sh.shiftTiming_start,
ShiftHour_Stop = sh.shiftTiming_stop,
ES.EmployeeName,
ES.StartTime,
ES.EndTime,
ES.Date
};
BS.DataSource = Viewemp;
dgvEmpShift.DataSource = BS;
}
}