/// 修改是否使用的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbUse_Click(object sender, EventArgs e) { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.gvPrice.DataKeys[index].Value.ToString()); // Song.Entities.CoursePrice entity = Business.Do <ICourse>().PriceSingle(id); entity.CP_IsUse = !entity.CP_IsUse; Business.Do <ICourse>().PriceSave(entity); BindPriceData(); }
/// <summary> /// 编辑当前数据项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEditEnter_Click(object sender, EventArgs e) { try { System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender; int index = ((GridViewRow)(btn.Parent.Parent)).RowIndex; int id = int.Parse(this.gvPrice.DataKeys[index].Value.ToString()); // Song.Entities.CoursePrice col = Business.Do <ICourse>().PriceSingle(id); if (col != null) { //区间 TextBox tb = (TextBox)gvPrice.Rows[index].FindControl("tbSpan"); int span; int.TryParse(tb.Text, out span); col.CP_Span = span; //单位 DropDownList ddlUnit = (DropDownList)gvPrice.Rows[index].FindControl("ddlUnit"); col.CP_Unit = ddlUnit.SelectedItem.Text; //价格 TextBox tbprice = (TextBox)gvPrice.Rows[index].FindControl("tbPrice"); int price; int.TryParse(tbprice.Text, out price); col.CP_Price = price; //卡券 int coupon = 0; TextBox tbcoupon = (TextBox)gvPrice.Rows[index].FindControl("tbCoupon"); int.TryParse(tbcoupon.Text, out coupon); col.CP_Coupon = coupon; //是否可用 CheckBox cb = (CheckBox)gvPrice.Rows[index].FindControl("cbIsUse"); col.CP_IsUse = cb.Checked; // Business.Do <ICourse>().PriceSave(col); } gvPrice.EditIndex = -1; BindPriceData(); } catch (Exception ex) { Alert(ex.Message); } }