protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { if (this.ViewState["Mode"] == null) // Add mode { SupplySystem.Level level = new SupplySystem.Level { LevelID = Public.ToShort(this.txtCode.Text), LevelName = this.txtLevelName.Text }; level.SubLevels.Add(new SupplySystem.SubLevel { SubLevelName = "Employees" }); db.Levels.InsertOnSubmit(level); } else if (this.ViewState["Mode"].ToString() == "edit") // Edit mode { db.Levels.First<SupplySystem.Level>(sk => sk.LevelID == Public.ToShort(this.txtCode.Text)).LevelName = this.txtLevelName.Text; } db.SubmitChanges(); this.grdLevels.DataSource = db.Levels.ToList<SupplySystem.Level>(); this.grdLevels.DataBind(); this.lblMessage.Text = Public.SUCCESSMESSAGE; ClearControls(); } }
partial void DeleteLevel(Level instance);
partial void UpdateLevel(Level instance);
partial void InsertLevel(Level instance);