protected void btnAdd_Click(object sender, EventArgs e) { SeriesBiz pBiz = new SeriesBiz(); lwg_Series p; if (string.IsNullOrEmpty(hdfID.Value)) { p = new lwg_Series(); lblNote.Text = "Insert error, please try again"; } else { p = pBiz.GetByID(int.Parse(hdfID.Value)); lblNote.Text = "Update error, please try again"; } if (p != null) { p.Name = txtName.Text; if (pBiz.SaveSeries(p)) { rptSeries.DataSource = pBiz.GetListSeries(); rptSeries.DataBind(); txtName.Text = string.Empty; pnEditSeries.Visible = false; pnListSeries.Visible = true; return; } } lblNote.Visible = true; }
protected void rptSeries_ItemCommand(object source, RepeaterCommandEventArgs e) { SeriesBiz pBiz = new SeriesBiz(); lwg_Series p = pBiz.GetByID(int.Parse(e.CommandArgument.ToString())); if (e.CommandName.Equals("EDIT")) { if (p != null) { btnAdd.Text = "Update"; txtTitle.Text = "Update Series"; hdfID.Value = e.CommandArgument.ToString(); pnEditSeries.Visible = true; pnListSeries.Visible = false; txtName.Text = p.Name; } } else if (e.CommandName.Equals("DELETE")) { if (p != null) { if (pBiz.DeleteSeries(p)) { BindingSeries(); } } } }