protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Save")
        {
            return;
        }

        using (ISession session = new Session())
        {
            try
            {
                IList <INVCheckLine> lines = new List <INVCheckLine>();
                INVCheckHead         head  = INVCheckHead.Retrieve(session, this.OrderNumber);
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    TextBox text = item.FindControl("txtQty") as TextBox;
                    decimal qty  = Cast.Decimal(text.Text, 0M);
                    if (qty <= 0M)
                    {
                        continue;
                    }

                    HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                    lines.Add(head.NewLineAdj(session, Cast.Int(chk.Value), qty));
                }
                if (lines.Count <= 0)
                {
                    log.Debug("Save - sto adj line: no lines need to be saved");
                    return;
                }

                session.BeginTransaction();
                head.CreateOrUpdateLines(session, lines);
                session.Commit();

                log.DebugFormat("Save - sto adj line: {0} lines were created or updated", lines.Count);
                WebUtil.ShowMsg(this, "库存调整明细已经保存");
                this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
            }
            catch (Exception er)
            {
                log.Error("Save - to add sto adj line: ", er);
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }