protected void btnMustSubmit_Click(object sender, EventArgs e) { try { if (ViewState["MustPropsCounter"] != null && tvCats.SelectedNode != null) { using (CatalogDataContext dct = new CatalogDataContext()) { var mCat = from mapping in dct.Mapping_Categories where mapping.tb_cid == long.Parse(tvCats.SelectedValue) && mapping.ss_cat_id == ddlSSCats.SelectedValue select mapping; if (mCat.Single() != null) { int counter = int.Parse(ViewState["MustPropsCounter"].ToString()); for (int i = 0; i < counter; i++) { Label lbl = (Label)this.Master.FindControl("MainContent").FindControl("lblMust" + i); DropDownList ddl = (DropDownList)this.Master.FindControl("MainContent").FindControl("ddlMust" + i); var prop = (from pv in dct.TB_ItemProps where pv.Cid == long.Parse(tvCats.SelectedValue) && pv.Name == lbl.Text select pv).Single(); Mapping_Categories_Prop mMust = new Mapping_Categories_Prop() { id = System.Guid.NewGuid(), mapping_categories_id = mCat.Single().id, pid = prop.Pid, vid = long.Parse(ddl.SelectedValue) }; dct.Mapping_Categories_Props.InsertOnSubmit(mMust); dct.SubmitChanges(); } } else throw new ArgumentException("还未匹配ss分类,淘宝分类为空"); } } } catch (Exception ex) { string message = ex.Message.Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + message + "')", true); } }
partial void InsertMapping_Categories_Prop(Mapping_Categories_Prop instance);
partial void DeleteMapping_Categories_Prop(Mapping_Categories_Prop instance);
private void detach_Mapping_Categories_Props(Mapping_Categories_Prop entity) { this.SendPropertyChanging(); entity.Mapping_Category = null; }