public bool updateEmployeeTransportationSetting(long id, Dictionary <string, object> dicObj) { bool ret = false; using (NaNaEntities db = new NaNaEntities()) { EmployeeTransportationSetting e = db.EmployeeTransportationSetting.AsQueryable().FirstOrDefault(x => x.Id == id); //不存在此資料 if (e == null) { return(false); } Type cl = e.GetType(); foreach (var obj in dicObj) { if (cl.GetProperty(obj.Key) != null) { cl.GetProperty(obj.Key).SetValue(e, obj.Value); } } db.SaveChanges(); ret = true; } return(ret); }
public EmployeeTransportationSetting addEmployeeTransportationSetting(EmployeeTransportationSetting e) { EmployeeTransportationSetting ret = null; using (NaNaEntities db = new NaNaEntities()) { ret = db.EmployeeTransportationSetting.Add(e); db.SaveChanges(); } return(ret); }
protected void btn_admEmployeeTransportationSetting_add_Click(object sender, EventArgs e) { this.lt_akert_msg.Text = ""; //check this empNo is Exist in row FormOptionsSettingViewModel.EmployeeTransportationSettingQueryParameter param = new FormOptionsSettingViewModel.EmployeeTransportationSettingQueryParameter() { desc = true, keyword = "", orderField = "EmpNo", pageIndex = 1, pageSize = int.MaxValue, transType = this.ddl_admEmployeeTransportationSetting_trans_type.SelectedValue, empNo = this.hid_admEmployeeTransportationSetting_emp.Value }; FormOptionsSettingViewModel.ViewEmployeeTransportationSettingListResult list_ret = this.formOptSvc.getViewEmployeeTransportationSettingListResult(param); if (list_ret.count > 0) { this.lt_akert_msg.Text = UtilitySvc.alertMsg("此員工已存在"); return; } EmployeeTransportationSetting ee = new EmployeeTransportationSetting() { DateCreated = DateTime.Now, Deleted = false, EmpNo = this.hid_admEmployeeTransportationSetting_emp.Value, TransId = this.txt_admEmployeeTransportationSetting_transId.Text, TransType = this.ddl_admEmployeeTransportationSetting_trans_type.SelectedValue }; FormOptionsSettingViewModel.ViewEmployeeTransportationSettingResult add_ret = this.formOptSvc.addEmployeeTransportationSetting(ee); if (add_ret.success) { this.lt_akert_msg.Text = UtilitySvc.alertMsg("新增成功"); } else { this.lt_akert_msg.Text = UtilitySvc.alertMsg(add_ret.resultException); } }
/// <summary> /// 新增員工私車公用設定檔 /// </summary> public FormOptionsSettingViewModel.ViewEmployeeTransportationSettingResult addEmployeeTransportationSetting(EmployeeTransportationSetting e) { FormOptionsSettingViewModel.ViewEmployeeTransportationSettingResult ret = new FormOptionsSettingViewModel.ViewEmployeeTransportationSettingResult(); try { ret.success = this.formOptionSettingDao.addEmployeeTransportationSetting(e) != null; ret.resultCode = "200"; } catch (Exception ex) { ret.success = false; ret.resultException = ex.ToString(); ret.resultCode = "500"; } return(ret); }