protected void btnAdd_Click(object sender, EventArgs e) { ReprintSourceBiz pBiz = new ReprintSourceBiz(); lwg_ReprintSource p; if (string.IsNullOrEmpty(hdfID.Value)) { p = new lwg_ReprintSource(); 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.SaveReprintSource(p)) { BindingReprintSource(); txtName.Text = string.Empty; pnEditReprintSource.Visible = false; pnListReprintSource.Visible = true; return; } } lblNote.Visible = true; }
protected void rptReprintSource_ItemCommand(object source, RepeaterCommandEventArgs e) { ReprintSourceBiz pBiz = new ReprintSourceBiz(); lwg_ReprintSource p = pBiz.GetByID(int.Parse(e.CommandArgument.ToString())); if (e.CommandName.Equals("EDIT")) { if (p != null) { btnAdd.Text = "Update"; txtTitle.Text = "Update Reprint Source"; hdfID.Value = e.CommandArgument.ToString(); pnEditReprintSource.Visible = true; pnListReprintSource.Visible = false; txtName.Text = p.Name; } } else if (e.CommandName.Equals("DELETE")) { if (p != null) { if (pBiz.DeleteReprintSource(p)) { BindingReprintSource(); } } } }