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 - ÒÆ¿âÃ÷ϸ: ordNum={0}, lineNum={1}", this.OrderNumber, chk.Value); WHTransferLine.Delete(session, this.OrderNumber, chk.Value); deleted = true; } } session.Commit(); this.QueryAndBindData(session, WHTransferHead.Retrieve(session, this.OrderNumber)); WebUtil.ShowMsg(this, "Ñ¡ÔñµÄÃ÷ϸÒѾɾ³ý"); } catch (Exception er) { session.Rollback(); log.Error("Error - ɾ³ýÒÆ¿âÃ÷ϸ: ", er); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Release") { #region ·¢²¼ using (ISession session = new Session()) { try { session.BeginTransaction(); WHTransferHead head = WHTransferHead.Retrieve(session, this.OrderNumber); log.DebugFormat("Release - ÒÆ¿âµ¥: {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 - ÒÆ¿âµ¥: ", er); WebUtil.ShowError(this, er); } } #endregion } else if (e.CommandName == "Close") { #region ¹Ø±Õ using (ISession session = new Session()) { try { WHTransferHead head = WHTransferHead.Retrieve(session, this.OrderNumber); session.BeginTransaction(); log.DebugFormat("Close - ÒÆ¿âµ¥: {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 - ÒÆ¿âµ¥: ", er); WebUtil.ShowError(this, er); } } #endregion } }
protected void MagicItemCommand(object sender, MagicItemEventArgs e) { if (e.CommandName != "Save") { return; } using (ISession session = new Session()) { try { IList <WHTransferLine> lines = new List <WHTransferLine>(); WHTransferHead head = WHTransferHead.Retrieve(session, this.OrderNumber); foreach (RepeaterItem item in this.repeatControl.Items) { TextBox text = item.FindControl("txtMoveQty") as TextBox; decimal qty = Cast.Decimal(text.Text, 0M); if (qty <= 0M) { continue; } WHTransferLine line = new WHTransferLine(); line.MoveQty = qty; HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; line.FromStockID = Cast.Int(chk.Value); HtmlInputText input = item.FindControl("hidTransferQty") as HtmlInputText; qty = Cast.Decimal(input.Value, 0M); if (line.MoveQty > qty) { WebUtil.ShowError(this, "ÒÆ¿âÁ¿±ØÐëСÓÚ»òµÈÓÚ¿ÉÒÆ¿âÁ¿"); return; } DropDownList drp = item.FindControl("drpToArea") as DropDownList; line.ToArea = drp.SelectedValue; text = item.FindControl("txtToSection") as TextBox; line.ToSection = text.Text.Trim(); lines.Add(line); } if (lines.Count <= 0) { log.Debug("Save - ÒÆ¿âÃ÷ϸ: ûÓÐÌîдÒÆ¿âÊýÁ¿£¬Î´Ìí¼ÓÃ÷ϸ"); return; } session.BeginTransaction(); head.AddLines(session, lines); session.Commit(); log.DebugFormat("Save - ÒÆ¿âÃ÷ϸ: ×ܹ²Ìí¼ÓÁË{0}¸öÒÆ¿âÃ÷ϸ", lines.Count); WebUtil.ShowMsg(this, "ÒѾ´´½¨ÒÆ¿âÃ÷ϸ"); this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true); } catch (Exception er) { log.Error("Save - ÒÆ¿âÃ÷ϸ: ", er); session.Rollback(); WebUtil.ShowError(this, er); } } }