private void BindArea(ISession session, INVCheckHead head)
    {
        IList <WHArea> areas = session.CreateObjectQuery(@"
select 1 from WHArea where AreaCode not in(
    select distinct a.AreaCode 
    from INVCheckWh a 
    inner join INVCheckHead b on a.OrderNumber=b.OrderNumber 
    where b.Status=?s1
)
    and Status=?status and IsReservedArea=?isReserved and IsTransArea=?transArea and LocationCode=?loc and IsLocked=?islock
order by AreaCode")
                               .Attach(typeof(WHArea)).Attach(typeof(INVCheckWh)).Attach(typeof(INVCheckHead))
                               .SetValue("?s1", INVCheckStatus.New, EntityManager.GetPropMapping(typeof(INVCheckHead), "Status").DbTypeInfo)
                               .SetValue("?status", WHStatus.Enable, "Status")
                               .SetValue("?isReserved", false, "IsReservedArea")
                               .SetValue("?transArea", true, "IsTransArea")
                               .SetValue("?loc", head.LocationCode, "LocationCode")
                               .SetValue("?islock", false, "IsLocked")
                               .List <WHArea>();

        this.drpArea.Items.Clear();
        foreach (WHArea area in areas)
        {
            this.drpArea.Items.Add(new ListItem(area.AreaCode, area.AreaCode));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value     = WebUtil.Param("ordNumber");

            this.setView(null);

            using (ISession session = new Session())
            {
                IList <WHLocation> locations = WHLocation.EffectiveList(session);
                this.drpLocation.Items.Clear();
                foreach (WHLocation loc in locations)
                {
                    this.drpLocation.Items.Add(new ListItem(loc.Name, loc.LocationCode));
                }

                if (!this.IsNew)
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    this.setView(head);
                    this.showInfo(session, head);
                    log.DebugFormat("PageLoad - {0}库存调整: ordNum={1}, return={2}", head.Status == INVCheckStatus.New ? "编辑" : "查看", this.OrderNumber, this.ReturnUrl);
                }
                else
                {
                    log.Debug("PageLoad-新增库存调整单: return=" + WebUtil.Param("return"));
                }
            }
        }
    }
