public static void Save(ReminderMaster reminder) { ReminderMaster lreminder = null; if (reminder.ReminderID == 0) { lreminder = new ReminderMaster(); DbContextHelper.DbContext.Add(lreminder); } else { lreminder = Get(reminder.ReminderID); } lreminder.Description = reminder.Description; lreminder.Duration = reminder.Duration; lreminder.DurationType = reminder.DurationType; lreminder.clientID = reminder.clientID; lreminder.isActive = reminder.isActive; DbContextHelper.DbContext.SaveChanges(); }
protected void gvReminder_RowCommand(object sender, GridViewCommandEventArgs e) { int reminderID = 0; if (e.CommandName == "DoEdit") { hf_reminderID.Value = e.CommandArgument.ToString(); reminderID = Convert.ToInt32(e.CommandArgument.ToString()); ReminderMaster reminder = ReminderMasterManager.Get(reminderID); txtDescription.Text = reminder.Description; txtDuration.Text = reminder.Duration.ToString(); ddlType.SelectedValue = reminder.DurationType.ToString(); pnlEdit.Visible = true; pnlList.Visible = false; } if (e.CommandName == "DoDelete") { hf_reminderID.Value = e.CommandArgument.ToString(); reminderID = Convert.ToInt32(e.CommandArgument.ToString()); ReminderMaster reminder = ReminderMasterManager.Get(reminderID); if (reminder != null) { reminder.isActive = false; ReminderMasterManager.Save(reminder); } } bindList(); }
protected void btnSave_click(object sender, EventArgs e) { ReminderMaster reminder = null; Page.Validate("reminder"); if (!Page.IsValid) return; reminder = new ReminderMaster(); reminder.ReminderID = Convert.ToInt32(hf_reminderID.Value); reminder.Description = txtDescription.Text; reminder.DurationType = Convert.ToInt32(ddlType.SelectedValue); reminder.Duration = Convert.ToInt32(txtDuration.Text); reminder.isActive = true; if (SessionHelper.getClientId() > 0) reminder.clientID = SessionHelper.getClientId(); ReminderMasterManager.Save(reminder); clearFields(); pnlList.Visible = true; pnlEdit.Visible = false; bindList(); }