⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 returnticketadd2.aspx.cs

📁 可供共享学习.net环境下生产管理的实现
💻 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>
	/// ReturnTicketAdd2 的摘要说明。
	/// </summary>
	public class ReturnTicketAdd2 : BasePage
	{
		protected System.Web.UI.WebControls.Label lblTitle;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.TextBox txtIId;
		protected System.Web.UI.WebControls.ValidationSummary ErrorSummary;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.DropDownList ddlInstruction;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label lblFromDate;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label lblEndDate;
		protected System.Web.UI.WebControls.Label Label13;
		protected System.Web.UI.WebControls.DataGrid gridOrderLine;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Button btnContinue;
		protected System.Web.UI.WebControls.Button btnOTOut;
		protected System.Web.UI.WebControls.Button btnGoBack;
		protected System.Web.UI.WebControls.Label lblMessage;
		protected System.Web.UI.HtmlControls.HtmlTable tableBOM;
		protected System.Web.UI.WebControls.TextBox txtRTId;

		protected ReturnTicket_C  ReturnTicket_C1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			Principal p=this.CurrentUser();
			this.CheckPermissionPage(p.Id,"","206");
			this.lblMessage.Visible=false;
			if(!Page.IsPostBack)
			{
				string otid="";
				if(Request.QueryString["RTID"]!=null)
					otid=Request.QueryString["RTID"].ToString();
				this.txtRTId.Text = otid;
								
				this.InitPage();
			}
		}
		private void InitPage()
		{
			
			ReturnTicket_C1.RID=this.txtRTId.Text.Trim();
			ReturnTicket_C1.Bind();

			ReturnTicket rt=new ReturnTicket();
			rt.Id=this.txtRTId.Text.Trim();
			rt.Retrieve();
			if(rt.IsPersistent)
			{
				DataTable dt=InstructionSystem.GetInstrForReturnTicket(rt.LineId);

				Common.BindDrop(this.ddlInstruction,dt,Instruction.SERIALNO,Instruction.ID,"请选择...","");

			}
			

		}

		#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.ddlInstruction.SelectedIndexChanged += new System.EventHandler(this.ddlInstruction_SelectedIndexChanged);
			this.gridOrderLine.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.gridOrderLine_ItemDataBound);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.btnContinue.Click += new System.EventHandler(this.btnContinue_Click);
			this.btnOTOut.Click += new System.EventHandler(this.btnOTOut_Click);
			this.btnGoBack.Click += new System.EventHandler(this.btnGoBack_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ddlInstruction_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.BindMateriel();
		}


		private void BindMateriel()
		{
			string iid=this.ddlInstruction.SelectedItem.Value;
			if(iid!="")
			{
				Instruction i=new Instruction();
				i.Id=iid;
				i.Retrieve();
				if(i.IsPersistent)
				{
					this.lblFromDate.Text = i.FromDate.ToShortDateString();
					this.lblEndDate.Text = i.EndDate.ToShortDateString();
					this.txtIId.Text = iid;

				}
				else
				{
					this.lblEndDate.Text ="";
					this.lblFromDate.Text="";
					this.txtIId.Text ="";
					
				}

			}
			else
			{
				this.lblEndDate.Text="";
				this.lblFromDate.Text="";
				this.txtIId.Text ="";
							
			}

			if(iid=="")
				iid="*";
			DataTable dt=InstructionSystem.AllInstructionDet(iid);
			Common.ReSet(this.gridOrderLine,dt.DefaultView);
			this.gridOrderLine.DataSource=dt;
			this.gridOrderLine.DataBind();
		}

		private void gridOrderLine_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
			{
				
				string mid=e.Item.Cells[0].Text.Trim();

				double max=double.Parse(e.Item.Cells[3].Text.ToString())+double.Parse(e.Item.Cells[4].Text.ToString());
				RangeValidator rv=(RangeValidator)e.Item.FindControl("RangeNums");
				
				
				
					rv.MaximumValue=max.ToString();
					rv.ErrorMessage +=max.ToString();
					
				
			
				e.Item.Cells[6].Text = Common.GetHtmlCode(MaterielSystem.GetMaterielLocations(mid));

				e.Item.Cells[2].Text = UnitSystem.GetUnitCode(e.Item.Cells[2].Text.Trim());

				e.Item.Cells[0].Text = MaterielSystem.GetMaterielCode(mid);

			}
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			bool haveNums=false;
			string otid=this.txtRTId.Text.Trim();
			for(int i=0;i<this.gridOrderLine.Items.Count;i++)
			{
				string ild=this.gridOrderLine.DataKeys[i].ToString();
				InstructionLineDet ins=new InstructionLineDet();
				ins.Id=ild;
				ins.Retrieve();
				string nums=((TextBox)this.gridOrderLine.Items[i].FindControl("txtNums")).Text.Trim();
				if(nums!="")
				{
					if(ins.IsPersistent)
					{
						ReturnTicketLine rtl=new ReturnTicketLine();
						rtl.Id=LoginSystem.GetTableId("ReturnTicketLine").ToString();
						rtl.Line=i;
						rtl.MaterielId=ins.MaterielId;
						rtl.Quantity=ins.Quantity;
						rtl.ReturnTicketQuantity=double.Parse(nums);
						rtl.UnitId=ins.UnitId;
						rtl.StructionId =this.txtIId.Text.Trim();
						rtl.InstructionLineDetId=ild;
						rtl.ReturnTicketId=this.txtRTId.Text.Trim();
						rtl.Save();
						haveNums=true;
						
					}
				}
				else
				{
//					this.lblMessage.Text ="失败:请输入需退料的数量";
//					this.lblMessage.Visible=true;
//					return;
				}

			}

			if(haveNums)
			{
				this.lblMessage.Text ="成功:填写退料单成功";
				this.lblMessage.Visible=true;
				this.Button2.Visible=false;
				this.btnContinue.Visible=true;
				this.btnOTOut.Visible=true;
				this.btnGoBack.Text =" 完成 ";
			}
			else
			{
				this.lblMessage.Text ="提示:请输入需退料的数量";
				this.lblMessage.Visible=true;
			}

		}

		private void btnContinue_Click(object sender, System.EventArgs e)
		{
			this.ddlInstruction.SelectedIndex=0;
			this.BindMateriel();
			this.btnContinue.Visible=false;
			this.Button2.Visible=true;
		}

		private void btnGoBack_Click(object sender, System.EventArgs e)
		{
			string otid=this.txtRTId.Text.Trim();
			DataTable d=InventorySystem.AllReturnTicketLine(otid);
			if(d.Rows.Count<=0)
			{
				ReturnTicket rt=new ReturnTicket();
				rt.Id=otid;
				rt.Delete();
			}
			
			Response.Redirect("ReturnTicketWeb.aspx",true);
		}

		private void btnOTOut_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("ReturnTicketIn.aspx?id=" + this.txtRTId.Text.Trim(),true);
		}
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -