Exemplo n.º 1
0
    protected void cmdAddLines_Click(object sender, EventArgs e)
    {
        string[] linesArray = this.txtSkus.Value.Trim().Trim(';').Split(';');
        if (linesArray == null || linesArray.Length <= 0)
        {
            return;
        }

        using (ISession session = new Session())
        {
            ICHead head = ICHead.Retrieve(session, this.OrderNumber);
            if (head == null)
            {
                return;
            }
            try
            {
                session.BeginTransaction();
                head.AddLines(session, linesArray);
                session.Commit();
                this.QueryAndBindData(session, head);
            }
            catch (Exception er)
            {
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value     = WebUtil.Param("ordNumber");

            ICHead head = null;
            using (ISession session = new Session())
            {
                IList <Logistics> companies = session.CreateEntityQuery <Logistics>()
                                              .Where(Magic.Framework.ORM.Query.Exp.Eq("Status", LogisticsStatus.Enable))
                                              .OrderBy("ShortName")
                                              .List <Logistics>();
                this.drpLogistic.Items.Clear();
                foreach (Logistics lg in companies)
                {
                    this.drpLogistic.Items.Add(new ListItem(lg.ShortName, lg.LogisticCompID.ToString()));
                }

                if (!this.IsNew)
                {
                    head = ICHead.Retrieve(session, this.OrderNumber);
                    this.showInfo(session, head);
                }
            }
            this.setView(head);
        }
    }
Exemplo n.º 3
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, "保存成功");
            }
        }
    }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.txtReturnUrl.Value               = WebUtil.Param("return");
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             ICHead head = ICHead.Retrieve(session, this.OrderNumber);
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
     else
     {
         this.frameDownload.Attributes["src"] = "about:blank;";
     }
 }
Exemplo n.º 5
0
        internal static IApprovable GetApproveItem(ISession session, string orderType, string orderNumber)
        {
            switch (orderType)
            {
            case POHead.ORDER_TYPE:     //采购订单
                return(POHead.Retrieve(session, orderNumber));

            case RCVHead.ORD_TYPE_PUR:           //采购收货
                return(RCVHead.Retrieve(session, orderNumber));

            case POReturnHead.ORD_TYPE_CODE:     //采购退货
                return(POReturnHead.Retrieve(session, orderNumber));

            case ICHead.ORDER_TYPE:     //交接单
                return(ICHead.Retrieve(session, orderNumber));

            case INVCheckHead.ORDER_TYPE_ADJ:     //库存调整单
            case INVCheckHead.ORDER_TYPE_CHK:     //库房盘点
                return(INVCheckHead.Retrieve(session, orderNumber));

            case StockInHead.ORD_TYPE_ASSIST_IN:         //辅料入库
            case StockInHead.ORD_TYPE_ASSIST_OUT:        //辅料领用
            case StockInHead.ORD_TYPE_PRD_IN:            //产品入库
            case StockInHead.ORD_TYPE_PRD_OUT:           //产品领用
                return(StockInHead.Retrieve(session, orderNumber));

            case ReturnHead.ORDER_TYPE_MBR_RTN:       //会员退货
            case ReturnHead.ORDER_TYPE_LOGISTICS_RTN: //物流退货
            case ReturnHead.ORDER_TYPE_INNER_RTN:     //内部退货
            case ReturnHead.ORDER_TYPE_EXCHANGE_RTN:  //会员换货
                return(ReturnHead.Retrieve(session, orderNumber));

            case WHTransferHead.ORDER_TYPE_NORMAL:     //移库单
                return(WHTransferHead.Retrieve(session, orderNumber));
            }
            throw new Exception(string.Format("Order type {0} is not a registered approvable item", orderType));
        }