Пример #3
0
    private void SetView(INVCheckHead head)
    {
        switch (head.Status)
        {
        case INVCheckStatus.New:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;

        case INVCheckStatus.Release:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = true;
            this.cmdClose2.Visible = true;
            break;

        case INVCheckStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            break;
        }
    }
    private void QueryAndBindData(ISession session, INVCheckHead head, int pageSize, int pageIndex, bool fetchCount)
    {
        Magic.Framework.ORM.Query.ObjectQuery query = session.CreateObjectQuery(string.Format(@"
select l.LineNumber as LineNumber
    ,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName
    ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode
    ,l.AreaCode as AreaCode,l.SectionCode as SectionCode,l.BeforeQty as BeforeQty,l.CurrentQty as CurrentQty
from INVCheckLine l
inner join ItemSpec s on l.SKUID=s.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
left join ItemColor color on color.ColorCode=s.ColorCode
where l.OrderNumber=?ordNum {0}
order by l.LineNumber", this.drpViewType.SelectedValue == "2" ? "and l.BeforeQty<>l.CurrentQty" : ""))
                                                      .Attach(typeof(INVCheckLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                                                      .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber")
                                                      .SetPage(pageIndex, pageSize);
        if (this.drpArea.SelectedValue.Trim().Length > 0)
        {
            query.And(Exp.Eq("l.AreaCode", this.drpArea.SelectedValue.Trim()));
        }
        if (this.txtSKU.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("s.BarCode", "%" + this.txtSKU.Text.Trim() + "%"));
        }
        if (this.txtItemCode.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("m.ItemCode", "%" + this.txtItemCode.Text.Trim() + "%"));
        }
        if (this.txtName.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("m.ItemName", "%" + this.txtName.Text.Trim() + "%"));
        }
        if (this.txtColor.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("s.ColorCode", "%" + this.txtColor.Text.Trim().ToUpper() + "%"));
        }
        if (this.txtSize.Text.Trim().Length > 0)
        {
            query.And(Exp.Like("s.SizeCode", "%" + this.txtSize.Text.Trim().ToUpper() + "%"));
        }

        this.repeatControl.DataSource = query.DataSet();
        this._head = INVCheckHead.Retrieve(session, this.OrderNumber);
        this.repeatControl.DataBind();
        this._head = null;

        if (fetchCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = query.Count();
        }
        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
        this.txtReturnToThisUrl.Value = this.GetReturnUrl();
    }
    private void QueryAndBindData(ISession session, INVCheckHead head)
    {
        this.repeaterControl.DataSource = session.CreateObjectQuery(@"
select 1 from WHArea where AreaCode in (select AreaCode from INVCheckWh where OrderNumber=?ordNum)
order by AreaCode")
                                          .Attach(typeof(WHArea)).Attach(typeof(INVCheckWh))
                                          .SetValue("?ordNum", this.OrderNumber, EntityManager.GetPropMapping(typeof(INVCheckWh), "OrderNumber").DbTypeInfo)
                                          .List <WHArea>();
        this._head = head;
        this.repeaterControl.DataBind();
        this._head = null;
    }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            using (ISession session = new Session())
            {
                INVCheckHead head = null;
                if (this.IsNew)
                {
                    head               = new INVCheckHead();
                    head.OrderNumber   = ERPUtil.NextOrderNumber(INVCheckHead.ORDER_TYPE_ADJ);
                    head.Note          = this.txtNote.Text.Trim();
                    head.LocationCode  = this.drpLocation.SelectedValue;
                    head.Status        = INVCheckStatus.New;
                    head.OrderTypeCode = INVCheckHead.ORDER_TYPE_ADJ;
                    head.CreateTime    = DateTime.Now;
                    head.CreateUser    = SecuritySession.CurrentUser.UserId;

                    head.Create(session);
                    log.DebugFormat("Create - 库存调整单: {0}", head.OrderNumber);

                    System.Text.StringBuilder url = new System.Text.StringBuilder();
                    url.Append("StockAdjustmentNewLine.aspx?ordNum=").Append(head.OrderNumber);
                    url.Append("&return=");
                    //保存后跳转到添加明细页面
                    //下面的返回url设置用途:
                    //1. 从添加明细页面点击返回按钮,将跳转到明细维护界面
                    //2. 明细维护界面再点击返回按钮,跳转到调整单主档维护页面,并且保留下从调整单主档维护页面进入新增页面时的查询条件
                    url.Append(WebUtil.escape("StockAdjustmentLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))));
                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("Redirect - to添加调整明细: url={0}", url.ToString());
                        log.DebugFormat("返回调整明细页地址: url={0}", "StockAdjustmentLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                    }
                    this.Response.Redirect(url.ToString());
                }

                head = INVCheckHead.Retrieve(session, this.OrderNumber);
                if (head.Status != INVCheckStatus.New)
                {
                    log.WarnFormat("Warn - 保存库存调整单: 库存调整单{0}状态为{1},无法保存", head.OrderNumber, head.Status.ToString());
                    WebUtil.ShowMsg(this, "只有状态为新建的库存调整单可以修改保存!");
                    return;
                }
                head.Note         = this.txtNote.Text.Trim();
                head.LocationCode = this.drpLocation.SelectedValue;
                head.Update(session, "Note", "LocationCode");
                log.DebugFormat("Update - 库存调整单: {0}", head.OrderNumber);
                WebUtil.ShowMsg(this, "保存成功");
            }
        }
    }
Пример #7
0
    private void SetView(ISession session, INVCheckHead head)
    {
        if (!this.IsNew)
        {
            WebUtil.DisableControl(this.drpLocation);
        }
        if (head != null)
        {
            if (!string.IsNullOrEmpty(head.LocationCode) && head.LocationCode.Trim().Length > 0)
            {
                WHLocation location = WHLocation.Retrieve(session, head.LocationCode);
                this.drpLocation.Items.Clear();
                this.drpLocation.Items.Add(new ListItem(location.Name, location.LocationCode));
            }
            this.drpCheckType.SelectedValue = head.CheckType.ToString();
            this.txtMemo.Text = head.Note;
            OrderStatusDef statusDef = OrderStatusDef.Retrieve(session, INVCheckHead.ORDER_TYPE_CHK, (int)head.Status);
            if (statusDef != null)
            {
                this.lblStatus.Text = statusDef.StatusText;
            }
            Magic.Sys.User user = null;
            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);
            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;

            if (head.Status != INVCheckStatus.New)
            {
                WebUtil.DisableControl(this.txtMemo);
                WebUtil.DisableControl(this.drpCheckType);
                this.cmdSave.Visible = false;
            }
        }
    }
    private void showInfo(ISession session, INVCheckHead head)
    {
        User user;

        if (head != null)
        {
            this.txtOrderNumber.Text = head.OrderNumber;
            this.txtNote.Text        = head.Note;
            if (!string.IsNullOrEmpty(head.LocationCode))
            {
                this.drpLocation.SelectedValue = head.LocationCode;
            }

            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;
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (ISession session = new Session())
         {
             INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
             this.SetView(head);
             if (head.Status == INVCheckStatus.New)
             {
                 this.BindArea(session, head);
             }
             this.QueryAndBindData(session, head);
         }
     }
 }
Пример #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtOrderNumber.Value             = this.OrderNumber;
         this.txtUrlToThisPage.Value           = "StockAdjustmentLine.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"));
         this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
             log.DebugFormat("PageLoad - sto adj line: ordNum={0}, status={1}", head.OrderNumber, head.Status.ToString());
             this.SetView(head);
             this.QueryAndBindData(session, head);
         }
     }
 }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Save")
        {
            return;
        }

        using (ISession session = new Session())
        {
            try
            {
                IList <INVCheckLine> lines = new List <INVCheckLine>();
                INVCheckHead         head  = INVCheckHead.Retrieve(session, this.OrderNumber);
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    TextBox text = item.FindControl("txtQty") as TextBox;
                    decimal qty  = Cast.Decimal(text.Text, 0M);
                    if (qty <= 0M)
                    {
                        continue;
                    }

                    HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                    lines.Add(head.NewLineAdj(session, Cast.Int(chk.Value), qty));
                }
                if (lines.Count <= 0)
                {
                    log.Debug("Save - sto adj line: no lines need to be saved");
                    return;
                }

                session.BeginTransaction();
                head.CreateOrUpdateLines(session, lines);
                session.Commit();

                log.DebugFormat("Save - sto adj line: {0} lines were created or updated", lines.Count);
                WebUtil.ShowMsg(this, "库存调整明细已经保存");
                this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
            }
            catch (Exception er)
            {
                log.Error("Save - to add sto adj line: ", er);
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
    private void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetchRecordCount)
    {
        int          count = 0;
        INVCheckHead head  = INVCheckHead.Retrieve(session, this.OrderNumber);

        this.repeatControl.DataSource = INVCheckHead.Query(session, fetchRecordCount, out count
                                                           , head.LocationCode, this.txtSku.Text, this.txtItemCode.Text, this.txtItemName.Text, this.txtColor.Text, this.txtSize.Text, this.drpArea.SelectedValue, this.txtSection.Text
                                                           , pageIndex, pageSize);

        this.repeatControl.DataBind();
        if (fetchRecordCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = count;
        }
        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
    }
Пример #13
0
    private void QueryAndBindData(ISession session, INVCheckHead head)
    {
        this.repeatControl.DataSource = session.CreateObjectQuery(@"
select l.LineNumber as LineNumber,sku.BarCode as BarCode,i.ItemCode as ItemCode,i.ItemName as ItemName
    ,sku.ColorCode as ColorCode,color.ColorText as ColorText,sku.SizeCode as SizeCode
    ,l.AreaCode as AreaCode,l.SectionCode as SectionCode,l.BeforeQty as StockQty,l.CurrentQty as AdjQty
from INVCheckLine l
inner join ItemSpec sku on l.SKUID=sku.SKUID
inner join ItemMaster i on i.ItemID=sku.ItemID
left join ItemColor color on color.ColorCode=sku.ColorCode
where l.OrderNumber=?ordNum
order by l.LineNumber")
                                        .Attach(typeof(INVCheckLine))
                                        .Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor))
                                        .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber")
                                        .DataSet();
        this.repeatControl.DataBind();
    }
    private void RestoreLastQuery(ISession session, INVCheckHead head)
    {
        QueryHelper helper = new QueryHelper(this);

        if (helper.HasQueryParameter())
        {
            this.drpViewType.SelectedValue = helper.Pop("vt");
            this.drpArea.SelectedValue     = helper.Pop("area");
            this.txtSection.Text           = helper.Pop("sec");
            this.txtSKU.Text      = helper.Pop("sku");
            this.txtItemCode.Text = helper.Pop("itmc");
            this.txtName.Text     = helper.Pop("itmn");
            this.txtColor.Text    = helper.Pop("color");
            this.txtSize.Text     = helper.Pop("size");
        }
        int pageSize  = Cast.Int(helper.Pop("ps"), this.magicPagerMain.PageSize);
        int pageIndex = Cast.Int(helper.Pop("pi"), 1);

        this.QueryAndBindData(session, head, pageSize, pageIndex, true);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         log.DebugFormat("PageLoad - to add sto adj line: ordNum={0}, return={1}", this.OrderNumber, WebUtil.Param("return"));
         this.toolbarTop["Return"].NavigateUrl = this.toolbarBottom["Return"].NavigateUrl = WebUtil.Param("return");
         using (ISession session = new Session())
         {
             INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
             this.drpArea.Items.Clear();
             this.drpArea.Items.Add(new ListItem("", ""));
             IList <WHArea> areas = ERPUtil.GetWHArea(session, INVCheckHead.ORDER_TYPE_ADJ, null, head.LocationCode);
             foreach (WHArea area in areas)
             {
                 this.drpArea.Items.Add(new ListItem(area.AreaCode, area.AreaCode));
             }
             this.QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
         }
     }
 }
    protected void cmdDelete_Click(object sender, EventArgs e)
    {
        LinkButton cmd = sender as LinkButton;

        if (cmd == null)
        {
            return;
        }
        string area = cmd.Attributes["area"];

        if (string.IsNullOrEmpty(area) || area.Trim().Length <= 0)
        {
            return;
        }
        try
        {
            using (ISession session = new Session())
            {
                INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                try
                {
                    session.BeginTransaction();
                    head.RemoveArea(session, area);
                    session.Commit();

                    this.BindArea(session, head);
                    this.QueryAndBindData(session, head);
                }
                catch (Exception err)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, err);
                    return;
                }
            }
        }
        catch (Exception er)
        {
            WebUtil.ShowError(this, er);
        }
    }
