protected void btn_Click(object sender, EventArgs e) { clsLabelsFactory fac = new clsLabelsFactory(); if (string.IsNullOrEmpty(hf.Value)) { List <clsLabels> lbl = fac.GetAllBy(clsLabels.clsLabelsFields.Title, txtLable.Text); if (lbl != null && lbl.Count > 0) { pnlSuccess.Visible = false; pnlError.Visible = true; } else { clsLabels label = new clsLabels(); label.Title = txtLable.Text; label.Data = ddlFirst.SelectedValue == "1" ? false : true; fac.Insert(label); pnlSuccess.Visible = true; lblSuccess.Text = "Label added successfully"; pnlError.Visible = false; } } else { clsLabelsKeys key = new clsLabelsKeys(Convert.ToInt32(hf.Value)); clsLabels label = fac.GetByPrimaryKey(key); label.Title = txtLable.Text; label.Data = ddlFirst.SelectedValue == "1" ? false : true; fac.Update(label); pnlSuccess.Visible = true; lblSuccess.Text = "Label updated successfully"; pnlError.Visible = false; } }
protected void Button1_Click(object sender, EventArgs e) { clsLabelsFactory fac = new clsLabelsFactory(); List <clsLabels> lbl = fac.GetAllBy(clsLabels.clsLabelsFields.Title, txtLable.Text); if (lbl != null && lbl.Count > 0) { pnlSuccess.Visible = false; pnlError.Visible = true; lblError.Text = "Label already exists"; } else { clsLabels label = new clsLabels(); label.Title = txtLable.Text; label.Data = ddlFirst.SelectedValue == "1" ? false : true; fac.Insert(label); pnlSuccess.Visible = true; lblSuccess.Text = "Label added successfully"; pnlError.Visible = false; } LoadData(); }