/// <summary> /// 更新選項 /// </summary> public bool updateFormOptionSetting(long id, Dictionary <string, object> dic) { bool ret = false; using (NaNaEntities db = new NaNaEntities()) { FormOptionsSetting f = db.FormOptionsSetting.AsQueryable().FirstOrDefault(x => x.id == id); if (f == null) { return(false); } Type cl = f.GetType(); foreach (var obj in dic) { if (cl.GetProperty(obj.Key) != null) { cl.GetProperty(obj.Key).SetValue(f, obj.Value); } } db.SaveChanges(); ret = true; } return(ret); }
/// <summary> /// 新增一筆選項 /// </summary> public FormOptionsSetting addFormOptionSetting(FormOptionsSetting f) { FormOptionsSetting ret = null; using (NaNaEntities db = new NaNaEntities()) { ret = db.FormOptionsSetting.Add(f); db.SaveChanges(); } return(ret); }
public FormOptionsSettingViewModel.FormOptionsResult addFormOptionSetting(FormOptionsSetting f) { FormOptionsSettingViewModel.FormOptionsResult ret = new FormOptionsSettingViewModel.FormOptionsResult(); try { ret.success = true; ret.resultCode = "200"; ret.f = this.formOptionSettingDao.addFormOptionSetting(f); } catch (Exception ex) { ret.success = false; ret.resultCode = "500"; ret.resultMessage = ex.ToString(); } return(ret); }
protected void btn_add_option_Command(object sender, CommandEventArgs e) { var field_select_value = this.ddl_fields.SelectedValue; if (string.IsNullOrEmpty(field_select_value)) { return; } FormOptionsSetting f = new FormOptionsSetting() { dateCreated = DateTime.Now, deleted = false, fieldID = Guid.Parse(field_select_value), fieldName = this.ddl_fields.SelectedItem.Text, formName = this.ddl_forms.SelectedItem.Text, formNo = this.ddl_forms.SelectedValue, formOID = this.ddl_forms.SelectedValue, id = 0, needKeyIn = this.chk_add_needKeyIn.Checked, sort = int.Parse(this.txt_add_sort.Text), text = this.txt_add_text.Text, type = this.hid_select_field_type.Value, value = this.txt_add_value.Text }; this.formOptionSettingSvc.addFormOptionSetting(f); this.txt_add_sort.Text = "0"; this.txt_add_text.Text = ""; this.txt_add_value.Text = ""; this.chk_add_needKeyIn.Checked = false; this.reload_options_list(); return; }
public FormOptionsResult() : base() { this.f = null; }