Пример #17
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            try
            {
                using (ISession session = new Session())
                {
                    List <INVCheckHead> heads = new List <INVCheckHead>();
                    for (int i = 0; i < this.rptSDHead.Items.Count; i++)
                    {
                        System.Web.UI.HtmlControls.HtmlInputCheckBox chk = this.rptSDHead.Items[i].FindControl("checkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
                        if (chk.Checked)
                        {
                            heads.Add(INVCheckHead.Retrieve(session, chk.Value));
                        }
                    }

                    session.BeginTransaction();
                    try
                    {
                        foreach (INVCheckHead h in heads)
                        {
                            h.Delete(session);
                        }
                        session.Commit();
                        QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
                    }
                    catch
                    {
                        session.Rollback();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                WebUtil.ShowMsg(this, "删除失败:" + ex.Message);
            }
        }
    }
Пример #18
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         try
         {
             using (ISession session = new Session())
             {
                 try
                 {
                     session.BeginTransaction();
                     INVCheckHead objHead = null;
                     if (this.IsNew)
                     {
                         objHead = new INVCheckHead(this.drpLocation.SelectedValue, Cast.Enum <INVCheckType>(this.drpCheckType.SelectedValue), this.txtMemo.Text.Trim(), SecuritySession.CurrentUser.UserId);
                         objHead.Create(session);
                     }
                     else
                     {
                         objHead           = INVCheckHead.Retrieve(session, this.OrderNumber);
                         objHead.Note      = this.txtMemo.Text.Trim();
                         objHead.CheckType = Cast.Enum <INVCheckType>(this.drpCheckType.SelectedValue);
                         objHead.Update(session, "CheckType", "Note");
                     }
                     session.Commit();
                     this.Response.Redirect("InventoryCheckWH.aspx?ordNum=" + objHead.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(WebUtil.Param("return")));
                 }
                 catch (Exception ex)
                 {
                     session.Rollback();
                     throw ex;
                 }
             }
         }
         catch (Exception ex)
         {
             logger.Info("保存库存盘点单", ex);
             WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtOrdNumber.Value = this.OrderNumber;
            WebUtil.SetMagicPager(this.magicPagerMain, this.magicPagerMain.PageSize, 1);
            WebUtil.SetMagicPager(this.magicPagerSub, this.magicPagerSub.PageSize, 1);

            using (ISession session = new Session())
            {
                this.LoadArea(session);
                INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                this.SetView(head);
                this.RestoreLastQuery(session, head);
            }
        }
        else
        {
            this.frameDownload.Attributes["src"] = "about:blank;";
        }
    }
 private void SetView(INVCheckHead head)
 {
     if (head == null || head.Status != INVCheckStatus.New)
     {
         this.sectionAdd.Visible   = false;
         this.sectionAlert.Visible = false;
         this.cmdConfirm.Visible   = false;
         if (head != null)
         {
             this.cmdViewDetail.Visible = true;
             this.cmdViewDetail["Detail"].NavigateUrl = "InventoryCheckDetail.aspx?ordNum=" + head.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(WebUtil.Param("return"));
         }
         else
         {
             this.cmdViewDetail.Visible = false;
         }
     }
     else
     {
         this.cmdViewDetail.Visible = false;
     }
     this.cmdReturn["Return"].NavigateUrl = WebUtil.Param("return");
 }
    private void setView(INVCheckHead head)
    {
        if (this.IsNew)
        {
            this.cmdDetail.Visible = false;
        }
        else
        {
            this.cmdDetail.Visible = true;
            this.cmdDetail["Detail"].NavigateUrl = "StockAdjustmentLine.aspx?ordNum=" + this.OrderNumber + "&return=" + Microsoft.JScript.GlobalObject.escape(this.ReturnUrl);
            if (head != null && head.Status != INVCheckStatus.New)
            {
                this.cmdEdit.Visible = false;
            }
        }
        this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl;

        if (head != null && head.Status != INVCheckStatus.New)
        {
            WebUtil.DisableControl(this.drpLocation);
            WebUtil.DisableControl(this.txtNote);
        }
    }
