Пример #1
0
 private void btChinhDiaChiWeb_Click(object sender, EventArgs e)
 {
     Setting st = SettingController.get_by_key("path_to_website");
     InputDialog ip = new InputDialog("Địa chỉ trang Web", "Giá trị: ", (st != null) ? st.value : "http://localhost:12430");
     if (ip.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         if(st == null)
         {
             // new
             Setting _st = new Setting{ key = "path_to_website", value = ip.GiaTri};
             if(SCtr.add(_st) > 0) MessageBox.Show("Chỉnh thành công.");
             else MessageBox.Show("Chỉnh thất bại.");
         }
         else
         {
             //modify
             Setting _st = SCtr.get_by_id(st.id);
             _st.value = ip.GiaTri;
             SCtr.save();
             MessageBox.Show("Chỉnh thành công.");
         }
     }
 }
Пример #2
0
 public int add(Setting st)
 {
     _db.ds_setting.Add(st);
     save();
     return _db.ds_setting.Max(x => x.id);
 }