/// <summary> /// Probably better use method with parameter has type Partner /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Delete(PartnerSpecialization item) { bool result = false; using (StoredProcedure sp = new StoredProcedure("PartnerSpecialization_DeleteByPartner")) { sp.Params.Add("@PartnerID", System.Data.SqlDbType.Int).Value = item.PartnerID; result = sp.ExecuteNonQuery() > 0; } return result; }
public int Add(PartnerSpecialization item) { int newID = 0; using (StoredProcedure sp = new StoredProcedure("PartnerSpecialization_AddSpecialization")) { sp.Params.Add("@PartnerID", System.Data.SqlDbType.NChar).Value = item.PartnerID; sp.Params.Add("@SpecializationID", System.Data.SqlDbType.NVarChar).Value = item.SpecializationID; newID = Convert.ToInt32(sp.ExecuteScalar()); } return newID; }
public bool Update(PartnerSpecialization item) { bool result = false; using (StoredProcedure sp = new StoredProcedure("PartnerSpecializations_UpdateItem")) { //sp.Params.Add("@ID", System.Data.SqlDbType.Int).Value = item.ID; //sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode; //sp.Params.Add("@Name", System.Data.SqlDbType.NVarChar).Value = item.Name; //sp.Params.Add("@Description", System.Data.SqlDbType.NVarChar).Value = item.Description; result = sp.ExecuteNonQuery() > 0; } return result; }
private void Save() { foreach (RepeaterItem item in RepeaterLang.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { PartnerEditor editor = (PartnerEditor)item.FindControl("editor"); editor.CityID = Int32.Parse(ddlCity.SelectedValue); editor.RegionID = Int32.Parse(ddlRegion.SelectedValue); editor.PartnerStatus = Int32.Parse(ddlStatus.SelectedValue); editor.Telephone = txtTelephone.Text; editor.Url = txtUrl.Text; editor.SaveItem(); } } PartnerSpecializations ps = new PartnerSpecializations(); ps.Delete(this.GroupID); for (int i = 0; i < chbSpecialization.Items.Count; i++) { if(chbSpecialization.Items[i].Selected) { PartnerSpecialization p = new PartnerSpecialization(); p.PartnerID = this.GroupID; p.SpecializationID = Int32.Parse(chbSpecialization.Items[i].Value); ps.Add(p); } } GridViewItemsList.DataBind(); }