Exemplo n.º 1
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                POReturnHead head = null;
                if (this.IsNew)
                {
                    head = new POReturnHead();
                    head.Status = POReturnStatus.New;
                    head.ApproveResult = ApproveStatus.UnApprove;
                    head.ApproveUser = 0;
                    head.ApproveTime = new DateTime(1900, 1, 1);
                    head.CreateUser = SecuritySession.CurrentUser.UserId;
                    head.CreateTime = DateTime.Now;
                    head.Note = this.txtNote.Text.Trim();
                    head.LocationCode = this.drpLocation.SelectedValue;
                    head.VendorID = Cast.Int(this.drpVendor.SelectedValue);
                    try
                    {
                        session.BeginTransaction();
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        head.Create(session);
                        session.Commit();
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                        return;
                    }

                    this.Response.Redirect("POReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                    return;
                }

                head = POReturnHead.Retrieve(session, this.OrderNumber);
                try
                {
                    session.BeginTransaction();
                    head.Update(session, Cast.Int(this.drpVendor.SelectedValue), this.drpLocation.SelectedValue, this.txtNote.Text.Trim());
                    session.Commit();
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                    return;
                }
                this.Response.Redirect("POReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
            }
        }
    }
Exemplo n.º 2
0
 private void SetView(POReturnHead head)
 {
     switch (head.Status)
     {
         case POReturnStatus.New:
             this.cmdEdit1.Visible = true;
             this.cmdEdit2.Visible = true;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             break;
         case POReturnStatus.Release:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             break;
         case POReturnStatus.Open:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = true;
             this.cmdClose2.Visible = true;
             break;
         case POReturnStatus.Close:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             break;
     }
 }
Exemplo n.º 3
0
 private void QueryAndBindData(ISession session, POReturnHead head)
 {
     this.repeatControl.DataSource = session.CreateObjectQuery(@"
     select l.LineNumber as LineNumber,l.PONumber as PONumber,l.POLine as POLine
     ,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName
     ,s.ColorCode as ColorCode,s.SizeCode as SizeCode,color.ColorText as ColorText
     ,sto.AreaCode as AreaCode,sto.SectionCode as SectionCode,l.Quantity as Qty
     from POReturnLine l
     inner join ItemSpec s on l.SKUID=s.SKUID
     inner join ItemMaster m on m.ItemID=s.ItemID
     inner join StockDetail sto on sto.StockDetailID=l.StockDetailID
     left join ItemColor color on color.ColorCode=s.ColorCode
     where l.OrderNumber=?ordNum
     order by l.LineNumber")
         .Attach(typeof(POReturnLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
         .Attach(typeof(StockDetail))
         .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber")
         .DataSet();
     this._head = head;
     this.repeatControl.DataBind();
 }
Exemplo n.º 4
0
 private void showInfo(ISession session, POReturnHead head)
 {
     User user;
     if (head != null)
     {
         this.txtOrderNumber.Text = head.OrderNumber;
         this.txtNote.Text = head.Note;
         this.drpLocation.SelectedValue = head.LocationCode;
         this.drpVendor.SelectedValue = head.VendorID.ToString();
         OrderStatusDef statusDef = OrderStatusDef.Retrieve(session, head.OrderTypeCode, (int)head.Status);
         if (statusDef != null) this.lblStatus.Text = statusDef.StatusText;
         if (head.CreateUser > 0)
         {
             user = Magic.Sys.User.Retrieve(session, head.CreateUser);
             if (user != null) this.lblUser.Text = user.FullName;
         }
         this.lblCreateTime.Text = RenderUtil.FormatDatetime(head.CreateTime);
         this.lblApproveResult.Text = ERPUtil.EnumText<ApproveStatus>(head.ApproveResult);
         switch (head.ApproveResult)
         {
             case ApproveStatus.Reject: this.lblApproveResult.ForeColor = System.Drawing.Color.Red; break;
             case ApproveStatus.Approve: this.lblApproveResult.ForeColor = System.Drawing.Color.Blue; break;
         }
         if (head.ApproveResult == ApproveStatus.Approve || head.ApproveResult == ApproveStatus.Reject)
         {
             if (head.ApproveUser > 0)
             {
                 user = Magic.Sys.User.Retrieve(session, head.ApproveUser);
                 if (user != null) this.lblApproveUser.Text = user.FullName;
             }
             this.lblApproveTime.Text = RenderUtil.FormatDatetime(head.ApproveTime);
         }
         this.txtApproveNote.Text = head.ApproveNote;
     }
 }
Exemplo n.º 5
0
 private void setView(POReturnHead head)
 {
     if (head != null && head.Status != POReturnStatus.New)
     {
         WebUtil.DisableControl(this.txtNote);
         WebUtil.DisableControl(this.drpLocation);
         WebUtil.DisableControl(this.drpVendor);
         this.cmdEdit.Visible = false;
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }