//窗体加载 private void Infrared_Load(object sender, EventArgs e) { My_RunCode = BLL.MyLog.DL_Run.Insert(this.Text); C_Infrared InfraredItem = new C_Infrared(); InfraredBLL.DataShow(InfraredItem); this.Cb_Enable.Checked = InfraredItem.Enable; this.Cmb_Infrared1.SelectedByValue(InfraredItem.Infrared1); this.Cmb_Infrared2.SelectedByValue(InfraredItem.Infrared2); }
//保存 private void Btn_Save_Click(object sender, EventArgs e) { C_Infrared InfraredItem = new C_Infrared(); InfraredItem.Enable = this.Cb_Enable.Checked; InfraredItem.Infrared1 = Convert.ToInt32(this.Cmb_Infrared1.SelectedValue); InfraredItem.Infrared2 = Convert.ToInt32(this.Cmb_Infrared2.SelectedValue); if (InfraredBLL.Update(InfraredItem)) { Function.Message("修改成功!"); } }
/// <summary> /// 显示信息 /// </summary> /// <returns>返回数据源</returns> public static void DataShow(C_Infrared Item) { try { PublicFun.IniFile Ini = new PublicFun.IniFile(WSV.Model.FilePath.Config); if (Ini.ExistIniFile()) { Item.Enable = Convert.ToBoolean(Ini.IniReadValue("Infrared", "Enable")); Item.Infrared1 = Convert.ToInt32(Ini.IniReadValue("Infrared", "Infrared1")); Item.Infrared2 = Convert.ToInt32(Ini.IniReadValue("Infrared", "Infrared2")); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 修改数据 /// </summary> /// <param name="Item">model</param> /// <returns></returns> public static bool Update(C_Infrared Item) { bool Flag = false; try { PublicFun.IniFile Ini = new PublicFun.IniFile(WSV.Model.FilePath.Config); if (Ini.ExistIniFile()) { Ini.IniWriteValue("Infrared", "Enable", Item.Enable); Ini.IniWriteValue("Infrared", "Infrared1", Item.Infrared1); Ini.IniWriteValue("Infrared", "Infrared2", Item.Infrared2); } Flag = true; } catch (Exception ex) { throw ex; } return Flag; }