Exemplo n.º 6
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            #region  除
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk.Checked)
                        {
                            ICLine line = ICLine.Retrieve(session, this.OrderNumber, chk.Value.Trim());
                            if (line != null)
                            {
                                line.Delete(session);
                            }
                        }
                    }
                    session.Commit();
                    this.QueryAndBindData(session, null);
                    WebUtil.ShowMsg(this, "选择的明细已经删除");
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Release")
        {
            #region 发布
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                    head.Release(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "发布成功");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Close")
        {
            #region 关闭
            using (ISession session = new Session())
            {
                try
                {
                    ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.Close(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "交接单" + head.OrderNumber + "已经完成");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Download")
        {
            #region  载
            DataSet ds = null;
            IDictionary <string, string> dic = new Dictionary <string, string>();
            #region 初始化dic
            dic["$LogisName$"]    = "";
            dic["$LogisAddress$"] = "";
            dic["$LogisContact$"] = "";
            dic["$LogisPhone$"]   = "";
            dic["$LogisZipCode$"] = "";
            dic["$LogisFax$"]     = "";
            dic["$ICNumber$"]     = "";
            dic["$ICUser$"]       = "";
            dic["$AgentAmt$"]     = "";
            dic["$Note$"]         = "";
            dic["$Status$"]       = "";
            dic["$ICTime$"]       = "";
            dic["$ICBoxCount$"]   = "";
            #endregion
            IList <DownloadFormat> format = new List <DownloadFormat>()
            {
                new DownloadFormat(DataType.NumberText, "", "OrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "ShippingNumber"),
                new DownloadFormat(DataType.NumberText, "", "SaleOrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "InvoiceNumber"),
                new DownloadFormat(DataType.Number, "", "PackageWeight"),
                new DownloadFormat(DataType.Number, "", "PackageCount"),
                new DownloadFormat(DataType.Text, "", "Contact"),
                new DownloadFormat(DataType.Text, "", "Province", "City"), //省市2区县待完善
                new DownloadFormat(DataType.NumberText, "", "PostCode"),
                new DownloadFormat(DataType.Text, "", "Address"),
                new DownloadFormat(DataType.NumberText, "", "Phone"),
                new DownloadFormat(DataType.NumberText, "", "Mobile"),
                new DownloadFormat(DataType.Number, "", "AgentAmt"),
                new DownloadFormat(DataType.Text, "", "Remark")
            };
            using (ISession session = new Session())
            {
                ds = session.CreateObjectQuery(@"
SELECT 
    A.OrderNumber AS OrderNumber,A.ShippingNumber as ShippingNumber,A.SaleOrderNumber AS SaleOrderNumber
    ,A.InvoiceNumber as InvoiceNumber,A.PackageWeight as PackageWeight,A.PackageCount as PackageCount
    ,A.Contact as Contact,A.Province as Province,A.City as City,A.Address as Address,A.Mobile as Mobile,A.Phone as Phone
    ,A.AgentAmt as AgentAmt,A.Remark as Remark,A.PostCode as PostCode
FROM ICLine L
inner JOIN CRMSN A ON L.RefOrderNumber=A.OrderNumber
LEFT JOIN Member E ON A.MemberID= E.MemberID
order by L.LineNumber")
                     .Attach(typeof(Magic.ERP.Orders.ICLine))
                     .Attach(typeof(Magic.ERP.Orders.CRMSN))
                     .Attach(typeof(Magic.Basis.Member))
                     .And(Magic.Framework.ORM.Query.Exp.Eq("L.OrderNumber", this.OrderNumber))
                     .DataSet();

                decimal totalAmt = 0M;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    totalAmt += Cast.Decimal("AgentAmt");
                }

                ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                if (head == null)
                {
                    WebUtil.ShowError(this, "交接单" + this.OrderNumber + "不存在");
                    return;
                }
                dic["$ICNumber$"]   = "'" + head.OrderNumber;
                dic["$AgentAmt$"]   = totalAmt.ToString("#0.#0");
                dic["$Note$"]       = "'" + head.Note;
                dic["$Status$"]     = ERPUtil.StatusText(session, CRMSN.ORDER_TYPE_CODE_SD, head.Status);
                dic["$ICTime$"]     = "'" + head.CreateTime.ToString("yyyy-MM-dd");
                dic["$ICBoxCount$"] = "'" + head.TotalPackageCount(session).ToString();
                Logistics logis = Logistics.Retrieve(session, head.LogisticCompID);
                if (logis != null)
                {
                    dic["$LogisName$"]    = logis.ShortName;
                    dic["$LogisAddress$"] = logis.Address;
                    dic["$LogisContact$"] = logis.Contact;
                    dic["$LogisPhone$"]   = "'" + logis.Phone;
                    dic["$LogisZipCode$"] = "'" + logis.ZipCode;
                    dic["$LogisFax$"]     = "'" + logis.Fax;
                }
                if (head.CreateUser > 0)
                {
                    Magic.Sys.User user = Magic.Sys.User.Retrieve(session, head.CreateUser);
                    if (user != null)
                    {
                        dic["$ICUser$"] = user.FullName;
                    }
                }
            }
            if (ds == null)
            {
                WebUtil.ShowError(this, "没有数据下载或者下载出错了");
                return;
            }

            string fileName = DownloadUtil.DownloadXls("IC_" + this.OrderNumber + ".xls", "IC", Server.MapPath("/Template/IC_Download.xls"), dic, 7, format, ds);
            this.frameDownload.Attributes["src"] = fileName;
            #endregion
        }
    }