📄 materielstout.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Botheighten.Yanghui.BusinessFacade;
using Botheighten.Yanghui.Framework;
using Botheighten.Yanghui.BusinessRules;
using Botheighten.Yanghui.Web.Controls;
namespace Botheighten.Yanghui.Web
{
/// <summary>
/// MaterielSTOut 的摘要说明。
/// </summary>
public class MaterielSTOut : BasePage
{
protected System.Web.UI.WebControls.Label lblTitle;
protected System.Web.UI.WebControls.DataGrid grid;
protected System.Web.UI.WebControls.ValidationSummary ErrorSummary;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Button btnIn;
protected System.Web.UI.WebControls.Button btnGoBack;
protected System.Web.UI.WebControls.Label Label1;
protected Instruction_C Instruction_C1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Principal p=this.CurrentUser();
this.CheckPermissionPage(p.Id,"","204");
this.lblMessage.Visible=false;
this.btnIn.Attributes.Add("onClick","if(confirm('请检查一下[领料数量]是否正确?')){if(typeof(Page_ClientValidate)== 'function'){Page_ClientValidate();}}else{return false;}");
if(!Page.IsPostBack)
{
string iid="";
if(Request.QueryString["ID"]!=null)
iid=Request.QueryString["ID"].ToString();
this.ViewState["ID"]=iid;
this.InitPage();
}
}
private void InitPage()
{
Instruction_C1.OrderHeadId =this.ViewState["ID"].ToString();
Instruction_C1.Bind();
DataTable dt=InstructionSystem.AllInstructionDet(this.ViewState["ID"].ToString());
Common.ReSet(this.grid,dt.DefaultView);
this.grid.DataSource=dt;
this.grid.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.grid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.grid_ItemDataBound);
this.btnIn.Click += new System.EventHandler(this.btnIn_Click);
this.btnGoBack.Click += new System.EventHandler(this.btnGoBack_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void grid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
double max=double.Parse(e.Item.Cells[2].Text.ToString())-double.Parse(e.Item.Cells[3].Text.ToString());
RangeValidator rv=(RangeValidator)e.Item.FindControl("RangeInNums");
string mid=e.Item.Cells[0].Text.Trim();
double acQ=InventorySystem.GetInventorys(mid);
if(max>acQ)
{
e.Item.ForeColor=Color.Red;
rv.MaximumValue=acQ.ToString();
rv.ErrorMessage +=acQ.ToString();
((TextBox)e.Item.FindControl("txtInNums")).Text =acQ.ToString();
}
else
{
//取消对最大值的控制 ,因为可以多领物料,生产后进行退料
// rv.MaximumValue=max.ToString();
// rv.ErrorMessage +=max.ToString();
((TextBox)e.Item.FindControl("txtInNums")).Text =max.ToString();
}
e.Item.Cells[4].Text = InventorySystem.GetInventorys(mid).ToString();
e.Item.Cells[6].Text = Common.GetHtmlCode(MaterielSystem.GetMaterielLocations(mid));
e.Item.Cells[0].Text = MaterielSystem.GetMaterielCode(mid);
}
}
private void btnIn_Click(object sender, System.EventArgs e)
{
MaterielOutTransaction mot=new MaterielOutTransaction(this.ViewState["ID"].ToString(),this.CurrentUser().Id);
bool havein=false;
for(int i=0;i<this.grid.Items.Count;i++)
{
string innums=((TextBox)this.grid.Items[i].FindControl("txtInNums")).Text.Trim();
if(innums!="" && innums!="0")
{
mot.AddLines(this.grid.DataKeys[i].ToString(),double.Parse(innums));
havein=true;
}
}
if(!havein)
{
this.lblMessage.Text="失败:请输入有效的非零领料量";
this.lblMessage.Visible=true;
return;
}
try
{
mot.Process();
}
catch
{
this.lblMessage.Text="失败:领料过程中遇到错误";
this.lblMessage.Visible=true;
return;
}
this.lblMessage.Text="成功:生产领料操作成功";
this.lblMessage.Visible=true;
this.btnIn.Visible=false;
}
private void btnGoBack_Click(object sender, System.EventArgs e)
{
Response.Redirect("MaterielSTWeb.aspx");
Response.End();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -