protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { StockInHead head = null; if (this.IsNew) { head = new StockInHead(); head.OrderTypeCode = StockInHead.ORD_TYPE_PRD_IN; head.Status = StockInStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.RefOrdNum = this.txtRefOrdNum.Text.Trim().ToUpper(); try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); head.AddPrdOutDetail2ThisOrder(session); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } this.Response.Redirect("ProductInLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); return; } head = StockInHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.RefOrdNum = this.txtRefOrdNum.Text.Trim().ToUpper(); head.Update(session, "Note", "LocationCode", "RefOrdNum"); //没有明细时,才考虑将库存领用明细添加进来 if (session.CreateEntityQuery<StockInLine>() .Where(Magic.Framework.ORM.Query.Exp.Eq("OrderNumber", head.OrderNumber)) .Count() <= 0) head.AddPrdOutDetail2ThisOrder(session); this.Response.Redirect("ProductInLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { StockInHead head = null; if (this.IsNew) { head = new StockInHead(); head.OrderTypeCode = StockInHead.ORD_TYPE_ASSIST_IN; head.Status = StockInStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); session.Commit(); this.txtAction.Value = "edit"; this.txtId.Value = head.OrderNumber; this.showInfo(session, head); this.setView(head); WebUtil.ShowMsg(this, string.Format("入库单{0}创建成功", head.OrderNumber)); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } return; } head = StockInHead.Retrieve(session, this.OrderNumber); head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.Update(session, "Note", "LocationCode"); WebUtil.ShowMsg(this, "保存成功"); } } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName == "Save") { using (ISession session = new Session()) { StockInHead head = null; if (this.IsNew) { head = new StockInHead(); head.OrderTypeCode = StockInHead.ORD_TYPE_PRD_OUT; head.Status = StockInStatus.New; head.ApproveResult = ApproveStatus.UnApprove; head.ApproveUser = 0; head.ApproveTime = new DateTime(1900, 1, 1); head.CreateUser = SecuritySession.CurrentUser.UserId; head.CreateTime = DateTime.Now; head.Note = this.txtNote.Text.Trim(); head.Responsible = this.txtResponsible.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; try { session.BeginTransaction(); head.OrderNumber = ERPUtil.NextOrderNumber(head.OrderTypeCode); head.Create(session); session.Commit(); } catch (Exception er) { session.Rollback(); WebUtil.ShowError(this, er); } this.Response.Redirect("ProductOutNewLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape("ProductOutLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return")))); return; } head = StockInHead.Retrieve(session, this.OrderNumber); head.Responsible = this.txtResponsible.Text.Trim(); head.Note = this.txtNote.Text.Trim(); head.LocationCode = this.drpLocation.SelectedValue; head.Update(session, "Note", "LocationCode"); this.Response.Redirect("ProductOutLine.aspx?ordNum=" + head.OrderNumber + "&return=" + WebUtil.escape(WebUtil.Param("return"))); } } }