Пример #1
0
 void Initialize()
 {
     if (Request.QueryString["Id"] != null && !string.IsNullOrEmpty(Request.QueryString["Id"].ToString()))
     {
         Update = true;
         Id     = StringHelper.TryParse(StringHelper.Decrypt(Request.QueryString["Id"].ToString()));
         DataSource.MeterNoteCategory cat = SourceConnection.MeterNoteCategories.Where(x => x.Id.Equals(Id)).FirstOrDefault();
         FillDataForUpdate(cat);
     }
 }
Пример #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Id = (Update) ? StringHelper.TryParse(StringHelper.Decrypt(Request.QueryString["Id"].ToString())) : 0;
            DataSource.MeterNoteCategory data = (!Update) ? new DataSource.MeterNoteCategory() : SourceConnection.MeterNoteCategories.Where(x => x.Id.Equals(Id)).First();
            data.Description = txtDescription.Text;
            data.Category    = txtCategory.Text;

            if (!Update)
            {
                SourceConnection.MeterNoteCategories.AddObject(data);
            }

            SourceConnection.SaveChanges();
            Response.Redirect("DataView.aspx");
        }
Пример #3
0
 void FillDataForUpdate(DataSource.MeterNoteCategory data)
 {
     txtCategory.Text    = data.Category;
     txtDescription.Text = data.Description;
 }