Пример #22
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));
        }
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         try
         {
             using (ISession session = new Session())
             {
                 session.BeginTransaction();
                 try
                 {
                     for (int i = 0; i < this.rptSDHead.Items.Count; i++)
                     {
                         System.Web.UI.HtmlControls.HtmlInputCheckBox objCheckBox = this.rptSDHead.Items[i].FindControl("checkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
                         if (objCheckBox.Checked)
                         {
                             INVCheckHead.Delete(session, objCheckBox.Attributes["value"].Trim());
                         }
                     }
                     session.Commit();
                     QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
                 }
                 catch (Exception ex)
                 {
                     session.Rollback();
                     throw ex;
                 }
             }
         }
         catch (Exception ex)
         {
             WebUtil.ShowError(this, "删除失败,请与管理员联系!\r\n失败信息:" + ex.Message);
             return;
         }
     }
 }
Пример #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtInvCheckNumber.Text          = WebUtil.Param("ordNum");
            this.cmdReturn["Return"].NavigateUrl = WebUtil.Param("return");

            this.drpCheckType.Items.Clear();
            this.drpCheckType.Items.Add(new ListItem(ERPUtil.EnumText <INVCheckType>(INVCheckType.Explicit), INVCheckType.Explicit.ToString()));
            this.drpCheckType.Items.Add(new ListItem(ERPUtil.EnumText <INVCheckType>(INVCheckType.Implicit), INVCheckType.Implicit.ToString()));

            INVCheckHead head = null;
            using (ISession session = new Session())
            {
                this.LoadLocation(session);
                if (!this.IsNew)
                {
                    head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    this.LoadLocation(session);
                    this.SetView(session, head);
                }
            }
        }
    }
Пример #25
0
    private void SaveCheckOrder()
    {
        try
        {
            DataSet ds = Session["InvAdjustmentItem"] as DataSet;

            Dictionary <int, int> lstCurrentQuantity = new Dictionary <int, int>();
            for (int i = 0; i < this.rptInvCheck.Items.Count; i++)
            {
                TextBox objBox = this.rptInvCheck.Items[i].FindControl("txtCurrentQuantity") as TextBox;
                System.Web.UI.HtmlControls.HtmlInputHidden objSKU = this.rptInvCheck.Items[i].FindControl("hidSKUID") as System.Web.UI.HtmlControls.HtmlInputHidden;
                try
                {
                    lstCurrentQuantity.Add(Cast.Int(objSKU.Value), Cast.Int(objBox.Text));
                }
                catch (Exception ex)
                {
                    WebUtil.ShowMsg(this, "调整数量非法,请重新输入!");
                    return;
                }
            }

            using (_session = new Session())
            {
                _session.BeginTransaction();
                try
                {
                    INVCheckHead objHead = INVCheckHead.Retrieve(_session, this.txtInvCheckNumber.Text);

                    bool blnInsert = false;
                    if (objHead == null)
                    {
                        blnInsert             = true;
                        objHead               = new INVCheckHead();
                        objHead.CreateTime    = DateTime.Now;
                        objHead.CreateUser    = Magic.Security.SecuritySession.CurrentUser.UserId;
                        objHead.Note          = this.txtMemo.Text;
                        objHead.OrderNumber   = Magic.ERP.ERPUtil.NextOrderNumber(Magic.ERP.Orders.INVCheckHead.ORDER_TYPE_ADJ);
                        objHead.OrderTypeCode = INVCheckHead.ORDER_TYPE_ADJ;
                        objHead.Status        = Magic.ERP.INVCheckStatus.New;
                        objHead.Create(_session);
                    }
                    else
                    {
                        if ((objHead.Status == Magic.ERP.INVCheckStatus.Release) || (objHead.Status == Magic.ERP.INVCheckStatus.Close))
                        {
                            WebUtil.ShowMsg(this, "发布以后的盘点单不可以进行修改");
                            return;
                        }

                        objHead.Note = this.txtMemo.Text;
                        blnInsert    = false;
                        _session.CreateEntityQuery <INVCheckLine>().Where(Exp.Eq("OrderNumber", objHead.OrderNumber)).Delete();
                    }

                    objHead.CurrentLineNumber = "";


                    List <INVCheckLine> List = new List <INVCheckLine>();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        INVCheckLine objLine = new INVCheckLine();
                        objLine.SKUID        = Cast.Int(ds.Tables[0].Rows[i]["SKUID"]);
                        objLine.AreaCode     = Cast.String(ds.Tables[0].Rows[i]["AreaCode"]);
                        objLine.BeforeQty    = Cast.Decimal(ds.Tables[0].Rows[i]["BeforeQty"]);
                        objLine.CurrentQty   = lstCurrentQuantity[objLine.SKUID];
                        objLine.LineNumber   = objHead.NextLineNumber();
                        objLine.LocationCode = Cast.String(ds.Tables[0].Rows[i]["LocationCode"]);
                        objLine.OrderNumber  = objHead.OrderNumber;
                        objLine.SectionCode  = Cast.String(ds.Tables[0].Rows[i]["SectionCode"]);
                        objLine.Create(_session);
                    }

                    objHead.Update(_session, "CurrentLineNumber");

                    this.txtInvCheckNumber.Text = objHead.OrderNumber;
                    _session.Commit();
                }
                catch (Exception ex)
                {
                    _session.Rollback();
                    throw ex;
                }
            }
            WebUtil.ShowMsg(this, "库存盘点单保存成功", "操作成功");
        }
        catch (Exception ex)
        {
            logger.Info("保存库存盘点单", ex);
            WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
        }
    }
