Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            PendingReceipt tempObj = obj as PendingReceipt;

            if (tempObj == null)
            {
                return(false);
            }
            return(this._sKU_ID == tempObj._sKU_ID);
        }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        using (ISession session = new Session())
        {
            try
            {
                session.BeginTransaction();
                foreach (RepeaterItem item in this.rptPO.Items)
                {
                    HiddenField hidsku = item.FindControl("hidsku") as HiddenField;
                    TextBox text = item.FindControl("txtQty") as TextBox;
                    int skuId = Cast.Int(hidsku.Value);
                    decimal qty = Cast.Decimal(text.Text);
                    if (skuId <= 0) continue;

                    PendingReceipt pr = PendingReceipt.Retrieve(session, skuId);
                    if (pr == null)
                    {
                        if (qty <= 0M) continue;
                        pr = new PendingReceipt() { SKU_ID = skuId };
                        pr.Qty = qty;
                        pr.Create(session);
                    }
                    else
                    {
                        pr.Qty = qty;
                        pr.Update(session);
                    }
                }

                session.Commit();
                WebUtil.ShowMsg(this, "保存成功");
            }
            catch (Exception er)
            {
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }