Пример #1
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         this.SetView(SavePOHead());
     }
     else if (e.CommandName == "Paid")
     {
         try
         {
             using (ISession session = new Session())
             {
                 POHead po = POHead.Retrieve(session, this.OrderNumber);
                 po.HasPaid = true;
                 po.Update(session, "HasPaid");
                 this.cmdPaid.Visible = false;
                 this.lblPaid.Text    = "是";
                 WebUtil.ShowMsg(this, "已付款操作成功");
             }
         }
         catch (Exception er)
         {
             WebUtil.ShowError(this, "操作失败:" + er.Message);
         }
     }
 }
Пример #2
0
    void RetrievePOHeadData(POHead po, string poNumber)
    {
        string orderNumber = poNumber;

        if (!string.IsNullOrEmpty(orderNumber))
        {
            if (po != null)
            {
                this.txtOrderNumber.Text             = po.OrderNumber;
                this.drpPurchGroupCode.SelectedValue = po.PurchGroupCode;
                this.drpLocationCode.SelectedValue   = po.LocationCode;
                this.drpVendorID.SelectedValue       = po.VendorID.ToString();
                this.txtShippingAddress.Text         = po.ShippingAddress;
                this.txtNote.Text       = po.Note;
                this.hidStatus.Value    = po.Status.ToString();
                this.txtDemandDate.Text = po.DefaultPlanDate.ToString("yyyy-MM-dd");
                this.lblPaid.Text       = po.HasPaid ? "是" : "否";
                if (po.Status != POStatus.New)
                {
                    WebUtil.DisableControl(this.drpPurchGroupCode);
                    WebUtil.DisableControl(this.drpLocationCode);
                    WebUtil.DisableControl(this.drpVendorID);
                    WebUtil.DisableControl(this.txtShippingAddress);
                    WebUtil.DisableControl(this.txtNote);
                    WebUtil.DisableControl(this.txtDemandDate);
                    this.cmdSave.Visible = false;
                }
            }
        }
    }
Пример #3
0
 public POHead SavePOHead()
 {
     using (ISession session = new Session())
     {
         try
         {
             POHead poHead = null;
             if (this.IsNew)
             {
                 //新增
                 poHead                   = new POHead();
                 poHead.OrderNumber       = ERPUtil.NextOrderNumber(POHead.ORDER_TYPE);
                 this.txtOrderNumber.Text = poHead.OrderNumber;
                 poHead.CompanyID         = -1;
                 poHead.LocationCode      = this.drpLocationCode.SelectedValue;
                 poHead.PurchGroupCode    = this.drpPurchGroupCode.SelectedValue;
                 poHead.VendorID          = Cast.Int(this.drpVendorID.SelectedValue, 0);
                 poHead.Status            = POStatus.New;
                 poHead.TaxAmt            = 0M;
                 poHead.TaxExclusiveAmt   = 0M;
                 poHead.TaxInclusiveAmt   = 0M;
                 poHead.ShippingAddress   = this.txtShippingAddress.Text.Trim();
                 poHead.CreateUser        = Magic.Security.SecuritySession.CurrentUser.UserId;
                 poHead.CreateTime        = DateTime.Now;
                 poHead.ApproveResult     = ApproveStatus.UnApprove;
                 poHead.ApproveTime       = new DateTime(1900, 1, 1);
                 poHead.ApproveUser       = 0;
                 poHead.ApproveNote       = " ";
                 poHead.CurrentLineNumber = "0000";
                 poHead.Note              = this.txtNote.Text.Trim();
                 poHead.DefaultPlanDate   = Cast.DateTime(this.txtDemandDate.Text, DateTime.Now);
                 poHead.Create(session);
                 WebUtil.ShowMsg(this, "采购订单保存成功", "操作成功");
                 return(poHead);
             }
             else
             {
                 //编辑
                 poHead = POHead.Retrieve(session, this.txtOrderNumber.Text.Trim());
                 poHead.LocationCode    = this.drpLocationCode.SelectedValue;
                 poHead.PurchGroupCode  = this.drpPurchGroupCode.SelectedValue;
                 poHead.VendorID        = Cast.Int(this.drpVendorID.SelectedValue, 0);
                 poHead.ShippingAddress = this.txtShippingAddress.Text.Trim();
                 poHead.Note            = this.txtNote.Text.Trim();
                 poHead.DefaultPlanDate = Cast.DateTime(this.txtDemandDate.Text, poHead.DefaultPlanDate);
                 poHead.Update(session, "PurchGroupCode", "LocationCode", "VendorID", "ShippingAddress", "Note", "DefaultPlanDate");
                 WebUtil.ShowMsg(this, "采购订单保存成功", "操作成功");
                 return(poHead);
             }
         }
         catch (Exception ex)
         {
             //throw;
             logger.Info("保存POHead", ex);
             WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
         }
         return(null);
     }
 }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int skuid = WebUtil.ParamInt("sku", 0);
         if (skuid <= 0)
         {
             this.divMsg.InnerText = "无效的SKU";
             return;
         }
         using (ISession session = new Session())
         {
             ItemSpec spec = ItemSpec.Retrieve(session, skuid);
             if (spec == null)
             {
                 this.divMsg.InnerText = "SKU " + skuid.ToString() + "不存在";
                 return;
             }
             //显示sku信息
             this.lblItemCode.Text = spec.ItemCode;
             this.lblSize.Text     = spec.SizeCode;
             ItemMaster master = ItemMaster.Retrieve(session, spec.ItemCode);
             this.lblItemName.Text = master == null ? "" : master.ItemName;
             ItemColor color = ItemColor.Retrieve(session, spec.ColorCode);
             this.lblColor.Text  = spec.ColorCode + " " + (color == null ? "" : color.ColorText);
             this.lblOVSQty.Text = spec.EnableOS ? RenderUtil.FormatNumber(spec.OSQty, "#0.##", "0") : "0";
             //现有库存
             StockSummary sto = StockSummary.Retrieve(session, skuid);
             this.lblStockQty.Text  = sto == null ? "0" : RenderUtil.FormatNumber(sto.StockQty, "#0.##");
             this.lblFrozenQty.Text = sto == null ? "0" : RenderUtil.FormatNumber(sto.FrozenQty, "#0.##");
             //在途采购记录
             IList <POLine> lines = POHead.PipelineInvQuery(session, skuid);
             this.repeater.DataSource = lines;
             this.repeater.DataBind();
             decimal pipelineStockQty = 0M;
             //计算汇总在途量
             foreach (POLine line in lines)
             {
                 pipelineStockQty += (line.PurchaseQty - line.ReceiveQty);
             }
             this.lblPipelineStock.Text = RenderUtil.FormatNumber(pipelineStockQty, "#0.##");
             if (lines.Count <= 0)
             {
                 this.divMsg.InnerText = "该SKU没有在途采购";
             }
             else
             {
                 this.divMsg.InnerText = "";
             }
         }
     }
 }
Пример #5
0
    private void BindPOLine(ISession session, POHead poHead)
    {
        //显示POHead内容
        if (poHead != null)
        {
            this.LabOrderNumber.Text = poHead.OrderNumber;
            //供应商
            Vendor vendor = Vendor.Retrieve(session, poHead.VendorID);
            if (vendor != null)
            {
                this.LabVendorID.Text = vendor.ShortName;
            }
            //采购组
            this.LabPurchGroupCode.Text  = poHead.PurchGroupCode;
            this.LabTaxInclusiveAmt.Text = RenderUtil.FormatNumber(poHead.TaxInclusiveAmt, "#0.#0");
        }

        //POLine.SKUID=ItemSpec.SKUID  ItemSpec.ItemID=ItemMaster.ItemID
        //货号ItemMaster.ItemCode  商品名称ItemMaster.ItemName
        //颜色ItemSpec.ColorCode  尺码  ItemSpec.SizeCode
        ObjectQuery query = session.CreateObjectQuery(@"
select m.ItemCode as ItemCode,m.ItemName as ItemName,s.ColorCode as ColorCode,s.SizeCode as SizeCode
    ,p.LineNumber as LineNumber,p.LineStatus as LineStatus,p.PurchaseQty as PurchaseQty,p.PlanDate as PlanDate,p.Price as Price,p.OrderNumber as OrderNumber
    ,p.TaxInclusiveAmt as TaxInclusiveAmt,p.TaxValue as TaxValue,p.TaxAmt as TaxAmt,p.TaxID as TaxID
from POLine p
inner join ItemSpec s on p.SKUID=s.SKUID
inner join ItemMaster m on s.ItemID=m.ItemID
WHERE p.OrderNumber=?
order by p.LineNumber")
                            .Attach(typeof(POLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster))
                            .SetValue(0, this.OrderNumber, "p.OrderNumber");
        DataSet ds = query.DataSet();

        this.rptPL.DataSource = ds;
        this.rptPL.DataBind();

        int number = 0;

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            number += Cast.Int(row["PurchaseQty"]);
        }
        this.lblTotalQty.Text = number.ToString();
    }
Пример #6
0
    void QueryAndBindData(ISession session)
    {
        string OrderNumber = WebUtil.Param("OrderNum");
        string LineNumber  = WebUtil.Param("CurrentLineNumber");

        if (!string.IsNullOrEmpty(OrderNumber) && !string.IsNullOrEmpty(LineNumber))
        {
            //显示POHead内容
            POHead poHead = POHead.Retrieve(session, OrderNumber);
            if (poHead != null)
            {
                this.LabOrderNumber.Text = poHead.OrderNumber;

                this.LabTaxAmt.Text          = poHead.TaxAmt.ToString();
                this.LabTaxExclusiveAmt.Text = poHead.TaxExclusiveAmt.ToString();
                this.LabTaxInclusiveAmt.Text = poHead.TaxInclusiveAmt.ToString();
                //供应商
                Vendor vendor = Vendor.Retrieve(session, poHead.VendorID);
                if (vendor != null)
                {
                    this.LabVendorID.Text = vendor.FullName;
                }
                //采购组
                PurchaseGroup purchasegroup = PurchaseGroup.Retrieve(session, poHead.PurchGroupCode);
                if (purchasegroup != null)
                {
                    this.LabPurchGroupCode.Text = purchasegroup.PurchGroupText;
                }
            }
            //POLine.SKUID=ItemSpec.SKUID  ItemSpec.ItemID=ItemMaster.ItemID
            //货号ItemMaster.ItemCode  商品名称ItemMaster.ItemName
            //颜色ItemSpec.ColorCode  尺码  ItemSpec.SizeCode
            this.magicPagerSub.PageSize = 20;
            int         pageIndex = this.magicPagerMain.CurrentPageIndex;
            int         pageSize  = this.magicPagerMain.PageSize;
            ObjectQuery query     = session.CreateObjectQuery(@"select m.ItemCode as ItemCode,m.ItemName as ItemName,s.ColorCode as ColorCode,s.SizeCode as SizeCode,p.LineStatus as LineStatus,p.PurchaseQty as PurchaseQty,p.PlanDate as PlanDate,p.Price as Price,p.TaxInclusiveAmt as TaxInclusiveAmt,p.TaxValue as TaxValue,p.TaxAmt as TaxAmt,p.LineNumber as LineNumber,p.OrderNumber as OrderNumber from POLine p,ItemSpec s,ItemMaster m WHERE p.SKUID=s.SKUID AND s.ItemID=m.ItemID AND p.OrderNumber=?").Attach(typeof(POLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).SetValue(0, OrderNumber, "p.OrderNumber").SetPage(pageIndex, pageSize);
            this.rptPL.DataSource = query.DataSet();
            this.rptPL.DataBind();

            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = query.Count();
            WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
            WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
        }
    }
Пример #7
0
 private void SetView(POHead po)
 {
     if (this.IsNew)
     {
         this.cmdDetail.Visible = false;
         this.cmdPaid.Visible   = false;
     }
     else
     {
         this.cmdDetail.Visible = true;
         this.cmdPaid.Visible   = false;
         if (po != null && !po.HasPaid)
         {
             this.cmdPaid.Visible = true;
         }
         this.cmdDetail["Detail"].NavigateUrl = "POLineManage.aspx?OrderNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(WebUtil.Param("return"));
     }
     this.cmdReturn["Return"].NavigateUrl = WebUtil.Param("return");
 }
Пример #8
0
    private void UpdatePOLineAndPoHead(ISession session, POHead head)
    {
        //POLine 统计
        IList <POLine> lines = session.CreateEntityQuery <POLine>()
                               .Where(Exp.Eq("OrderNumber", this.OrderNumber))
                               .And(Exp.NEq("LineStatus", POLineStatus.Cancel))
                               .List <POLine>();
        decimal totalTaxInclusiveAmt = 0M; //, totalTaxAmt = 0M, totalTaxExlusiveAmt = 0M;

        foreach (POLine line in lines)
        {
            totalTaxInclusiveAmt += line.TaxInclusiveAmt;
            //totalTaxAmt += line.TaxAmt;
            //totalTaxExlusiveAmt += line.TaxExlusiveAmt;
        }

        //更新主表 TaxInclusiveAmt TaxAmt TaxExlusiveAmt
        head.TaxInclusiveAmt = totalTaxInclusiveAmt;
        //head.TaxAmt = totalTaxAmt;
        //head.TaxExclusiveAmt = totalTaxExlusiveAmt;
        head.Update(session, "TaxInclusiveAmt");
    }
Пример #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.hidStatus.Value     = POStatus.New.ToString();
            this.txtOrderNumber.Text = WebUtil.Param("OrderNum");
            this.lblPaid.Text        = "否";
            POHead po = null;
            using (_session = new Session())
            {
                InitDrp(_session);
                _actionMode             = WebUtil.GetActionMode(this);
                this.txtDemandDate.Text = DateTime.Now.ToString("yyyy-MM-dd");

                if (_actionMode == Mode.Edit)
                {
                    po = POHead.Retrieve(_session, this.OrderNumber);
                    RetrievePOHeadData(po, this.OrderNumber);
                }
            }
            this.SetView(po);
        }
    }