Пример #26
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            if (this.FileUpload1.FileName.Trim().Length <= 0)
            {
                WebUtil.ShowMsg(this, "请选择盘点结果文件");
                return;
            }
            string fileName = this.FileUpload1.FileName;
            if (!fileName.EndsWith(".xls"))
            {
                WebUtil.ShowMsg(this, "请选择有效的Excel文件");
                return;
            }
            string filePath = System.IO.Path.Combine(DownloadUtil.DownloadFolder, "CK_IMP_" + DateTime.Now.ToString("yyMMdd_HHmmss") + ".xls");
            this.FileUpload1.SaveAs(filePath);
            IList <INVCheckLine> lines = new List <INVCheckLine>();

            #region 读取文件
            ExcelApp       excelapp   = null;
            ExcelWorkbook  excelBook  = null;
            ExcelWorksheet excelSheet = null;
            try
            {
                excelapp = new ExcelApp();
                excelapp.DisplayAlerts = false;
                excelBook  = excelapp.Open(filePath, 0);
                excelSheet = excelBook.Worksheets(1);
                int     rowIndex = 2;
                string  lineNum  = Cast.String(excelSheet.Range(rowIndex, rowIndex, 1, 1).Value).Trim();
                decimal qty;
                while (lineNum.Length == 4)
                {
                    qty = Cast.Decimal(excelSheet.Range(rowIndex, rowIndex, 9, 9).Value, 0M);
                    INVCheckLine line = new INVCheckLine();
                    line.LineNumber = lineNum;
                    line.CurrentQty = qty;
                    lines.Add(line);
                    rowIndex++;
                    lineNum = Cast.String(excelSheet.Range(rowIndex, rowIndex, 1, 1).Value).Trim();
                }
            }
            catch (Exception er)
            {
                WebUtil.ShowError(this, er.Message);
                return;
            }
            finally
            {
                if (excelSheet != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet.COMObject);
                }
                if (excelBook != null)
                {
                    excelBook.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelBook.COMObject);
                }
                if (excelapp != null)
                {
                    excelapp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelapp.COMObject);
                }
            }
            #endregion

            using (ISession session = new Session())
            {
                try
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, WebUtil.Param("ordNum"));
                    if (head == null)
                    {
                        WebUtil.ShowError(this, "盘点单" + WebUtil.Param("ordNum") + "不存在");
                        return;
                    }
                    session.BeginTransaction();
                    head.ClearCheckQty(session);
                    head.UpdateLines(session, lines);
                    session.Commit();
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er.Message);
                    return;
                }
            }

            this.Response.Redirect(WebUtil.Param("return"));
        }
    }
