/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void EditTimeSheetCode_Click(object sender, DirectEventArgs e) { if (!int.TryParse(hdfKeyRecord.Text, out var id) || id <= 0) { return; } var modelTimeSheetCode = TimeSheetCodeController.GetById(id); if (modelTimeSheetCode != null) { txtTimeSheetCode.Text = modelTimeSheetCode.Code; dfStartTime.SetValue(modelTimeSheetCode.StartTime); dfEndTime.SetValue(modelTimeSheetCode.EndTime); hdfEmployeeSelectedId.Text = modelTimeSheetCode.RecordId.ToString(); cbxSelectedEmployee.Text = modelTimeSheetCode.FullName; chk_IsActive.Checked = modelTimeSheetCode.IsActive; hdfTimeMachineId.Text = modelTimeSheetCode.MachineId.ToString(); cbxTimeMachine.Text = modelTimeSheetCode.SerialNumber; } // show window btnUpdate.Show(); btnUpdateClose.Hide(); cbxSelectedEmployee.Disabled = true; wdTimeSheetCode.Title = @"Cập nhật mã chấm công"; wdTimeSheetCode.Show(); }
/// <summary> /// /// </summary> private void Update() { if (!string.IsNullOrEmpty(hdfKeyRecord.Text)) { DateTime?startTime = null; DateTime?endTime = null; var modelTimeSheet = TimeSheetCodeController.GetById(Convert.ToInt32(hdfKeyRecord.Text)); var currentTimeSheetCode = string.Empty; if (modelTimeSheet != null) { modelTimeSheet.EditedDate = DateTime.Now; currentTimeSheetCode = modelTimeSheet.Code; //Edit data EditData(modelTimeSheet, ref startTime, ref endTime); } var checkTime = TimeSheetCodeController.GetAll(null, null, null, txtTimeSheetCode.Text, null, true, startTime, endTime, null, null); if (checkTime.IsNullOrEmpty() || currentTimeSheetCode == txtTimeSheetCode.Text) { TimeSheetCodeController.Update(modelTimeSheet); Dialog.Alert("Cập nhật thành công"); } else { Dialog.Alert("Mã chấm công đã tồn tại. Vui lòng nhập mã chấm công khác!"); return; } } }