Ejemplo n.º 1
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                ICHead head = null;
                bool created = false;
                if (this.IsNew)
                {
                    head = new ICHead();
                    head.OrderTypeCode = ICHead.ORDER_TYPE;
                    head.Status = InterchangeStatus.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.CompanyUser = head.CreateUser;
                    head.InterchangeTime = DateTime.Now;
                    head.LogisticUser = this.txtLogisticsUser.Text.Trim();
                    head.Note = this.txtNote.Text.Trim();
                    head.LogisticCompID = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue);
                    try
                    {
                        session.BeginTransaction();
                        head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode);
                        head.Create(session);
                        head.AutoGenerateDetail(session);
                        session.Commit();
                        created = true;
                        //this.txtAction.Value = "edit";
                        //this.txtId.Value = head.OrderNumber;
                        //this.showInfo(session, head);
                        //this.setView(head);
                        //WebUtil.ShowMsg(this, string.Format("交接单{0}创建成功", head.OrderNumber));
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }
                }
                if (created)
                {
                    this.Response.Redirect("InterchangeLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                }

                head = ICHead.Retrieve(session, this.OrderNumber);
                head.Note = this.txtNote.Text.Trim();
                head.LogisticCompID = Magic.Framework.Utils.Cast.Int(this.drpLogistic.SelectedValue);
                head.LogisticUser = this.txtLogisticsUser.Text.Trim();
                head.Update(session, "Note", "LogisticCompID", "LogisticUser", "BoxNum");
                WebUtil.ShowMsg(this, "保存成功");
            }
        }
    }
Ejemplo n.º 2
0
        public static bool Delete(ISession session, string orderNumber)
        {
            ICHead head = ICHead.Retrieve(session, orderNumber);

            if (head == null)
            {
                return(false);
            }
            return(head.Delete(session));
        }
Ejemplo n.º 3
0
        public static ICHead Query(ISession session, string snNumber)
        {
            IList <ICLine> lines = session.CreateEntityQuery <ICLine>()
                                   .Where(Exp.Eq("RefOrderNumber", snNumber))
                                   .List <ICLine>();

            if (lines == null || lines.Count <= 0)
            {
                return(null);
            }
            return(ICHead.Retrieve(session, lines[0].OrderNumber));
        }
Ejemplo n.º 4
0
        public static SimpleJson AddLine(ISession session, string icNumber, string snNumber)
        {
            if (string.IsNullOrEmpty(icNumber) || string.IsNullOrEmpty(snNumber))
            {
                throw new Exception("无效参数");
            }
            ICHead head = ICHead.Retrieve(session, icNumber);

            if (head == null)
            {
                throw new Exception("交接单" + icNumber + "不存在");
            }
            CRMSN sn = CRMSN.Retrieve(session, snNumber);

            if (sn == null)
            {
                throw new Exception("发货单" + snNumber + "不存在");
            }
            head.AddLine(session, sn);
            return(sn.ToJSon(session));
        }
Ejemplo n.º 5
0
 private void SetView(ICHead head)
 {
     switch (head.Status)
     {
         case InterchangeStatus.New:
             this.cmdEdit1.Visible = true;
             this.cmdEdit2.Visible = true;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             this.cmdPrint1.Visible = false;
             this.cmdPrint2.Visible = false;
             break;
         case InterchangeStatus.Release:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             this.cmdPrint1.Visible = true;
             this.cmdPrint2.Visible = true;
             break;
         case InterchangeStatus.Open:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = true;
             this.cmdClose2.Visible = true;
             this.cmdPrint1.Visible = true;
             this.cmdPrint2.Visible = true;
             break;
         case InterchangeStatus.Close:
             this.cmdEdit1.Visible = false;
             this.cmdEdit2.Visible = false;
             this.cmdClose1.Visible = false;
             this.cmdClose2.Visible = false;
             this.cmdPrint1.Visible = true;
             this.cmdPrint2.Visible = true;
             break;
     }
 }
Ejemplo n.º 6
0
 private void QueryAndBindData(ISession session, ICHead head)
 {
     this.repeatControl.DataSource = session.CreateObjectQuery(@"
     select il.LineNumber as LineNumber,il.OrderNumber as OrderNumber,sn.OrderNumber as SNNumber,sn.SaleOrderNumber as SONumber,sn.ShippingNumber as ShippingNumber
     ,m.Name as Name,sn.Contact as Contact,sn.Phone as Phone,sn.Address as Address,sn.Province as Province,sn.City as City
     from ICLine il
     inner join CRMSN sn on il.RefOrderNumber=sn.OrderNumber
     left join Member m on m.MemberID=sn.MemberID
     where il.OrderNumber=?ordNum
     order by il.LineNumber")
         .Attach(typeof(ICLine)).Attach(typeof(CRMSN)).Attach(typeof(Member))
         .SetValue("?ordNum", this.OrderNumber, "il.OrderNumber")
         .DataSet();
     this._head = head;
     this.repeatControl.DataBind();
     this._head = null;
 }
Ejemplo n.º 7
0
 private void showInfo(ISession session, ICHead head)
 {
     User user;
     if (head != null)
     {
         this.txtOrderNumber.Text = head.OrderNumber;
         this.txtNote.Text = head.Note;
         this.drpLogistic.SelectedValue = head.LogisticCompID.ToString();
         this.txtLogisticsUser.Text = head.LogisticUser;
         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;
     }
 }
Ejemplo n.º 8
0
 private void setView(ICHead head)
 {
     if (this.IsNew)
     {
         this.cmdDetail.Visible = false;
         this.cmdScanLine.Visible = false;
     }
     else
     {
         if (head != null && head.Status != InterchangeStatus.New)
         {
             WebUtil.DisableControl(this.txtNote);
             WebUtil.DisableControl(this.drpLogistic);
             WebUtil.DisableControl(this.txtLogisticsUser);
             this.cmdEdit.Visible = false;
             this.cmdScanLine.Visible = false;
         }
         else if (head != null)
         {
             this.cmdScanLine.Visible = true;
             this.cmdScanLine["ScanLine"].NavigateUrl = "InterchangeLineScan.aspx?ordNumber=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
         }
         this.cmdDetail.Visible = true;
         this.cmdDetail["Detail"].NavigateUrl = "InterchangeLine.aspx?ordNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
     }
     this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;
 }