Пример #27
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         #region  除
         using (ISession session = new Session())
         {
             try
             {
                 bool deleted = false;
                 session.BeginTransaction();
                 foreach (RepeaterItem item in this.repeatControl.Items)
                 {
                     HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                     if (chk.Checked)
                     {
                         log.DebugFormat("Delete - sto adj line: ordNum={0}, lineNum={1}", this.OrderNumber, chk.Value);
                         INVCheckLine.Delete(session, this.OrderNumber, chk.Value);
                         deleted = true;
                     }
                 }
                 session.Commit();
                 if (deleted)
                 {
                     this.QueryAndBindData(session, INVCheckHead.Retrieve(session, this.OrderNumber));
                     WebUtil.ShowMsg(this, "选择的明细已经删除");
                 }
             }
             catch (Exception er)
             {
                 session.Rollback();
                 log.Error("Error - delete sto adj line: ", er);
                 WebUtil.ShowError(this, er);
             }
         }
         #endregion
     }
     else if (e.CommandName == "Release")
     {
         #region 发布
         using (ISession session = new Session())
         {
             try
             {
                 INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                 session.BeginTransaction();
                 log.DebugFormat("Release - sto adj: {0}", this.OrderNumber);
                 head.Release(session);
                 session.Commit();
                 WebUtil.ShowMsg(this, "发布成功");
                 this.QueryAndBindData(session, head);
                 this.SetView(head);
             }
             catch (Exception er)
             {
                 session.Rollback();
                 log.Error("Error - release sto adj: ", er);
                 WebUtil.ShowError(this, er);
             }
         }
         #endregion
     }
     else if (e.CommandName == "Close")
     {
         #region 关闭
         using (ISession session = new Session())
         {
             try
             {
                 INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                 session.BeginTransaction();
                 log.DebugFormat("Close - sto adj: {0}", this.OrderNumber);
                 head.Close(session);
                 session.Commit();
                 WebUtil.ShowMsg(this, string.Format("库存调整单{0}已经关闭", this.OrderNumber));
                 this.QueryAndBindData(session, head);
                 this.SetView(head);
             }
             catch (Exception er)
             {
                 session.Rollback();
                 log.Error("Error - close sto adj: ", er);
                 WebUtil.ShowError(this, er);
             }
         }
         #endregion
     }
 }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        try
        {
            if (e.CommandName == "Add" && !string.IsNullOrEmpty(this.drpArea.SelectedValue))
            {
                #region 添加库位
                using (ISession session = new Session())
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    try
                    {
                        session.BeginTransaction();
                        head.AddArea(session, this.drpArea.SelectedValue);
                        session.Commit();

                        this.BindArea(session, head);
                        this.QueryAndBindData(session, head);
                    }
                    catch (Exception er1)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er1);
                        return;
                    }
                }
                #endregion
            }
            else if (e.CommandName == "Confirm")
            {
                #region 确定开始盘点作业
                bool success = false;
                using (ISession session = new Session())
                {
                    INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    try
                    {
                        session.BeginTransaction();
                        head.ConfirmCheckOrder(session);
                        session.Commit();
                        success = true;
                    }
                    catch (Exception er1)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er1);
                        return;
                    }
                }
                #endregion
                if (success)
                {
                    this.Response.Redirect("InventoryCheckDetail.aspx?ordNum=" + this.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")));
                }
            }
        }
        catch (Exception er)
        {
            WebUtil.ShowError(this, er);
        }
    }
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        try
        {
            if (e.CommandName == "Download")
            {
                #region  载
                DataSet      ds   = null;
                INVCheckHead head = null;
                using (ISession session = new Session())
                {
                    head = INVCheckHead.Retrieve(session, this.OrderNumber);
                    Magic.Framework.ORM.Query.ObjectQuery query = session.CreateObjectQuery(string.Format(@"
select l.LineNumber as LineNumber,l.AreaCode as AreaCode,l.SectionCode as SectionCode
    ,s.BarCode as SKU,m.ItemCode as ItemCode
    ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode
    ,{0} as BeforeQty,l.CurrentQty as CurrentQty,m.ItemName as ItemName
from INVCheckLine l
inner join ItemSpec s on l.SKUID=s.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
left join ItemColor color on color.ColorCode=s.ColorCode
where l.OrderNumber=?ordNum {1}
order by l.LineNumber"
                                                                                                          , head.CheckType == INVCheckType.Implicit && head.Status == INVCheckStatus.Confirm ? "'-'" : "l.BeforeQty"
                                                                                                          , this.drpViewType.SelectedValue == "2" ? "and l.BeforeQty<>l.CurrentQty" : ""))
                                                                  .Attach(typeof(INVCheckLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster))
                                                                  .Attach(typeof(ItemColor)).Attach(typeof(ItemSize))
                                                                  .SetValue("?ordNum", this.OrderNumber, "l.OrderNumber");
                    if (this.drpArea.SelectedValue.Trim().Length > 0)
                    {
                        query.And(Exp.Eq("l.AreaCode", this.drpArea.SelectedValue.Trim()));
                    }
                    if (this.txtSKU.Text.Trim().Length > 0)
                    {
                        query.And(Exp.Like("s.BarCode", "%" + this.txtSKU.Text.Trim() + "%"));
                    }
                    if (this.txtItemCode.Text.Trim().Length > 0)
                    {
                        query.And(Exp.Like("m.ItemCode", "%" + this.txtItemCode.Text.Trim() + "%"));
                    }
                    if (this.txtName.Text.Trim().Length > 0)
                    {
                        query.And(Exp.Like("m.ItemName", "%" + this.txtName.Text.Trim() + "%"));
                    }
                    if (this.txtColor.Text.Trim().Length > 0)
                    {
                        query.And(Exp.Like("s.ColorCode", "%" + this.txtColor.Text.Trim().ToUpper() + "%"));
                    }
                    if (this.txtSize.Text.Trim().Length > 0)
                    {
                        query.And(Exp.Like("s.SizeCode", "%" + this.txtSize.Text.Trim().ToUpper() + "%"));
                    }
                    ds = query.DataSet();
                }
                if (ds == null)
                {
                    WebUtil.ShowError(this, "没有数据下载或者下载出错了");
                    return;
                }

                string fileName = DownloadUtil.DownloadXls("StockCheck_" + DateTime.Now.ToString("yyMMdd") + ".xls", "CK",
                                                           new List <DownloadFormat>()
                {
                    new DownloadFormat(DataType.NumberText, "行号", "LineNumber"),
                    new DownloadFormat(DataType.Text, "库位", "AreaCode"),
                    new DownloadFormat(DataType.NumberText, "货架", "SectionCode"),
                    new DownloadFormat(DataType.NumberText, "SKU", "SKU"),
                    new DownloadFormat(DataType.NumberText, "货号", "ItemCode"),
                    new DownloadFormat(DataType.Text, "颜色", "ColorCode", "ColorText"),
                    new DownloadFormat(DataType.Text, "尺码", "SizeCode"),
                    new DownloadFormat((head.CheckType == INVCheckType.Implicit && head.Status == INVCheckStatus.Confirm ? DataType.Text : DataType.Number), "系统数量", "BeforeQty"),
                    new DownloadFormat(DataType.Number, "盘点数量", "CurrentQty"),
                    new DownloadFormat(DataType.Text, "商品名称", "ItemName")
                }, ds);
                this.frameDownload.Attributes["src"] = fileName;
                #endregion
            }
            else if (e.CommandName == "Save")
            {
                #region 保存
                using (ISession session = new Session())
                {
                    try
                    {
                        session.BeginTransaction();

                        foreach (RepeaterItem item in this.repeatControl.Items)
                        {
                            TextBox text = item.FindControl("txtQty") as TextBox;
                            if (text == null)
                            {
                                continue;
                            }
                            string lineNum = text.Attributes["lineNumber"];
                            if (string.IsNullOrEmpty(lineNum) || lineNum.Trim().Length <= 0)
                            {
                                continue;
                            }
                            INVCheckLine line = INVCheckLine.Retrieve(session, this.OrderNumber, lineNum);
                            if (line != null)
                            {
                                line.CurrentQty = Cast.Decimal(text.Text, line.CurrentQty);
                                line.Update(session, "CurrentQty");
                            }
                        }

                        session.Commit();
                        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
                    {
                        INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                        session.BeginTransaction();
                        head.Release(session);
                        session.Commit();
                        WebUtil.ShowMsg(this, "发布成功");
                        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
                    {
                        INVCheckHead head = INVCheckHead.Retrieve(session, this.OrderNumber);
                        session.BeginTransaction();
                        head.Close(session);
                        session.Commit();
                        WebUtil.ShowMsg(this, "关闭成功,本次盘点任务已经完成");
                        this.SetView(head);
                    }
                    catch (Exception er)
                    {
                        session.Rollback();
                        WebUtil.ShowError(this, er);
                    }
                }
                #endregion
            }
        }
        catch (Exception err)
        {
            WebUtil.ShowError(this, err);
        }
    }
    private void SetView(INVCheckHead head)
    {
        this.cmdReturn1["Return"].NavigateUrl = WebUtil.Param("return");
        this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");
        WebUtil.EnableControl(this.drpViewType);
        if (!IsPostBack)
        {
            this.drpViewType.ClearSelection();
            this.drpViewType.SelectedValue = "1";
        }
        if (head == null)
        {
            return;
        }
        #region 操作按钮
        switch (head.Status)
        {
        case INVCheckStatus.Confirm:
            this.cmdEdit1.Visible  = true;
            this.cmdEdit2.Visible  = true;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            if (head.CheckType == INVCheckType.Implicit)
            {
                WebUtil.DisableControl(this.drpViewType);
            }
            break;

        case INVCheckStatus.Release:
            this.cmdEdit1.Visible = false;
            this.cmdEdit2.Visible = false;
            if (head.ApproveResult == ApproveStatus.Approve)
            {
                this.cmdClose1.Visible = true;
                this.cmdClose2.Visible = true;
            }
            else
            {
                this.cmdClose1.Visible = false;
                this.cmdClose2.Visible = false;
            }
            if (!IsPostBack)
            {
                this.drpViewType.ClearSelection();
                this.drpViewType.SelectedValue = "2";
            }
            break;

        case INVCheckStatus.Close:
            this.cmdEdit1.Visible  = false;
            this.cmdEdit2.Visible  = false;
            this.cmdClose1.Visible = false;
            this.cmdClose2.Visible = false;
            if (!IsPostBack)
            {
                this.drpViewType.ClearSelection();
                this.drpViewType.SelectedValue = "2";
            }
            break;
        }
        #endregion
    }