protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName != "Save") return; using (ISession session = new Session()) { try { IList<StockInLine> lines = new List<StockInLine>(); StockInHead head = StockInHead.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; StockInLine line = new StockInLine(); line.OrderNumber = this.OrderNumber; line.StockDetailID = Cast.Int(chk.Value); line.LineNumber = Cast.String(chk.Attributes["line"]); line.Quantity = qty; line.Price = 0M; lines.Add(line); } if (lines.Count <= 0) { log.Debug("Save - assist item req line: no lines need to be saved"); return; } session.BeginTransaction(); head.CreateOrUpdateLines(session, lines); session.Commit(); log.DebugFormat("Save - assist item req 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 assist item req line: ", er); session.Rollback(); WebUtil.ShowError(this, er); } } }
//将产品领用单明细添加到产品入库单中 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 void UpdateLines(ISession session, IList <StockInLine> lines2Save) { if (lines2Save == null || lines2Save.Count <= 0) { return; } #region 检查 if (this._status != StockInStatus.New) { throw new Exception("单据不是新建状态,无法更新"); } IList <StockInLine> lines = new List <StockInLine>(lines2Save.Count); bool error = false, errorHead = false; System.Text.StringBuilder builder = new System.Text.StringBuilder(); foreach (StockInLine item in lines2Save) { errorHead = false; if (item.Quantity <= 0M) { error = true; if (!errorHead) { builder.Append("行号").Append(item.LineNumber).Append(": "); } errorHead = true; builder.Append("数量无效; "); } if (this._orderTypeCode == StockInHead.ORD_TYPE_ASSIST_IN) { if (string.IsNullOrEmpty(item.AreaCode) || item.AreaCode.Trim().Length <= 0) { error = true; if (!errorHead) { builder.Append("行号").Append(item.LineNumber).Append(": "); } errorHead = true; builder.Append("仓库为空; "); } if (!string.IsNullOrEmpty(item.SectionCode) && item.SectionCode.Trim().Length > 0) { WHSection section = WHSection.Retrieve(session, item.AreaCode, item.SectionCode); if (section == null) { error = true; if (!errorHead) { builder.Append("行号").Append(item.LineNumber).Append(": "); } errorHead = true; builder.Append("货架{").Append(item.AreaCode).Append("-").Append(item.SectionCode).Append("}不存在; "); } } } else if (this._orderTypeCode == StockInHead.ORD_TYPE_ASSIST_OUT) { if (item.Quantity > item.RefQuantity) { error = true; if (!errorHead) { builder.Append("行号").Append(item.LineNumber).Append(": "); } errorHead = true; builder.Append("领用数量大于库存数量; "); } } if (!error) { lines.Add(StockInLine.Retrieve(session, item.OrderNumber, item.LineNumber)); } } if (error) { throw new Exception(builder.ToString()); } #endregion for (int i = 0; i < lines.Count; i++) { StockInLine line = lines[i]; if (this._orderTypeCode == StockInHead.ORD_TYPE_ASSIST_IN) { line.AreaCode = lines2Save[i].AreaCode; line.SectionCode = lines2Save[i].SectionCode; line.Quantity = lines2Save[i].Quantity; line.Price = lines2Save[i].Price; line.Update(session, "AreaCode", "SectionCode", "Quantity", "Price"); } else { line.Quantity = lines2Save[i].Quantity; line.Update(session, "Quantity"); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { #region ���� IList<StockInLine> linesToSave = new List<StockInLine>(); foreach (RepeaterItem item in this.repeatControl.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; DropDownList drp = item.FindControl("drpArea") as DropDownList; TextBox text; StockInLine line = new StockInLine(); line.OrderNumber = this.OrderNumber; line.LineNumber = chk.Value.Trim(); line.AreaCode = drp.SelectedValue; text = item.FindControl("txtSection") as TextBox; line.SectionCode = text.Text.Trim(); text = item.FindControl("txtQualifiedQty") as TextBox; line.Quantity = Cast.Decimal(text.Text.Trim()); text = item.FindControl("txtPrice") as TextBox; line.Price = Cast.Decimal(text.Text.Trim()); linesToSave.Add(line); } using (ISession session = new Session()) { try { //��� StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); if (head == null) return; head.UpdateLines(session, linesToSave); WebUtil.ShowMsg(this, "����ɹ�"); } catch (Exception er) { 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 { session.BeginTransaction(); StockInHead head = StockInHead.Retrieve(session, this.OrderNumber); head.Release(session); session.Commit(); WebUtil.ShowMsg(this, "�����ɹ�"); this.QueryAndBindData(session, head); this.SetView(head); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Close") { #region �ر� using (ISession session = new Session()) { try { 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 } }
//����Ʒ���õ���ϸ��ӵ���Ʒ��ⵥ�� 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; }
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 } }