Пример #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["return"] != null)
     {
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = Request["return"];
     }
     if (!IsPostBack)
     {
         using (_session = new Session())
         {
             POHead head = POHead.Retrieve(_session, this.OrderNumber);
             if (head != null)
             {
                 BindPOLine(_session, head);
             }
             this.SetView(_session, head);
             if (head.Status == POStatus.New)
             {
                 this.SetQuickAdd(_session, head);
             }
         }
     }
 }
Пример #11
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));
        }
Пример #12
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         #region  除
         bool deleted = false;
         using (ISession session = new Session())
         {
             session.BeginTransaction();
             try
             {
                 foreach (RepeaterItem item in this.rptPO.Items)
                 {
                     HtmlInputCheckBox chk       = item.FindControl("checkbox") as HtmlInputCheckBox;
                     HtmlInputHidden   hidStatus = item.FindControl("hidStatus") as HtmlInputHidden;
                     if (chk != null && chk.Checked && !string.IsNullOrEmpty(chk.Value))
                     {
                         if (Cast.Enum <POStatus>(hidStatus.Value) == POStatus.New)
                         {
                             session.CreateEntityQuery <POLine>()
                             .Where(Exp.Eq("OrderNumber", chk.Value))
                             .Delete();
                             POHead.Delete(session, chk.Value);
                             deleted = true;
                         }
                     }
                 }
                 session.Commit();
                 if (deleted)
                 {
                     this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                     WebUtil.ShowMsg(this, "选择的采购订单已经被删除", "操作成功");
                 }
             }
             catch (Exception ex)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, ex);
             }
         }
         #endregion
     }
     else if (e.CommandName == "Complete")
     {
         #region 关闭采购订单
         bool completed = false;
         using (ISession session = new Session())
         {
             session.BeginTransaction();
             try
             {
                 foreach (RepeaterItem item in this.rptPO.Items)
                 {
                     HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                     if (chk != null && chk.Checked && !string.IsNullOrEmpty(chk.Value))
                     {
                         POHead poHead = POHead.Retrieve(session, chk.Value);
                         if (poHead.Status == POStatus.Release && poHead.ApproveResult == ApproveStatus.Approve)
                         {
                             poHead.Close(session);
                             completed = true;
                         }
                     }
                 }
                 session.Commit();
             }
             catch (Exception er)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, er);
             }
             if (completed)
             {
                 this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                 WebUtil.ShowMsg(this, "选择的采购订单已经完成", "操作成功");
             }
         }
         #endregion
     }
     else if (e.CommandName == "Publish")
     {
         #region 发布(送签单据)
         bool published = false;
         using (ISession session = new Session())
         {
             session.BeginTransaction();
             try
             {
                 foreach (RepeaterItem item in this.rptPO.Items)
                 {
                     HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                     if (chk != null && chk.Checked && !string.IsNullOrEmpty(chk.Value))
                     {
                         POHead poHead = POHead.Retrieve(session, chk.Value.Trim());
                         if (poHead.Status == POStatus.New)//为新建状态
                         {
                             poHead.Release(session);
                             published = true;
                         }
                     }
                 }
                 session.Commit();
             }
             catch (Exception er)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, er);
             }
             if (published)
             {
                 this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                 WebUtil.ShowMsg(this, "选择的采购订单已经发布", "操作成功");
             }
         }
         #endregion
     }
 }
