コード例 #1
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         bool deleted = false;
         using (ISession session = new Session())
         {
             session.BeginTransaction();
             try
             {
                 foreach (RepeaterItem item in this.rptVendor.Items)
                 {
                     HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                     if (chk != null && chk.Checked)
                     {
                         int mid = Cast.Int(chk.Attributes["mid"]), lid = Cast.Int(chk.Attributes["lid"]);
                         deleted = deleted || RestrictLogis2Member.Delete(session, lid, mid) > 0;
                     }
                 }
                 session.Commit();
                 if (deleted)
                 {
                     QueryAndBindData(session, magicPagerMain.CurrentPageIndex, magicPagerMain.PageSize, true);
                 }
             }
             catch (Exception ex)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, ex);
             }
         }
     }
 }
コード例 #2
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Add")
        {
            int logisId = Cast.Int(this.drpLogis.SelectedValue, 0);
            if (logisId <= 0)
            {
                WebUtil.ShowMsg(this, "请选择物流公司");
                return;
            }
            bool added = false;
            using (ISession session = new Session())
            {
                session.BeginTransaction();
                try
                {
                    foreach (RepeaterItem item in this.rptVendor.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk != null && chk.Checked)
                        {
                            RestrictLogis2Member r = new RestrictLogis2Member();
                            r.LogisId  = logisId;
                            r.MemberId = Cast.Int(chk.Value);
                            r.Create(session);
                            added = true;
                        }
                    }
                    session.Commit();
                }
                catch (Exception ex)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, ex);
                }

                if (added)
                {
                    this.Response.Redirect(Request["return"]);
                }
            }
        }
    }