public async Task <IActionResult> Edit(DetailViewModel model) { if (!ModelState.IsValid) { return(View(model)); } EditRecord editRecord = new EditRecord(); if (model.Record.BorrowAmount != null) { editRecord.BorrowAmount = Convert.ToInt32(model.Record.BorrowAmount); } if (model.Record.ReturnAmount != null) { editRecord.ReturnAmount = Convert.ToInt32(model.Record.ReturnAmount); } var data = JsonConvert.SerializeObject(editRecord); string targetUri = _config["api"] + "/RitualMoney/" + model.Record.RitualMoneyRecordId; Uri address = new Uri(targetUri); ResultModel result = new ResultModel(); result = await _callApi.CallAPI(data, address, "PUT"); TempData["isSuccess"] = result.IsSuccess; TempData["msg"] = result.Message; return(RedirectToAction(nameof(GetRitualMoney))); }
void EditArea() { int index = (this.Owner as WorkAreas).lbox.Items.IndexOf(this.update_Area); int idTable = update_Area.Id; List <WorkArea> all = ReadFromDatabase.ShowAllAreas(num).ToList(); WorkArea update = all.Where(i => i.Id == idTable).FirstOrDefault(); update.SiteName = name_txt.Text; update.Login = login_txt.Text; update.Password = paswd_txt.Text; update.Phone = Convert.ToInt32(phone_txt.Text); update.URL = url_txt.Text; update.Email = email_txt.Text; update.Coments = coments_txt.Text; update.DateCreate = DateTime.Now; string res = EditRecord.EditInfo(update, num); MessageBox.Show(res, "Result Update"); (this.Owner as WorkAreas).lbox.Items.RemoveAt(index); (this.Owner as WorkAreas).lbox.Items.Insert(index, update); this.Close(); }
private void EditRecordExecute() { EditRecord view = new EditRecord(); view.DataContext = new EditRecordViewModel(view, SelectItem.ID); view.Owner = mWindow; bool?result = view.ShowDialog(); if (result == true) { ReFreshRecordExecute(); } }
private void edit_record(object sender, RoutedEventArgs e) { if (recordlist.SelectedIndex != -1) // Магия / не трогать { EditRecord ed = new EditRecord(recordlist.SelectedItem as Service); ed.Show(); this.Close(); } else { MessageBox.Show("Выберите запись!", "Error"); } }
private void WriteAccountInfo(String idRdr, String value) { String fieldNumber = "40"; Response response = _db.Login(); if (CheckResponse.ErrorCode(response)) { response = _db.FindReader(idRdr); SearchPacketData packetData = (SearchPacketData)response.Data; String mfn = packetData.GetMfn(); response = _db.ReadRecord(mfn); EditRecord.AddField(ref response, fieldNumber, value); response = _db.WriteRecord(mfn, response.Data.Rows[1]); } }
private void EditButton_Click(object sender, RoutedEventArgs e) { try { //On Edit Button click, pulls the data from that row of the datagrid, and stores it as a DataRowView object reportRow = (DataRowView)((Button)e.Source).DataContext; List <int> IDArray = Helper.FillIDList(StaffMeetingQuery()); // this PrioritizeBySystemPage, is being passed so it can be updated //priorBySystemRow is a DataRowView object containing the data from that row of PBS datagrid EditRecord editRecord = new EditRecord(this, arr, reportRow, IDArray); editRecord.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void EditRecordButton_Click(object sender, RoutedEventArgs e) { if (RecordsListView.SelectedIndex != -1) { if (ValidateInputFields()) { if (ValidateInputFormat()) { EditRecord editRecord = new EditRecord(con.Connect()); editRecord.EditRec(fieldsData, FindId()); RecordsListView.SelectedIndex = -1; LoadRecords(); } } } else { MessageBox.Show("Wybierz z listy rekord do poprawy!"); } }
//Author : Michael Figueroa //Name: AdHoc.xaml.cs //Function Name: //Purpose: This leads to edit record, allows user to scroll through each status in the report using arrows //Parameters: //Return Value: //Local Variables: //Algorithm: //Version: //Date modified: //Assistance Received: private void EditRecord_Click(object sender, RoutedEventArgs e) { try {//Author : Michael Figueroa //Name: AdHoc.xaml.cs //Function Name: //Purpose: On Edit Button click, pulls the data from that row of the datagrid, and stores it as a DataRowView object //Parameters: //Return Value: //Local Variables: //Algorithm: //Version: //Date modified: //Assistance Received: reportRow = (DataRowView)((Button)e.Source).DataContext; List <int> IDArray = Helper.FillIDList(customQuery); //Author : Michael Figueroa //Name: AdHoc.xaml.cs //Function Name: //Purpose: this PrioritizeBySystemPage, is being passed so it can be updated //priorBySystemRow is a DataRowView object containing the data from that row of PBS datagrid //Parameters: //Return Value: //Local Variables: //Algorithm: //Version: //Date modified: //Assistance Received: EditRecord editRecord = new EditRecord(this, arr, reportRow, IDArray); editRecord.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public async Task <ResultModel> Put(int id, [FromBody] EditRecord editRecord) { var result = new ResultModel(); bool check = false; //檢查是否空請求 foreach (PropertyInfo property in editRecord.GetType().GetProperties()) { if (property.GetValue(editRecord) != null) { check = true; break; } } if (check == false) { result.IsSuccess = false; result.Message = "請輸入資料"; return(result); } //================ var recordToUpdate = _context.RitualMoneyRecords.FirstOrDefault(r => r.RitualMoneyRecordId == id); if (recordToUpdate != null) { //限制未還款的紀錄先去還款頁面處理 if (recordToUpdate.IsReturn == false && editRecord.ReturnAmount != null) { result.IsSuccess = false; result.Message = "尚有未還願的借用紀錄"; return(result); } if (editRecord.BorrowAmount != null) { recordToUpdate.BorrowAmount = editRecord.BorrowAmount; } if (editRecord.ReturnAmount != null) { recordToUpdate.ReturnAmount = editRecord.ReturnAmount; } try { await _context.SaveChangesAsync(); result.IsSuccess = true; result.Message = "編輯成功"; } catch (Exception e) { result.IsSuccess = false; result.Message = "DB error."; } } else { result.Message = "查無發財金紀錄"; result.IsSuccess = false; } var accessToken = Request.Headers["Authorization"]; var user = await _TokenGetUserHelper.GetUser(accessToken); //logger.Info("userId=" + user.Id + ", username="******"\nEdit " + "RitualMoney id= " + recordToUpdate.RitualMoneyRecordId + " successfully."); return(result); }
public ActionResult Edit(THR_Recruit dto) { if (dto.Id > 0) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); THR_Recruit model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id); //状态为已入职,不能修改 if (model.EntryType == 3) { return(Content(this.GetJSON(new { Result = false, Msg = "状态为【已入职】,不能修改!" }), this.JsonContentType())); } if (dto.EntryType == 3 && dto.HireTime == null) { return(Content(this.GetJSON(new { Result = false, Msg = "已入职时,报到时间不能为空!" }), this.JsonContentType())); } if (dto.HireTime != null && DateTime.Compare(dto.HireTime.Value, DateTime.Now) > 0 && dto.EntryType == 3) { return(Content(this.GetJSON(new { Result = false, Msg = "报到时间不能超过今天!" }), this.JsonContentType())); //this.CopyObject<THR_Recruit>(model, dto); } model.HireTime = dto.HireTime; model.EntryType = dto.EntryType.Value; model.Remark = dto.Remark; model.EditTime = DateTime.Now; model.EditBy = this.AppUser().UserName; if (ctx.SaveChanges() >= 0) { var m = ctx.THR_Recruit.Where(c => c.Id == dto.Id).Select(c => new RecruitModel { DptId = c.DptId.Value, DptName = c.TErp_Department.DeptName, Id = c.Id, PostId = c.PostId.Value, PostName = c.TErp_Position.PositionName, Userurl = c.Userurl, Remark = c.Remark, Name = c.Name, Tel = c.Tel, Status = c.Status.Value, Interview = c.Interview, Email = c.Email, EntryType = c.EntryType.Value, NeedsName = c.THR_Needs.TErp_Department.DeptName + " " + c.THR_Needs.TErp_Position.PositionName, CreateBy = c.CreateBy, CreateTime = c.CreateTime, HireTime = c.HireTime, Interviewer = c.Interviewer }).FirstOrDefault(); HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == model.CreateBy); if (emp != null) { m.CreateBy = emp.name; } if (model.EntryType == 3)//已入职 { WcfRestClient client = new HKSJRecruitment.Web.WcfRestClientAppBase("Employee"); EditRecord <string> resultname = client.Get <EditRecord <string> >("Uid/" + m.Name); string uid = resultname.Dto; HKSJRecruitment.Models.proModels.EmployeeDto empdto = new HKSJRecruitment.Models.proModels.EmployeeDto { FullName = model.Name, CreateBy = 0, Uid = uid, CreateTime = DateTime.Now, Sex = "男", Mobile = model.Tel, EntryDate = model.HireTime.Value, Status = 2, IsDelete = 0, Education = "大专", DeptId = 0, PostId = 0, EditBy = 0, DeleteBy = 0, Email = model.Email }; EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> result = client.Post <HKSJRecruitment.Models.proModels.EmployeeDto, EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> >(empdto); } return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败,报到时间不能超过今天!", Dto = dto }), this.JsonContentType())); } }