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

📄 editorder.cs

📁 机械制造业信息管理系统(含源码) 是为一个粮仪厂开发的
💻 CS
📖 第 1 页 / 共 4 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using System.Data;
using System.Data.OleDb;

namespace Eboer.MIS.MF.WinForm.Sell
{
	/// <summary>
	/// EditOrder 的摘要说明。
	/// </summary>
	public class EditOrder : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Label label18;
		private System.Windows.Forms.Label label17;
		private System.Windows.Forms.Label label16;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Button button3;
		public System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label3;
		public System.Windows.Forms.DataGrid list;
		private System.Windows.Forms.TextBox allExes;
		private System.Windows.Forms.TextBox buyContactEr;
		private System.Windows.Forms.ComboBox buyEr;
		private System.Windows.Forms.TextBox packSign;
		private System.Windows.Forms.TextBox pageSign;
		public System.Windows.Forms.TextBox sign;
		private System.Windows.Forms.TextBox memo;
		private System.Windows.Forms.TextBox txExes;
		private System.Windows.Forms.Label modInfo;
		private System.Windows.Forms.Label addInfo;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.ComboBox rgPlace;
		private System.Windows.Forms.ComboBox rgMeans;
		private System.Windows.Forms.ComboBox payMeans;
		private System.Windows.Forms.DateTimePicker writeDate;
		private System.Windows.Forms.DateTimePicker rgDate;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ComboBox fplx;
		private System.Windows.Forms.ComboBox yhzf;
		private System.Windows.Forms.TextBox hphm;
		private System.Windows.Forms.ContextMenu contextMenu1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;

		public  string autoID = null;

		public OrderList _ol = null;

		public string selID = null;

		/// <summary>
		/// 数据源
		/// </summary>
		private DataSet ds = null;

		private int currentIndex = -1;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.ComboBox jht;

		private ReportLibrary.ReportDocument rd = null;
		private System.Windows.Forms.ComboBox thisExecuteEr;
		private System.Windows.Forms.ComboBox payStat;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.Label label19;
		private System.Windows.Forms.TextBox fc2;
		private System.Windows.Forms.Timer timer1;

		//
		private string _writeDate = "";

		public OrderList orl = null;

		public EditOrder(OrderList orl)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			this.LoadConfig();

			this.timer1.Start();