Пример #13
0
    private void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetchRecordCount)
    {
        ObjectQuery query = session.CreateObjectQuery(@"
select ai.ApproveID as ApproveID,ai.OrderTypeCode as OrderTypeCode,td.TypeText as TypeText,ai.OrderNumber as OrderNumber
    ,ai.Status as Status,ai.ApproveTime as ApproveTime
    ,u1.FullName as SubmitUser,u2.FullName as CreateUser,ai.SubmitTime as SubmitTime,ai.CreateTime as CreateTime
    ,ar.HasFinished as HasFinished,ar.ActiveItem as ActiveItem, td.ViewURL as ViewURL
    ,ar.ApproveResultID as ApproveResultID, ' ' as Vendor
from OrderApproveItem ai 
inner join OrderApproveResult ar on ai.ApproveID=ar.ApproveID
inner join OrderTypeDef td on td.OrderTypeCode=ai.OrderTypeCode
left join User u1 on u1.UserId=ai.SubmitUser
left join User u2 on u2.UserId=ai.CreateUser
where ar.ApproveUser=?userId")
                            .Attach(typeof(OrderApproveItem)).Attach(typeof(OrderApproveResult)).Attach(typeof(OrderTypeDef))
                            .Attach(typeof(Magic.Sys.User))
                            .SetValue("?userId", Magic.Security.SecuritySession.CurrentUser.UserId, "ar.ApproveUser")
                            .SetPage(pageIndex, pageSize);

        if (this.drpOrderType.SelectedValue.Trim().Length > 0)
        {
            query.And(Exp.Eq("ai.OrderTypeCode", this.drpOrderType.SelectedValue.Trim()));
        }
        if (this.txtOrderNumber.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("ai.OrderNumber", "%" + this.txtOrderNumber.Text.Trim() + "%"));
        }
        if (this.rdoUnapprove.Checked)
        {
            query.And(Exp.Eq("ar.ActiveItem", true)).OrderBy("ai.SubmitTime", Order.Desc);
        }
        else
        {
            query.And(Exp.Eq("ar.HasFinished", true)).OrderBy("ai.ApproveTime", Order.Desc);
            DateTime dateFrom = Cast.DateTime(this.txtDateFrom.Text.Trim(), new DateTime(1900, 1, 1));
            DateTime dateTo   = Cast.DateTime(this.txtDateTo.Text.Trim(), new DateTime(1900, 1, 1)).AddDays(1);
            if (dateFrom > new DateTime(1900, 1, 1))
            {
                query.And(Exp.Ge("ai.ApproveTime", dateFrom));
            }
            if (dateTo > new DateTime(1900, 1, 1))
            {
                query.And(Exp.Le("ai.ApproveTime", dateTo));
            }
        }

        DataSet ds = query.DataSet();

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            string ordType = Cast.String(row["OrderTypeCode"]);
            if (ordType == POHead.ORDER_TYPE)
            {
                string poNum = Cast.String(row["OrderNumber"]);
                POHead po    = POHead.Retrieve(session, poNum);
                if (po != null && po.VendorID > 0)
                {
                    Vendor vendor = Vendor.Retrieve(session, po.VendorID);
                    if (vendor != null)
                    {
                        row["Vendor"] = vendor.ShortName;
                    }
                }
            }
        }
        this.repeatControl.DataSource = ds;
        this.repeatControl.DataBind();
        if (fetchRecordCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = query.Count();
        }
        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
    }
