私は現在立ち往生している問題に遭遇しました。例:
EmployeeShiftID | ShiftTime_Start | hiftTime_Stop | Name | Emp_Start | Emp_Stop
|(linked with foreign key)| (linked with FK) | | |
1 | 0000 | 1000 | Ken | 0000 | 1000
これらのデータは、外部キーがリンクされたデータグリッドビューに表示されました。また、Shiftの開始と停止もEmp_Startと停止に一致します。問題は、Emp_startとstopを更新すると、ShiftTime_StartとstopがEmp_StartとStopと比較されず、Emp_Startとstopを0430と2100に変更しようとしたときに0000と1000のままになることです。
データベースに保存した時間のタイプは、タイプ'time'ではなくStringです。誰かがそれを手伝ってくれますか?そのために行ったコードをすべて表示します。
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;
}
}