//将产品领用单明细添加到产品入库单中 public void AddPrdOutDetail2ThisOrder(ISession session) { if (this.OrderTypeCode != ORD_TYPE_PRD_IN) { throw new Exception("只有产品入库单可以执行该方法"); } if (string.IsNullOrEmpty(this.RefOrdNum) || this.RefOrdNum.Trim().Length <= 0) { return; } StockInHead refHead = StockInHead.Retrieve(session, this.RefOrdNum); if (refHead == null) { throw new Exception(""); } IList <StockInLine> refLines = session.CreateEntityQuery <StockInLine>() .Where(Exp.Eq("OrderNumber", this.RefOrdNum)) .List <StockInLine>(); if (refLines.Count <= 0) { return; } foreach (StockInLine refLine in refLines) { StockInLine line = new StockInLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.LocationCode = refLine.LocationCode; line.AreaCode = refLine.AreaCode; line.SectionCode = refLine.SectionCode; line.StockDetailID = refLine.StockDetailID; line.SKUID = refLine.SKUID; line.Quantity = refLine.Quantity; line.Price = refLine.Price; line.RefQuantity = 0M; line.UnitID = 0; line.Create(session); } this.Update(session, "CurrentLineNumber"); }
public int AddLines(ISession session, string[] skus) { StockInLine line; if (skus == null | skus.Length <= 0) { return(0); } int count = 0; if (this._orderTypeCode == ORD_TYPE_ASSIST_IN) { foreach (string s in skus) { int skuId = Magic.Framework.Utils.Cast.Int(s, 0); if (skuId <= 0) { continue; } line = new StockInLine(); line.OrderNumber = this._orderNumber; line.LineNumber = this.NextLineNumber(); line.SKUID = skuId; line.UnitID = 0; line.LocationCode = this._locationCode; line.AreaCode = ""; line.SectionCode = ""; line.Quantity = 0M; line.Price = 0M; line.Create(session); count++; } } else { foreach (string s in skus) { string[] temp = s.Split(','); if (temp == null || temp.Length != 4) { continue; } int skuId = Magic.Framework.Utils.Cast.Int(temp[0], 0); if (skuId <= 0) { continue; } line = new StockInLine(); line.OrderNumber = this._orderNumber; line.LineNumber = this.NextLineNumber(); line.SKUID = skuId; line.UnitID = 0; line.LocationCode = this._locationCode; line.AreaCode = temp[1]; line.SectionCode = temp[2]; line.RefQuantity = Magic.Framework.Utils.Cast.Decimal(temp[3]); line.Quantity = 0M; line.Price = 0M; line.Create(session); count++; } } this.Update(session, "CurrentLineNumber"); return(count); }
public int AddLines(ISession session, string[] skus) { StockInLine line; if (skus == null | skus.Length <= 0) return 0; int count = 0; if (this._orderTypeCode == ORD_TYPE_ASSIST_IN) { foreach (string s in skus) { int skuId = Magic.Framework.Utils.Cast.Int(s, 0); if (skuId <= 0) continue; line = new StockInLine(); line.OrderNumber = this._orderNumber; line.LineNumber = this.NextLineNumber(); line.SKUID = skuId; line.UnitID = 0; line.LocationCode = this._locationCode; line.AreaCode = ""; line.SectionCode = ""; line.Quantity = 0M; line.Price = 0M; line.Create(session); count++; } } else { foreach (string s in skus) { string[] temp = s.Split(','); if (temp == null || temp.Length != 4) continue; int skuId = Magic.Framework.Utils.Cast.Int(temp[0], 0); if (skuId <= 0) continue; line = new StockInLine(); line.OrderNumber = this._orderNumber; line.LineNumber = this.NextLineNumber(); line.SKUID = skuId; line.UnitID = 0; line.LocationCode = this._locationCode; line.AreaCode = temp[1]; line.SectionCode = temp[2]; line.RefQuantity = Magic.Framework.Utils.Cast.Decimal(temp[3]); line.Quantity = 0M; line.Price = 0M; line.Create(session); count++; } } this.Update(session, "CurrentLineNumber"); return count; }
//����Ʒ���õ���ϸ��ӵ���Ʒ��ⵥ�� public void AddPrdOutDetail2ThisOrder(ISession session) { if (this.OrderTypeCode != ORD_TYPE_PRD_IN) throw new Exception("ֻ�в�Ʒ��ⵥ����ִ�и÷���"); if (string.IsNullOrEmpty(this.RefOrdNum) || this.RefOrdNum.Trim().Length <= 0) return; StockInHead refHead = StockInHead.Retrieve(session, this.RefOrdNum); if (refHead == null) throw new Exception(""); IList<StockInLine> refLines = session.CreateEntityQuery<StockInLine>() .Where(Exp.Eq("OrderNumber", this.RefOrdNum)) .List<StockInLine>(); if (refLines.Count <= 0) return; foreach (StockInLine refLine in refLines) { StockInLine line = new StockInLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.LocationCode = refLine.LocationCode; line.AreaCode = refLine.AreaCode; line.SectionCode = refLine.SectionCode; line.StockDetailID = refLine.StockDetailID; line.SKUID = refLine.SKUID; line.Quantity = refLine.Quantity; line.Price = refLine.Price; line.RefQuantity = 0M; line.UnitID = 0; line.Create(session); } this.Update(session, "CurrentLineNumber"); }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { #region ���� using (ISession session = new Session()) { IList<StockInLine> linesToSave = new List<StockInLine>(); System.Text.StringBuilder error = new System.Text.StringBuilder(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; TextBox text; StockInLine line = StockInLine.Retrieve(session, this.OrderNumber, chk.Value); text = item.FindControl("txtQty") as TextBox; line.Quantity = Cast.Decimal(text.Text.Trim()); text = item.FindControl("txtSec") as TextBox; line.SectionCode = text.Text.Trim(); DropDownList drp = item.FindControl("drpArea") as DropDownList; line.AreaCode = drp.SelectedValue; if (string.IsNullOrEmpty(line.AreaCode) || line.AreaCode.Trim().Length <= 0) error.Append(chk.Attributes["sku"]).Append("δѡ���λ;"); else if (!string.IsNullOrEmpty(line.SectionCode) && line.SectionCode.Trim().Length > 0) { WHSection section = WHSection.Retrieve(session, line.AreaCode, line.SectionCode); if (section == null) error.Append(chk.Attributes["sku"]) .Append("��λ").Append(line.AreaCode).Append("�в����ڻ���").Append(line.SectionCode).Append(";"); } linesToSave.Add(line); } if (error.Length > 0) { WebUtil.ShowError(this, error.ToString()); return; } try { //��� StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); if (head == null) return; session.BeginTransaction(); head.CreateOrUpdateLines(session, linesToSave); session.Commit(); WebUtil.ShowMsg(this, "����ɹ�"); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Delete") { #region ɾ�� using (ISession session = new Session()) { try { session.BeginTransaction(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; if (chk.Checked) { StockInLine line = StockInLine.Retrieve(session, this.OrderNumber, chk.Value.Trim()); if (line != null) line.Delete(session); } } session.Commit(); this.QueryAndBindData(session, null); WebUtil.ShowMsg(this, "ѡ�����ϸ�Ѿ�ɾ��"); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Release") { #region ���� using (ISession session = new Session()) { try { StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); session.BeginTransaction(); head.Release(session); session.Commit(); WebUtil.ShowMsg(this, "�����ɹ�"); this.QueryAndBindData(session, head); this.SetView(head); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Close") { #region �ر� using (ISession session = new Session()) { try { StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); if (head == null) return; session.BeginTransaction(); head.Close(session); session.Commit(); WebUtil.ShowMsg(this, "��Ʒ��ⵥ" + head.OrderNumber + "�Ѿ����"); this.QueryAndBindData(session, head); this.SetView(head); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Add") { #region �����ϸ using (ISession session = new Session()) { ItemSpec sku = ItemSpec.Retrieve(session, this.txtSku.Text.Trim().ToUpper()); if (sku == null) { WebUtil.ShowError(this, "SKU: "+this.txtSku.Text.Trim()+"������"); return; } StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); StockInLine line = new StockInLine(); line.OrderNumber = this.OrderNumber; line.LocationCode = head.LocationCode; line.LineNumber = head.NextLineNumber(); line.AreaCode = ""; line.SectionCode = ""; line.Price = sku.AvgMoveCost; line.Quantity = 0M; line.RefQuantity = 0M; line.SKUID = sku.SKUID; line.StockDetailID = 0; line.UnitID = 0; bool isError = false; try { session.BeginTransaction(); line.Create(session); head.Update(session, "CurrentLineNumber"); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); isError = true; } if (!isError) { this.txtSku.Text = ""; this.QueryAndBindData(session, head); this.SetView(head); } } #endregion } }