Пример #14
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region 保存
            //txtPurchaseQty txtPlanDate txtPrice
            bool updated = false;
            using (_session = new Session())
            {
                POHead head = POHead.Retrieve(_session, this.OrderNumber);
                if (head == null || head.Status != POStatus.New)
                {
                    return;
                }

                _session.BeginTransaction();
                try
                {
                    foreach (RepeaterItem item in this.rptPL.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (!string.IsNullOrEmpty(chk.Value))
                        {
                            HtmlInputText txtPurchaseQty = item.FindControl("txtPurchaseQty") as HtmlInputText;
                            HtmlInputText txtPlanDate    = item.FindControl("txtPlanDate") as HtmlInputText;
                            HtmlInputText txtPrice       = item.FindControl("txtPrice") as HtmlInputText;
                            POLine        poLine         = POLine.Retrieve(_session, this.OrderNumber, chk.Value);
                            if (poLine == null || poLine.LineStatus != POLineStatus.Open)
                            {
                                continue;
                            }

                            poLine.PurchaseQty = Cast.Decimal(txtPurchaseQty.Value, poLine.PurchaseQty);
                            poLine.PlanDate    = Cast.DateTime(txtPlanDate.Value, poLine.PlanDate);
                            poLine.Price       = Cast.Decimal(txtPrice.Value, poLine.Price);
                            poLine.TaxID       = 0;
                            poLine.TaxValue    = 0M;
                            //含税额(含税采购成本)  TaxInclusiveAmt 含税额 = 数量*单价
                            poLine.TaxInclusiveAmt = poLine.PurchaseQty * poLine.Price;
                            //不含税额(采购成本) TaxExlusiveAmt 含税额-税额
                            poLine.TaxExlusiveAmt = 0M; // poLine.TaxInclusiveAmt / (1 + poLine.TaxValue);
                            //税额    TaxAmt  税额 = 不含税额*税率
                            poLine.TaxAmt = 0M;         //poLine.TaxExlusiveAmt * poLine.TaxValue;
                            poLine.Update(_session, "PurchaseQty", "TaxID", "TaxValue", "PlanDate", "Price", "TaxInclusiveAmt");
                            updated = true;
                        }
                    }
                    //更新统计信息
                    if (updated)
                    {
                        UpdatePOLineAndPoHead(_session, head);
                    }
                    _session.Commit();
                    if (updated)
                    {
                        BindPOLine(_session, head);
                        WebUtil.ShowMsg(this, "采购订单明细保存成功", "操作成功");
                    }
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    WebUtil.ShowError(this, ex);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Cancel")
        {
            #region 取消明细
            bool updated = false;
            using (_session = new Session())
            {
                POHead head = POHead.Retrieve(_session, this.OrderNumber);
                if (head.Status != POStatus.Release)
                {
                    return;
                }

                _session.BeginTransaction();
                try
                {
                    foreach (RepeaterItem item in this.rptPL.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk != null && chk.Checked && !string.IsNullOrEmpty(chk.Value))
                        {
                            POLine poLine = POLine.Retrieve(_session, this.OrderNumber, chk.Value);
                            if (poLine == null || poLine.LineStatus != POLineStatus.Open)
                            {
                                continue;
                            }
                            poLine.LineStatus = POLineStatus.Cancel;
                            poLine.ModifyUser = Magic.Security.SecuritySession.CurrentUser.UserId;
                            poLine.ModifyTime = DateTime.Now;
                            poLine.Update(_session, "LineStatus", "ModifyUser", "ModifyTime");
                            updated = true;
                        }
                    }
                    //再次统计 POLine
                    if (updated)
                    {
                        UpdatePOLineAndPoHead(_session, head);
                    }
                    _session.Commit();

                    if (updated)
                    {
                        BindPOLine(_session, head);
                        WebUtil.ShowMsg(this, "选择的明细已经取消", "操作成功");
                    }
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    WebUtil.ShowError(this, ex);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Delete")
        {
            #region  除明细
            bool deleted = false;
            using (_session = new Session())
            {
                POHead head = POHead.Retrieve(_session, this.OrderNumber);
                if (head == null || head.Status != POStatus.New)
                {
                    return;
                }

                _session.BeginTransaction();
                try
                {
                    foreach (RepeaterItem item in this.rptPL.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk != null && chk.Checked && !string.IsNullOrEmpty(chk.Value))
                        {
                            POLine line = POLine.Retrieve(_session, this.OrderNumber, chk.Value);
                            if (line.LineStatus != POLineStatus.Open)
                            {
                                continue;
                            }
                            line.Delete(_session);
                            deleted = true;
                        }
                    }
                    //再次统计 POLine
                    if (deleted)
                    {
                        UpdatePOLineAndPoHead(_session, head);
                    }
                    _session.Commit();

                    if (deleted)
                    {
                        BindPOLine(_session, head);
                        WebUtil.ShowMsg(this, "选择的明细已经删除", "操作成功");
                    }
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    WebUtil.ShowError(this, ex);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Release" || e.CommandName == "Close")
        {
            #region 发布,关闭
            using (_session = new Session())
            {
                try
                {
                    POHead head = POHead.Retrieve(_session, this.OrderNumber);
                    _session.BeginTransaction();
                    if (e.CommandName == "Release")
                    {
                        head.Release(_session);
                    }
                    else
                    {
                        head.Close(_session);
                    }
                    _session.Commit();

                    BindPOLine(_session, head);
                    this.SetView(_session, head);
                    WebUtil.ShowMsg(this, "订单已经" + (e.CommandName == "Release" ? "发布" : "关闭"), "操作成功");
                }
                catch (Exception er)
                {
                    _session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "QuickAdd")
        {
            #region 快速添加
            using (_session = new Session())
            {
                //检查
                string   itemCode = this.txtItemCode.Value.Trim();
                string   color    = this.txtColorCode.Value.Trim().ToUpper();
                string   size     = this.txtSizeCode.Value.Trim().ToUpper();
                decimal  qty      = Cast.Decimal(this.txtPurchaseQty.Value.Trim(), 0M);
                decimal  price    = Cast.Decimal(this.txtPrice.Value.Trim(), 0M);
                DateTime date     = Cast.DateTime(this.txtDemandDate.Value.Trim(), new DateTime(1900, 1, 1));

                if (qty <= 0M)
                {
                    this.txtAlertMsg.InnerText = string.Format("采购数量{0}不是有效的数字", this.txtPurchaseQty.Value.Trim());
                    return;
                }
                if (price <= 0M)
                {
                    this.txtAlertMsg.InnerText = string.Format("单价{0}不是有效的数字", this.txtPrice.Value.Trim());
                    return;
                }
                if (date <= new DateTime(1900, 1, 1))
                {
                    this.txtAlertMsg.InnerText = string.Format("无效的需求日期{0}", this.txtDemandDate.Value.Trim());
                    return;
                }

                IList <ItemMaster> masters = _session.CreateEntityQuery <ItemMaster>()
                                             .Where(Exp.Eq("ItemCode", itemCode)).List <ItemMaster>();
                if (masters == null || masters.Count <= 0)
                {
                    this.txtAlertMsg.InnerText = string.Format("货号{0}不存在", itemCode);
                    return;
                }
                ItemColor objColor = ItemColor.Retrieve(_session, color);
                if (objColor == null)
                {
                    this.txtAlertMsg.InnerText = string.Format("颜色代码{0}不存在", color);
                    return;
                }
                IList <ItemSpec> skus = _session.CreateEntityQuery <ItemSpec>()
                                        .Where(Exp.Eq("ItemID", masters[0].ItemID) & Exp.Eq("ColorCode", objColor.ColorCode) & Exp.Eq("SizeCode", size))
                                        .List <ItemSpec>();
                if (skus == null || skus.Count <= 0)
                {
                    this.txtAlertMsg.InnerText = string.Format("不存在货号:{0} 颜色:{1} 尺码:{2}的SKU", itemCode, color, size);
                    return;
                }
                ItemSize objSize = ItemSize.Retrieve(_session, size, masters[0].CategoryID);
                if (objSize == null)
                {
                    this.txtAlertMsg.InnerText = string.Format("尺码{0}不存在", size);
                    return;
                }

                //添加操作
                POHead head = POHead.Retrieve(_session, this.OrderNumber);
                POLine line = new POLine();
                line.OrderNumber          = this.OrderNumber;
                line.LineNumber           = head.NextLineNumber();
                line.LineStatus           = POLineStatus.Open;
                line.SKUID                = skus[0].SKUID;
                line.PurchaseQty          = qty;
                line.Price                = price;
                line.TaxID                = 0;
                line.TaxValue             = 0M;
                line.TaxInclusiveAmt      = line.PurchaseQty * line.Price;
                line.TaxExlusiveAmt       = 0M; // line.TaxInclusiveAmt / (1 + line.TaxValue);
                line.TaxAmt               = 0M; //line.TaxExlusiveAmt * line.TaxValue;
                line.PlanDate             = date;
                line.ActualDate           = new DateTime(1900, 1, 1);
                line.ReceiveQty           = 0M;
                line.IQCQty               = 0M;
                line.UnfinishedReceiveQty = 0M;
                line.ModifyUser           = SecuritySession.CurrentUser.UserId;
                line.ModifyTime           = DateTime.Now;
                line.UnitID               = 0;

                try
                {
                    _session.BeginTransaction();
                    line.Create(_session);
                    head.Update(_session, "CurrentLineNumber");
                    this.UpdatePOLineAndPoHead(_session, head);
                    _session.Commit();
                    BindPOLine(_session, head);
                    this.txtAlertMsg.InnerText = "添加成功,订单行号为" + line.LineNumber;
                    this.txtPurchaseQty.Value  = "";
                }
                catch (Exception er)
                {
                    _session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
    }
Пример #15
0
 private void SetQuickAdd(ISession session, POHead head)
 {
     this.txtDemandDate.Value = head.DefaultPlanDate.ToString("yyyy-MM-dd");
 }
Пример #16
0
    protected void cmdProduct_Click(object sender, EventArgs e)
    {
        if (this.txtSkuId.Value.Trim().Length <= 0)
        {
            return;
        }

        bool added = false;

        using (_session = new Session())
        {
            string[] idArray = this.txtSkuId.Value.Trim().Trim(';').Split(';');
            try
            {
                POHead head = POHead.Retrieve(_session, this.OrderNumber);
                if (head == null || head.Status != POStatus.New)
                {
                    return;
                }

                _session.BeginTransaction();
                foreach (string s in idArray)
                {
                    POLine poLine = new POLine();
                    poLine.OrderNumber = this.OrderNumber;
                    poLine.SKUID       = Cast.Int(s, 0);
                    if (poLine.SKUID <= 0)
                    {
                        continue;
                    }
                    poLine.LineNumber  = head.NextLineNumber();
                    poLine.LineStatus  = POLineStatus.Open;
                    poLine.PurchaseQty = 0M;
                    poLine.Price       = 0M;
                    //Vendor vendor = null;
                    //if (head.VendorID > 0) vendor = Vendor.Retrieve(_session, head.VendorID);
                    //if (vendor != null)
                    //{
                    //    poLine.TaxID = vendor.TaxID;
                    //    poLine.TaxValue = vendor.Tax;
                    //}
                    //else
                    //{
                    //    poLine.TaxID = 0;
                    //    poLine.TaxValue = 0M;
                    //}
                    poLine.TaxID                = 0;
                    poLine.TaxValue             = 0M;
                    poLine.TaxInclusiveAmt      = 0M;
                    poLine.TaxAmt               = 0M;
                    poLine.TaxExlusiveAmt       = 0M;
                    poLine.PlanDate             = head.DefaultPlanDate;
                    poLine.ActualDate           = new DateTime(1900, 1, 1);
                    poLine.ReceiveQty           = 0M;
                    poLine.IQCQty               = 0M;
                    poLine.UnfinishedReceiveQty = 0M;
                    poLine.ModifyUser           = SecuritySession.CurrentUser.UserId;
                    poLine.ModifyTime           = DateTime.Now;
                    poLine.UnitID               = 0;

                    poLine.Create(_session);
                    added = true;
                }
                head.Update(_session, "CurrentLineNumber");
                _session.Commit();
                if (added)
                {
                    BindPOLine(_session, head);
                    WebUtil.ShowMsg(this, "订单明细保存成功", "操作成功");
                }
            }
            catch (Exception ex)
            {
                _session.Rollback();
                logger.Info("保存POLine", ex);
                WebUtil.ShowError(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
            }
        }
    }
Пример #17
0
    private void SetView(ISession session, POHead head)
    {
        POStatus status = head == null ? POStatus.Close : head.Status;

        this.hidStatus.Value = status.ToString();
        //按钮屏蔽判断  新建 1  发布 2 已完成3
        //新增 cmdSelectItem  保存cmdSave1 取消cmdCancel1 返回cmdReturn1
        switch (status)
        {
        case POStatus.New:
            this.cmdSelectItem1.Visible = true;
            this.cmdSelectItem2.Visible = true;
            this.cmdSave1.Visible       = true;
            this.cmdSave2.Visible       = true;
            this.cmdDelete1.Visible     = true;
            this.cmdDelete2.Visible     = true;
            this.cmdCancel1.Visible     = false;
            this.cmdCancel2.Visible     = false;
            this.cmdRelease1.Visible    = true;
            this.cmdRelease2.Visible    = true;
            this.cmdClose1.Visible      = false;
            this.cmdClose2.Visible      = false;
            this.divQuickAdd1.Visible   = true;
            this.divQuickAdd2.Visible   = true;
            break;

        case POStatus.Release:
            this.cmdSelectItem1.Visible = false;
            this.cmdSelectItem2.Visible = false;
            this.cmdSave1.Visible       = false;
            this.cmdSave2.Visible       = false;
            this.cmdDelete1.Visible     = false;
            this.cmdDelete2.Visible     = false;
            this.cmdRelease1.Visible    = false;
            this.cmdRelease2.Visible    = false;
            this.cmdCancel1.Visible     = true;
            this.cmdCancel2.Visible     = true;
            if (head.ApproveResult == ApproveStatus.UnApprove)
            {
                this.cmdClose1.Visible = false;
                this.cmdClose2.Visible = false;
            }
            else
            {
                this.cmdClose1.Visible = true;
                this.cmdClose2.Visible = true;
            }
            this.divQuickAdd1.Visible = false;
            this.divQuickAdd2.Visible = false;
            this.SetReadonly();
            break;

        case POStatus.Close:
            this.cmdSelectItem1.Visible = false;
            this.cmdSelectItem2.Visible = false;
            this.cmdSave1.Visible       = false;
            this.cmdSave2.Visible       = false;
            this.cmdDelete1.Visible     = false;
            this.cmdDelete2.Visible     = false;
            this.cmdRelease1.Visible    = false;
            this.cmdRelease2.Visible    = false;
            this.cmdCancel1.Visible     = false;
            this.cmdCancel2.Visible     = false;
            this.cmdClose1.Visible      = false;
            this.cmdClose2.Visible      = false;
            this.divQuickAdd1.Visible   = false;
            this.divQuickAdd2.Visible   = false;
            this.SetReadonly();
            break;
        }
    }