			this.orl = orl;
		}

		public EditOrder(string selID){
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			this.selID = selID;

			this.LoadConfig();
		}


		private void LoadConfig(){
			//1、
			this.LoadSelectItem();
			this.LoadBuyer();

			if(this.autoID == null){
				this.addInfo.Text = "录入:" + Public.userID + "," + DateTime.Now.ToString();
				this.button2.Enabled = false;
				this.button3.Enabled = false;
				this.button4.Enabled = false;
			}else{
				
			}

			//当处理过数量时则重新计算总额
			//一个是列表中的总额,一个是基本信息中的总额
			this.list.CurrentCellChanged += new EventHandler(this.NumsChangeed);

			//
			//两个事件
			this.list.MouseDown   += new MouseEventHandler(this.ClickInDG);
			this.list.MouseUp     += new MouseEventHandler(this.UPInDG);
		}

		/// <summary>
		/// 载入基本信息
		/// </summary>
		private void LoadInfo(){
			if(this.autoID != null){
				try{
					string sql = "select * from SellOrder where autoID = " + this.autoID;
					OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
					DataSet ds = new DataSet();
					ad.Fill(ds,"list");

					if(ds != null && ds.Tables[0].Rows.Count > 0){
						DataRow row = ds.Tables[0].Rows[0];

						this.sign.Text          = row["sosign"].ToString();
						this.packSign.Text      = row["pactSign"].ToString();
						this.pageSign.Text      = row["pageSign"].ToString();
						this.writeDate.Text     = row["WriteDate"].ToString();
						this._writeDate         = Public.GetChineseDate(Convert.ToDateTime(row["WriteDate"].ToString().Replace(" 0:00:00","")));
						this.buyEr.Text         = row["buyName"].ToString() + "(" + row["buySign"].ToString() + ")";
						this.buyContactEr.Text  = row["buyContactEr"].ToString();
						this.thisExecuteEr.Text = row["thisExecuteEr"].ToString();
						this.allExes.Text       = row["allExes"].ToString();
						this.rgPlace.Text       = row["rgPlace"].ToString();
						this.rgMeans.Text       = row["rgMeansName"].ToString();
						this.rgDate.Text        = row["rgDate"].ToString();
						this.payMeans.Text      = row["payMeansName"].ToString();
						this.txExes.Text        = row["tsExes"].ToString();
						this.memo.Text          = row["content"].ToString();

						if(this.txExes.Text.Trim().Replace("0","").Equals("") || this.txExes.Text.Trim().Replace("0","").Equals(".")) this.txExes.Text = "";

						this.fplx.Text = row["fplx"].ToString();
						this.hphm.Text = row["hphm"].ToString();
						this.yhzf.Text = row["yhzf"].ToString();

						this.jht.Text  = row["jhrType"].ToString();

						this.payStat.Text = row["fc1"].ToString();

						this.fc2.Text = row["fc2"].ToString();

						
						this.addInfo.Text = "录入:" + row["addEr"].ToString() + "," + row["addDate"].ToString();
						this.modInfo.Text = "修改:" + row["modifyEr"].ToString() + "," + row["modifyDate"].ToString();

						this.button2.Enabled = true;
						this.button3.Enabled = true;
						this.button4.Enabled = true;

						//检查供货商的资料是否存在,如果不存在则不能进行相关的修改操作
						//灰色化保存按钮
						sql = "select * from CorpColl where comType='SELL' and sign='"+ row["buySign"].ToString() +"'";
						ad  = new OleDbDataAdapter(sql,Public.conn);
						DataSet _ds = new DataSet();
						ad.Fill(_ds,"corp");
						if(_ds == null || _ds.Tables[0].Rows.Count == 0){
							MessageBox.Show("数据库中找不到相关编号的订货商资料,可能已被删除或更改了手工编号!\n\n因缺少订货商资料本条信息已被冻结,不能进行修改操作,但可删除!");
							this.buyEr.Enabled   = false;
							this.button2.Enabled = false;
						}
					}

					this.sign.Enabled = false;

				}catch(Exception ex){
					MessageBox.Show(ex.Message.ToString());
					this.Close();

				}
			}
		}

		/// <summary>
		/// 载入订货商
		/// </summary>
		private void LoadBuyer(){
			try{
				string sql = "select * from CorpColl where comType='SELL'";
				OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
				DataSet ds = new DataSet();
				ad.Fill(ds,"list");
				if(ds != null){
					foreach(DataRow row in ds.Tables[0].Rows){
						this.buyEr.Items.Add(row["corName"].ToString() + "(" + row["sign"].ToString() +")");
					}
				}

				//选择默认
				if(this.selID != null){
					for(int i=0;i<this.buyEr.Items.Count;i++){
						if(this.buyEr.Items[i].ToString().EndsWith("("+ this.selID.ToString() +")")){
							this.buyEr.SelectedIndex = i;
						}
					}
				}

			}catch(Exception ex){
				MessageBox.Show(ex.Message.ToString());
				return;
			}
		}

		///载入明细
		public void LoadItemCol(){
			try{

				//this.list.TableStyles.Clear();
				//((DataTable)this.list.DataSource).Rows.Clear();

				string sql = "select proName as 品名,modelName as 规格,nums as 数量,unitName as 单位,price as 单价,allExes as 总额,content as 备注,spec as 编号 from SellList where";
				if(this.sign.Text.Trim() == ""){
					sql += " autoID = 0";
				}else{
					sql += " sellSign = '"+ this.sign.Text.Trim() +"'";
				}

				OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
				this.ds = new DataSet();
				ad.Fill(this.ds,"list");

				this.list.SetDataBinding(ds.Tables[0],"");

				Public.SizeColumnsToContent(this.list,-1,ds.Tables[0],new string[]{"编号"});
				this.InitDataGrid();
			}catch(Exception ex){
				MessageBox.Show(ex.Message.ToString());
				return;
			}
		}

		/// <summary>
		/// 载入选择项
		/// </summary>
		private void LoadSelectItem(){

			//收货地址
			DataSet ds = Public.GetDireItem("交货地点(ZD002");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.rgPlace.Items.Add(row["diName"].ToString());
				}
			}


			ds = Public.GetDireItem("员工(ZD007");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.thisExecuteEr.Items.Add(row["diName"].ToString());
				}
			}

			ds = Public.GetDireItem("交货方法(ZD008");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.rgMeans.Items.Add(row["diName"].ToString());
				}
			}

			ds = Public.GetDireItem("付款方法(ZD004");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.payMeans.Items.Add(row["diName"].ToString());
				}
			}

			ds = Public.GetDireItem("发票类型(ZD003");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.fplx.Items.Add(row["diName"].ToString());
				}
			}

			ds = Public.GetDireItem("运费支付方式(ZD009");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.yhzf.Items.Add(row["diName"].ToString());
				}
			}

			ds = Public.GetDireItem("交货日期方式(ZD010");
			if(ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					this.jht.Items.Add(row["diName"].ToString());
				}
			}
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.button4 = new System.Windows.Forms.Button();
			this.panel2 = new System.Windows.Forms.Panel();
			this.fc2 = new System.Windows.Forms.TextBox();
			this.label19 = new System.Windows.Forms.Label();
			this.payStat = new System.Windows.Forms.ComboBox();
			this.button5 = new System.Windows.Forms.Button();
			this.jht = new System.Windows.Forms.ComboBox();
			this.yhzf = new System.Windows.Forms.ComboBox();
			this.hphm = new System.Windows.Forms.TextBox();
			this.fplx = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.rgDate = new System.Windows.Forms.DateTimePicker();

⌨️ 快捷键说明

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