public Viwer(int id) { InitializeComponent(); db = Model.DatabaseConfigure.getConfigure(); using (var db = Model.DatabaseConfigure.getConfigure()) { this.Counter = db.counters.Find(id); label_counter.Text = this.Counter.name; } nepaliCalender.Datestamp = INFO.currentdate; if (this.Counter.counterstatus == 1) { pictureBox.Image = Properties.Resources.Rms_connection_on; } else { pictureBox.Image = Properties.Resources.Rms_Connection_off; } refreshdailydata(); this.id = id; }
private void materialButton_addnew_Click(object sender, EventArgs e) { if (betterTextBox_counterno.Text.Trim() == "") { INFO.ShowAlert(Text, "Please Enter Counter No", 3000); betterTextBox_counterno.Focus(); return; } try { using (var db = Model.DatabaseConfigure.getConfigure()) { var counter = new Model.counter() { name = betterTextBox_counterno.Text, counterstatus = -1, created_at = DateTime.Now, updated_at = DateTime.Now, admin_id = INFO.admin_id }; db.counters.Add(counter); db.SaveChanges(); add?.Invoke(counter); } this.Close(); } catch (Exception) { CustomControls.Alert.show("Error", "this data is not saved ", 1500); } }
public Edit(int id) { InitializeComponent(); db = Model.DatabaseConfigure.getConfigure(); this.Counter = db.counters.Find(id); }