private void QueryAndBindData(ISession session, ReturnHead head) { DataSet ds = session.CreateObjectQuery(@" select sku.BarCode As BarCode,sku.SizeCode As SizeCode ,i.ItemCode As ItemCode,i.ItemName As ItemName,sku.ColorCode As ColorCode,c.Name As ColorText ,st.Name As SaleType,rl.Price As Price,rl.Quantity As ReturnQty from ReturnHead rh inner join ReturnLine rl on rh.OrderNumber=rl.OrderNumber inner join ItemSpec sku on sku.SKUID=rl.SKUID inner join ItemMaster i on i.ItemCode=sku.ItemCode left join ItemColor c on c.ColorCode=sku.ColorCode left join CRMSN sn on sn.ID=rh.RefOrderID left join CRMSNLine snl on snl.SNID=sn.ID and snl.ID=rl.RefOrderLineID left join CRMSaleType st on st.ID=snl.SellType where rh.OrderNumber=?ordNum order by rl.LineNumber") .Attach(typeof(ReturnHead)).Attach(typeof(ReturnLine)) .Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor)) .Attach(typeof(CRMSN)).Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType)) .SetValue("?ordNum", head.OrderNumber, "rh.OrderNumber") .DataSet(); ds.Tables[0].Columns.Add("INDEX", typeof(int)); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) ds.Tables[0].Rows[i]["INDEX"] = i + 1; this.txtLineCount.Value = ds.Tables[0].Rows.Count.ToString(); this.repeatControl.DataSource = ds; this.repeatControl.DataBind(); }
public static bool Delete(ISession session, string orderNumber) { if (string.IsNullOrEmpty(orderNumber) || orderNumber.Trim().Length <= 0) { return(false); } ReturnHead head = Retrieve(session, orderNumber); if (head == null) { return(false); } return(head.Delete(session)); }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { ReturnHead head = null; if (this.IsNew) { head = new ReturnHead(); try { head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("LogisReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("LogisReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } try { head = ReturnHead.Retrieve(session, this.OrderNumber); head.LogisReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chkIsMalicious.Checked, this.chkHasTransported.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); session.BeginTransaction(); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID", "HasTransported"); session.Commit(); WebUtil.ShowMsg(this, "保存成功"); } catch (Exception er2) { session.Rollback(); WebUtil.ShowError(this, er2); } } } }
private void SetView(ReturnHead head) { switch (head.Status) { case ReturnStatus.New: this.cmdEdit1.Visible = true; this.cmdEdit2.Visible = true; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; case ReturnStatus.Release: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; case ReturnStatus.Open: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = true; this.cmdClose2.Visible = true; break; case ReturnStatus.Close: this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; } }
private void QueryAndBindData(ISession session, ReturnHead head) { this.repeatControl.DataSource = session.CreateObjectQuery(@" select rtl.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 ,st.Name as SaleType,snl.Price as Price,snl.Quantity as ShippingQty ,rtl.Quantity as ReturnQty,rtl.AreaCode as AreaCode,rtl.SectionCode as SectionCode from ReturnLine rtl inner join CRMSNLine snl on rtl.RefOrderLineID=snl.ID inner join ItemSpec s on s.SKUID=rtl.SKUID inner join ItemMaster m on m.ItemID=s.ItemID left join ItemColor color on color.ColorCode=s.ColorCode left join CRMSaleType st on st.ID=snl.SellType where rtl.OrderNumber=?ordNum order by rtl.LineNumber") .Attach(typeof(ReturnLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor)) .Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType)) .SetValue("?ordNum", this.OrderNumber, "rtl.OrderNumber") .DataSet(); this._session = session; this._head = head; this.repeatControl.DataBind(); this._head = null; this._session = null; }
private void QueryAndBindData(ISession session, ReturnHead head) { DataSet ds = session.CreateObjectQuery(@" select snl.ID as SNDID,s.BarCode as BarCode,m.ItemCode as ItemCode,m.ItemName as ItemName ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode ,st.Name as SaleType,snl.Price as Price,snl.Quantity as ShippingQty,rtl.Quantity as ReturnQty from ReturnHead rth inner join CRMSNLine snl on rth.RefOrderID=snl.SNID inner join ItemSpec s on s.SKUID=snl.SKUID inner join ItemMaster m on m.ItemID=s.ItemID left join ReturnLine rtl on rtl.OrderNumber=rth.OrderNumber and rtl.RefOrderLineID=snl.ID left join ItemColor color on color.ColorCode=s.ColorCode left join CRMSaleType st on st.ID=snl.SellType where rth.OrderNumber=?ordNum order by snl.ID") .Attach(typeof(ReturnHead)).Attach(typeof(ReturnLine)) .Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster)).Attach(typeof(ItemColor)) .Attach(typeof(CRMSNLine)).Attach(typeof(CRMSaleType)) .SetValue("?ordNum", this.OrderNumber, "rtl.OrderNumber") .DataSet(); ds.Tables[0].Columns.Add("INDEX", typeof(int)); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) ds.Tables[0].Rows[i]["INDEX"] = i + 1; this.repeatControl.DataSource = ds; this.repeatControl.DataBind(); }
private void showInfo(ISession session, ReturnHead head) { User user; if (head != null) { this.txtOrderNumber.Text = head.OrderNumber; this.drpLocation.SelectedValue = head.LocationCode; this.txtSNNumber.Text = head.RefOrderNumber; this.drpReason.SelectedValue = head.ReasonID.ToString(); this.chkIsMalicious.Checked = head.IsMalicious; this.chkHasTransported.Checked = head.HasTransported; this.txtNote.Text = head.Note; 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; } }
private void setView(ReturnHead head) { if (!this.IsNew && head != null && head.Status != ReturnStatus.New) { WebUtil.DisableControl(this.txtNote); WebUtil.DisableControl(this.drpLocation); WebUtil.DisableControl(this.txtSNNumber); WebUtil.DisableControl(this.drpReason); WebUtil.DisableControl(this.chkIsMalicious); this.cmdEdit.Visible = false; } this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl; }
private void QueryAndBindData(ISession session, ReturnHead head) { DbSession dbsession = session.DbSession as DbSession; IDbCommand cmd = dbsession.CreateSqlStringCommand(@" select /*+ ordered use_nl(snl s) use_nl(s m) use_nl(snl rth) index(rtl pk_ord_rtn_line) use_nl(color s) use_nl(st snl) */ snl.Id As SNDID,s.ITM_BARCODE As BarCode ,m.ITM_CODE As ItemCode,m.ITM_NAME As ItemName,s.COLOR_CODE As ColorCode,color.Name As ColorText ,s.SIZE_CODE As SizeCode ,st.Name As SaleType,snl.PRICE As Price,snl.QUANTITY As ShippingQty ,sum(rtl.RTN_QTY) As ReturnQty from ORD_SHIPPINGNOTICE_LINES snl inner join PRD_ITEM_SKU s on s.SKU_ID=snl.SKU_ID inner join PRD_ITEM m on m.itm_code=s.itm_code Left join ORD_RTN_HEAD rth on rth.REF_ORD_ID=snl.SN_ID left join ORD_RTN_LINE rtl on rtl.ORD_NUM=rth.ORD_NUM and rtl.REF_ORD_LINE_ID=snl.ID left join PRD_ITEM_COLOR color on color.CODE=s.COLOR_CODE Left join S_SELL_TYPE st on st.ID=snl.SELL_TYPE where snl.sn_id=:snid Group By snl.Id,s.ITM_BARCODE,m.ITM_CODE,m.ITM_NAME,s.COLOR_CODE,color.Name,s.SIZE_CODE ,st.Name,snl.PRICE,snl.QUANTITY order by snl.Id"); dbsession.AddParameter(cmd, ":snid", EntityManager.GetPropMapping(typeof(ReturnHead), "RefOrderID").DbTypeInfo, head.RefOrderID); DataSet ds = dbsession.ExecuteDataSet(cmd); ds.Tables[0].Columns.Add("INDEX", typeof(int)); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) ds.Tables[0].Rows[i]["INDEX"] = i + 1; this.repeatControl.DataSource = ds; this.repeatControl.DataBind(); }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { ReturnHead head = null; #region 更新退货单的情况 if (!this.IsNew) { head = ReturnHead.Retrieve(session, this.txtOrderNumber.Text.Trim()); if (head == null) { WebUtil.ShowError(this, "退货单" + this.txtOrderNumber.Text.Trim() + "不存在"); return; } if (head.Status != ReturnStatus.New) { WebUtil.ShowError(this, "退货单" + head.OrderNumber + "不是新建状态,无法更新"); return; } try { session.BeginTransaction(); if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_MBR_RTN) { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText", "IsMalicious", "RefOrderID", "RefOrderNumber", "OrginalOrderNumber", "LogisticsName", "LogisticsID", "MemberName", "MemberID"); } else { head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text, 0); head.Update(session, "Note", "LocationCode", "ReasonID", "ReasonText"); } session.Commit(); WebUtil.ShowMsg(this, "保存成功"); } catch (Exception er2) { session.Rollback(); WebUtil.ShowError(this, er2); } return; } #endregion //根据发货单查询是否存在退货单,2个作用 //1. 换货的情况下,创建换货订单同时已经创建了换货退货单,这种情况要更新一下换货退货单资料(仓库、退货原因、备注)而不用新增 //2. 目前不允许一个订单多次退货,即发货单如果已经用于创建退货单,则不再允许创建第2个了 IList<ReturnHead> heads = ReturnHead.QueryBySNNumber(session, this.txtSNNumber.Text.Trim()); #region 从来没有(会员退货、物流退货、内部退货),允许退货,以下代码创建新的会员退货单 if (heads.Count <= 0) { head = new ReturnHead(); try { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } #endregion int countOfNewChangeReturn = this.CountOfNewChangeReturn(heads); #region 有新建状态的换货单,直接调出该换货单,更新其资料,更新完后跳转到退货扫描界面 //如果已经部分退货过一次,下面的代码允许继续换货 if (countOfNewChangeReturn > 0) { foreach (ReturnHead h in heads) if (h.Status == ReturnStatus.New && h.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN) { head = h; break; } if (head != null) { try { head.ExchangeReturn(session, this.drpLocation.SelectedValue, Cast.Int(this.drpReason.SelectedValue), this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); session.BeginTransaction(); head.Update(session, "LocationCode", "ReasonID", "ReasonText", "Note"); session.Commit(); this.Response.Redirect("ExchangeReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")))); return; } catch (Exception er5) { session.Rollback(); WebUtil.ShowError(this, er5); } } return; } #endregion #region 如果有未完成的退货单,必须完成后才可以新建另外的退货 foreach (ReturnHead h in heads) { if (h.Status != ReturnStatus.Close) { WebUtil.ShowError(this, "与发货单" + h.RefOrderNumber + "相关的退货单" + h.OrderNumber + "还没有完成,无法创建另外的退货单"); return; } } #endregion #region 如果没有创建过任何会员退货、物流退货、内部退货,则允许创建一个(这几种退货只能退一次) if (this.IsAllChangeReturn(heads)) { head = new ReturnHead(); try { head.MemberReturn(session, this.drpLocation.SelectedValue, this.txtSNNumber.Text, Cast.Int(this.drpReason.SelectedValue, 0), this.chk.Checked, this.txtNote.Text.Trim(), SecuritySession.CurrentUser.UserId); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); session.BeginTransaction(); head.Create(session); session.Commit(); this.Response.Redirect("MemberReturnScan.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("MemberReturnLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(this.ReturnUrl))); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } #endregion #region 其它情况将无法再创建会员退货单 if (this.IsNew) { WebUtil.ShowError(this, "同一个订单(发货单)不允许多次退货,系统无法再创建退货单"); return; } #endregion } } }
private void setView(ReturnHead head) { if (!this.IsNew && head != null && head.Status != ReturnStatus.New) { WebUtil.DisableControl(this.txtNote); WebUtil.DisableControl(this.drpLocation); WebUtil.DisableControl(this.txtSNNumber); WebUtil.DisableControl(this.drpReason); WebUtil.DisableControl(this.chk); this.cmdEdit.Visible = false; } else if (head != null && head.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN) { //换货退货单,不允许修改发货单号码 WebUtil.DisableControl(this.txtSNNumber); WebUtil.DisableControl(this.chk); } this.cmdReturn["Return"].NavigateUrl = this.ReturnUrl; }
private void SetView(ReturnHead head) { switch (head.Status) { case ReturnStatus.New: this.cmdScan1.Visible = true; this.cmdScan2.Visible = true; this.cmdEdit1.Visible = true; this.cmdEdit2.Visible = true; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; case ReturnStatus.Release: this.cmdScan1.Visible = false; this.cmdScan2.Visible = false; this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; case ReturnStatus.Open: this.cmdScan1.Visible = false; this.cmdScan2.Visible = false; this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = true; this.cmdClose2.Visible = true; break; case ReturnStatus.Close: this.cmdScan1.Visible = false; this.cmdScan2.Visible = false; this.cmdEdit1.Visible = false; this.cmdEdit2.Visible = false; this.cmdClose1.Visible = false; this.cmdClose2.Visible = false; break; } if (head.OrderTypeCode == ReturnHead.ORDER_TYPE_EXCHANGE_RTN && head.HasScaned) { this.cmdScan1.Visible = false; this.cmdScan2.Visible = false; } }