public async Task Insert(ShiftView entity) { try { var vList = new Shift { Shift_Id = entity.Shift_Id, Company_Id = entity.Company_Id, Shift_Code = entity.Shift_Code, Shift_Name = entity.Shift_Name, Shift_Start = entity.Shift_Start, Shift_End = entity.Shift_End, NightShift = entity.NightShift, Shift_Variable = entity.Shift_Variable, isActive = entity.isActive, AddedOn = DateTime.Now, AddedBy = entity.AddedBy }; adbContext.shift.Add(vList); await Task.FromResult(adbContext.SaveChanges()); } catch (Exception ex) { throw ex; } }
public async Task Update(ShiftView entity) { try { var lstShift = adbContext.shift.Where(x => x.Shift_Id == entity.Shift_Id).FirstOrDefault(); if (lstShift != null) { lstShift.Company_Id = entity.Company_Id; lstShift.Shift_Code = entity.Shift_Code; lstShift.Shift_Name = entity.Shift_Name; lstShift.Shift_Start = entity.Shift_Start; lstShift.Shift_End = entity.Shift_End; lstShift.NightShift = entity.NightShift; lstShift.Shift_Variable = entity.Shift_Variable; lstShift.isActive = entity.isActive; lstShift.UpdatedBy = entity.UpdatedBy; lstShift.UpdatedOn = DateTime.Now; adbContext.shift.Update(lstShift); await Task.FromResult(adbContext.SaveChanges()); } else { throw new Exception("Data Not Available"); } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Edit(ShiftView shift) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = "Invalid Model State"; return(BadRequest(objHelper)); } try { if (shiftRepository.Exists(shift)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await shiftRepository.Update(shift); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; return(Ok(objHelper)); } catch { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = "Save Unsuccessful"; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public bool Exists(ShiftView entity) { int intCount = 0; if (entity.Shift_Id > 0) //Update Validation { intCount = adbContext.shift.Where(w => w.Company_Id == entity.Company_Id && w.Shift_Id != entity.Shift_Id && (w.Shift_Code == entity.Shift_Code && w.Shift_Name == entity.Shift_Name)).Count(); } else //Insert Validation { intCount = adbContext.shift.Where(w => w.Company_Id == entity.Company_Id && (w.Shift_Code == entity.Shift_Code && w.Shift_Name == entity.Shift_Name)).Count(); } return(intCount > 0 ? true : false); }
private void tsbDelete_Click(object sender, EventArgs e) { //系统提示确定要删除吗? if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.Msg.DeleteRemind}"), StringParser.Parse("${res:Global.SystemInfo}"))) { DataSet dataSetSchedule = new DataSet(); dataSetSchedule.Tables.Add(); dataSetSchedule.Tables[0].TableName = CAL_SCHEDULE.DATABASE_TABLE_NAME; dataSetSchedule.Tables[0].Columns.Add(CAL_SCHEDULE.FIELD_SCHEDULE_KEY); dataSetSchedule.Tables[0].Rows.Add(); dataSetSchedule.Tables[0].Rows[0][0] = _schedule.ScheduleKey; dataSetSchedule.Tables.Add(); dataSetSchedule.Tables[1].TableName = CAL_SHIFT.DATABASE_TABLE_NAME; dataSetSchedule.Tables[1].Columns.Add(CAL_SHIFT.FIELD_SHIFT_KEY); for (int i = 0; i < ShiftView.RowCount; i++) { dataSetSchedule.Tables[1].Rows.Add(); dataSetSchedule.Tables[1].Rows[i][0] = ShiftView.GetRowCellValue(i, shift_key).ToString(); } //删除信息 _schedule.DeleteSchedule(dataSetSchedule); if (_schedule.ErrorMsg == "") { //系统提示删除成功! MessageService.ShowMessage("${res:FanHai.Hemera.Addins.Msg.DeleteSucceed}", "${res:Global.SystemInfo}"); foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { //标题等于班次管理 if (viewContent.TitleName == StringParser.Parse("${res:FanHai.Hemera.Addins.EMS.ScheduleViewContent.ViewContentScheduleTitle}")) { //关闭窗体 WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.CloseWindow(true); viewContent.WorkbenchWindow.SelectWindow(); return; } } //班次管理 WorkbenchSingleton.Workbench.ActiveViewContent.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.EMS.ScheduleViewContent.ViewContentScheduleTitle}"); //状态设置为new CtrlState = ControlState.New; } else { MessageService.ShowError("${res:FanHai.Hemera.Addins.Msg.DeleteFailed}" + _schedule.ErrorMsg); } } }
private void btnAdd_Click(object sender, EventArgs e) { Shift shift = new Shift(); ShiftEditDialog shiftDialog = new ShiftEditDialog(_schedule.ScheduleKey, shift); if (DialogResult.OK == shiftDialog.ShowDialog()) { ShiftView.AddNewRow(); DataRow newRow = ShiftView.GetDataRow(ShiftView.FocusedRowHandle); newRow[CAL_SHIFT.FIELD_SHIFT_KEY] = shift.ShiftKey; newRow[CAL_SHIFT.FIELD_SHIFT_NAME] = shift.ShiftName; newRow[CAL_SHIFT.FIELD_START_TIME] = shift.StartTime; newRow[CAL_SHIFT.FIELD_END_TIME] = shift.EndTime; newRow[CAL_SHIFT.FIELD_OVER_DAY] = shift.OverDay; newRow.EndEdit(); ShiftView.UpdateCurrentRow(); ShiftView.ShowEditor(); } }
private void btnEdit_Click(object sender, EventArgs e) { int rowHandle = 0; if (ShiftView.FocusedRowHandle < 0) { MessageService.ShowMessage("${res:FanHai.Hemera.Addin.SelectRemaind}", "${res:Global.SystemInfo}"); } else { rowHandle = ShiftView.FocusedRowHandle; Shift shift = new Shift(); shift.ShiftKey = this.ShiftView.GetRowCellValue(rowHandle, shift_key).ToString(); ShiftEditDialog shiftDialog = new ShiftEditDialog(_schedule.ScheduleKey, shift); if (DialogResult.OK == shiftDialog.ShowDialog()) { ShiftView.SetRowCellValue(rowHandle, shift_name, shift.ShiftName); ShiftView.SetRowCellValue(rowHandle, start_time, shift.StartTime); ShiftView.SetRowCellValue(rowHandle, end_time, shift.EndTime); ShiftView.SetRowCellValue(rowHandle, over_day, shift.OverDay); } } }
private void btnDel_Click(object sender, EventArgs e) { //系统提示确定要删除吗? if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.Msg.DeleteRemind}"), StringParser.Parse("${res:Global.SystemInfo}"))) { int rowHandle = 0; //焦点没有获取到 if (ShiftView.FocusedRowHandle < 0) { //系统提示没有选中行 MessageService.ShowMessage("${res:FanHai.Hemera.Addin.SelectRemaind}", "${res:Global.SystemInfo}"); return; } else { rowHandle = ShiftView.FocusedRowHandle; Shift shift = new Shift(); shift.ScheduleKey = _schedule.ScheduleKey; shift.ShiftKey = this.ShiftView.GetRowCellValue(rowHandle, shift_key).ToString(); if (shift.ShiftKey != string.Empty && shift.ScheduleKey != string.Empty) { shift.DeleteShift(); if (shift.ErrorMsg == string.Empty) { //delete row from gridView 删除成功 MessageService.ShowMessage("${res:FanHai.Hemera.Addins.Msg.DeleteSucceed}", "${res:Global.SystemInfo}"); ShiftView.DeleteSelectedRows(); } else { MessageService.ShowError("${res:FanHai.Hemera.Addins.Msg.DeleteFailed}" + shift.ErrorMsg); } } } } }