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

📄 orderlist.cs

📁 机械制造业信息管理系统(含源码) 是为一个粮仪厂开发的
💻 CS
📖 第 1 页 / 共 2 页
字号:
					cmd.ExecuteNonQuery();
					Public.conn.Close();

					//
					sql = "delete from SellOrder where autoID=" + this.autoID;
					cmd = new OleDbCommand(sql,Public.conn);
					Public.CloseConn();
					Public.conn.Open();
					cmd.ExecuteNonQuery();
					Public.conn.Close();

					this.LoadList();

					this.autoID = null;
					this.currentIndex = -1;

					this.menuItem1.Enabled = false;
					this.menuItem2.Enabled = false;
					this.menuItem4.Enabled = false;
					this.menuItem6.Enabled = false;
				}
			//}catch(Exception ex){
			//	MessageBox.Show(ex.Message.ToString());
			//	return;
			//}
		}

		/// <summary>
		/// 查看订货商信息
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void menuItem4_Click(object sender, System.EventArgs e) {
			if(this.autoID != null && this.ds != null){
				for(int i=0;i<ds.Tables[0].Rows.Count;i++){
					DataRow row = ds.Tables[0].Rows[i];
					if(row["系统编号"].ToString().Equals(this.autoID)){
						string _corSign = row["订货商编号"].ToString();
						try{
							string sql = "select * from CorpColl where comType='SELL' and sign='"+ _corSign +"'";
							OleDbDataAdapter adp = new OleDbDataAdapter(sql,Public.conn);
							DataSet _cor = new DataSet();
							adp.Fill(_cor,"cor");
							if(_cor != null && _cor.Tables[0].Rows.Count > 0){
								DataRow _row = _cor.Tables[0].Rows[0];
								string _autoID = _row["autoID"].ToString();
								Eboer.MIS.MF.WinForm.EditCustomer ec = new EditCustomer(null);
								ec.SetAutoID(_autoID);
								ec.ShowDialog();
							}else{
								MessageBox.Show("数据库中找不到相关订货商的资料,可能已被删除或更改了手工编号!");
							}
						}catch(Exception ex){
							MessageBox.Show(ex.Message.ToString());
							return;
						}
					}
				}
			}
		}

		/// <summary>
		/// 打印选中
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void menuItem6_Click(object sender, System.EventArgs e) {
			if(this.autoID != null){
				OrderList ol = null;
				EditOrder eo = new EditOrder(ol);
				eo.SetAutoID(this.autoID);
				eo.button4_Click(null,null);
			}else{
				MessageBox.Show("没有选中的数据,不能继续!");
				return;
			}
		}

		/// <summary>
		/// 刷新全部
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void menuItem8_Click(object sender, System.EventArgs e) {
			this.LoadList();
		}

		/// <summary>
		/// 事件一
		/// </summary>
		private void ClickInDG(object sender,MouseEventArgs e){

			//try{
				if(this.currentIndex != -1) this.list.UnSelect(this.currentIndex);

				Point p = new Point(e.X,e.Y);
				DataGrid.HitTestInfo hti = this.list.HitTest(p);
				if(((DataTable)this.list.DataSource).Rows.Count > 0 && hti.Type == DataGrid.HitTestType.Cell){
					this.list.CurrentCell = new DataGridCell(hti.Row,hti.Column);
					this.list.Select(hti.Row);
					this.currentIndex = hti.Row;
					if(this.list.CurrentCell.RowNumber < this.ds.Tables[0].Rows.Count + 1){
						string xuhao = this.list[this.list.CurrentCell.RowNumber,0].ToString();
						if(xuhao != null && xuhao != "" && xuhao != "null"){
							try{
								this.autoID = xuhao;
							}catch{
								this.autoID = null;
							}
						}
					}else{
						if(this.currentIndex != -1){
							this.list.UnSelect(this.currentIndex);
							this.currentIndex = -1;
						}
						this.autoID = null;
					}
				}else this.autoID = null;

				//如果相等,则表示选中的是空行
				if(this.currentIndex == ((DataTable)this.list.DataSource).Rows.Count){
					this.autoID = null;
					this.currentIndex = -1;
				}

				if(this.autoID != null){
					this.menuItem1.Enabled = true;
					this.menuItem2.Enabled = true;
					this.menuItem4.Enabled = true;
					this.menuItem6.Enabled = true;
				}else{
					this.menuItem1.Enabled = false;
					this.menuItem2.Enabled = false;
					this.menuItem4.Enabled = false;
					this.menuItem6.Enabled = false;
				}

				//MessageBox.Show("当前选中:" + this.currentIndex.ToString() + ",当前autoID="+ this.autoID +",共有"+ ((DataTable)this.list.DataSource).Rows.Count.ToString() +"条记录。");

			//}catch{}
		}

		/// <summary>
		/// 事件二
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void UPInDG(object sender,MouseEventArgs e){

			if(this.autoID != null){
				this.menuItem1.Enabled = true;
				this.menuItem2.Enabled = true;
				this.menuItem4.Enabled = true;
				this.menuItem6.Enabled = true;
			}else{
				this.menuItem1.Enabled = false;
				this.menuItem2.Enabled = false;
				this.menuItem4.Enabled = false;
				this.menuItem6.Enabled = false;
			}
		}

		private void list_CurrentCellChanged(object sender, System.EventArgs e) {
			this.list.Select(this.list.CurrentCell.RowNumber);
		}

		private void button1_Click(object sender, System.EventArgs e) {
			this.LoadList();
		}

		/// <summary>
		/// 新建
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void button2_Click(object sender, System.EventArgs e) {
			EditOrder eo = new EditOrder(this);
			eo.LoadItemCol();
			eo.sign.Text = Public.GetNewInfoID("SellOrder","soSign");
			eo.SetPackSign();
			eo.sign.Enabled = true;
			eo._ol          = this;
			eo.Show();
		}

		/// <summary>
		/// 查询结果,分列表和明细两种情况
		/// 这种方式不能进行编辑等操作
		/// 如果没有选择公司名称的条件 ,则显示公司名称这个字段
		/// </summary>
		private void GetListForItem(){
			try{

				string sql = "select b.writeDate as 订购日期,b.buyName as 客户名称,c.corContactEr as 联系人,b.thisExecuteEr as 经办人,b.pageSign as 凭证编号,a.modelName as 规格,a.proName as 品名,a.nums as 数量,a.unitName as 单位,a.price as 单价,a.allExes as 总额,a.content as 备注,b.fc1 as 收款状态 from SellList a,SellOrder b,corpColl c where a.sellSign=b.soSign and b.buySign = c.sign";

				//限制公司名称
				if(this.corpSign != null && this.corpSign.Trim() != ""){
					sql += " and b.buySign='"+ this.corpSign +"'";
					this.tjStr += "$订购单位:" + this.corpName;
				}else if(this.corpName != null && this.corpName.Trim() != ""){
					sql += " and (b.buyName like '%"+ this.corpName +"%' or c.corContactEr = '"+ this.corpName +"')";
					this.tjStr += "$订购单位:" + this.corpName;
				}

				//按时间段查询
				if(this.startDate != null && this.endDate != null){
					if(this.timeType == "JY"){//签约日期
						sql += " and b.writeDate >= #"+ this.startDate +"# and b.writeDate <= #"+ this.endDate +"#";
					}else if(this.timeType == "JH"){ //交货日期
						sql += " and b.rgDate >= #"+ this.startDate +"# and b.rgDate <= #"+ this.endDate +"#";
					}

					if(this.timeType != "NO") this.tjStr += "$时间区间:" + this.startDate + " 至 " + this.endDate;
				}

				//按产品名称
				if(this.proSign != null && this.proSign.Trim() != ""){
					sql += " and a.spec = '"+ this.proSign +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}else if(this.proName != null && this.proName.Trim() != ""){
					sql += " and a.proName like '%"+ this.proName +"%'";
					this.tjStr += "$产品名称:" + this.proName;
				}

				//按我方经办人查询
				if(this.executeEr != null && this.executeEr.Trim() != ""){
					sql += " and b.thisExecuteEr='"+ this.executeEr +"'";
					this.tjStr += "$经 办 人:" + this.executeEr;
				}

				if(this.djhm != null && this.djhm.Trim() != ""){
					sql += " and b.pageSign='"+ this.djhm +"'";
					this.tjStr += "$单据号码:" + this.djhm;
				}

				if(this.areaName != null && this.areaName.Trim().Length > 0){
					sql += " and c.areaName like '%"+ this.areaName +"%'";
					this.tjStr += "$所属地区:" + this.areaName;
				}

				if(this.timeType == "JY"){
					sql += " order by b.writeDate desc";
				}else{
					sql += " order by b.rgDate desc";
				}

				this.ds = new DataSet();

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

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

				this.label2.Text = "共有销售明细数据 "+ this.ds.Tables[0].Rows.Count.ToString() +" 条";

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

		/// <summary>
		/// 载入列表
		/// </summary>
		private void GetListForList(){
			try{

				if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();

				string sql = "select a.autoID as 系统编号,a.soSign as 信息编号,a.writeDate as 签约日期,a.rgDate as 发货日期,fc2 as 总件数,a.buySign as 订货商编号,a.buyName as 客户名称,a.buyContacter as 对方联系人,d.tel as 电话,d.mobileTel as 手机,a.thisExecuteEr as 经办人,a.allExes as 总金额,a.fc1 as 收款状态 from SellOrder a,SellList b,CorpColl d where a.soSign=b.sellSign and a.buySign=d.sign and d.comType='SELL'";

				//限制公司名称
				if(this.corpSign != null && this.corpSign.Trim() != ""){
					sql += " and a.buySign='"+ this.corpSign +"'";
					this.tjStr += "$订购单位:" + this.corpName;
				}else if(this.corpName != null && this.corpName.Trim() != ""){
					sql += " and (a.buyName like '%"+ this.corpName +"%' or d.corContactEr = '"+ this.corpName +"')";
					this.tjStr += "$订购单位:" + this.corpName;
				}

				//按时间段查询
				if(this.startDate != null && this.endDate != null){
					if(this.timeType == "JY"){//签约日期
						sql += " and a.writeDate >= #"+ this.startDate +"# and a.writeDate <= #"+ this.endDate +"#";
					}else if(this.timeType == "JH"){ //交货日期
						sql += " and a.rgDate >= #"+ this.startDate +"# and a.rgDate <= #"+ this.endDate +"#";
					}

					 if(this.timeType != "NO") this.tjStr += "$时间区间:" + this.startDate + " 至 " + this.endDate;
				}

				//按产品名称
				if(this.proSign != null && this.proSign.Trim() != ""){
					sql += " and b.spec = '"+ this.proSign +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}else if(this.proName != null && this.proName.Trim() != ""){
					sql += " and b.proName like '%"+ this.proName +"%'";
					this.tjStr += "$产品名称:" + this.proName;
				}

				//按我方经办人查询
				if(this.executeEr != null && this.executeEr.Trim() != ""){
					sql += " and a.thisExecuteEr='"+ this.executeEr +"'";
					this.tjStr += "$经 办 人:" + this.executeEr;
				}

				if(this.djhm != null && this.djhm.Trim() != ""){
					sql += " and a.pageSign='"+ this.djhm +"'";
					this.tjStr += "$单据号码:" + this.djhm;
				}

				if(this.areaName != null && this.areaName.Trim().Length > 0){
					sql += " and d.areaName like '%"+ this.areaName +"%'";
					this.tjStr += "$所属地区:" + this.areaName;
				}

				sql += " Group by a.autoID,a.pageSign,a.soSign,a.pactSign,a.writeDate,a.buySign,a.buyName,a.buyContacter,a.thisExecuteEr,a.allExes,a.fc1,d.tel,d.mobileTel,a.fc2,a.rgDate";

				if(this.startDate != null){
					if(this.timeType == "JY"){
						sql += " order by a.writeDate desc";
					}else{
						sql += " order by a.rgDate desc";
					}
				}else{
					sql += " order by soSign desc";
				}

				this.ds = new DataSet();

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


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



				this.label2.Text = "共有销售单数据 "+ this.ds.Tables[0].Rows.Count.ToString() +" 条";

//
			}catch(Exception ex){
				MessageBox.Show("出错(710):" + ex.Message.ToString());
				return;
			}
		}

		/// <summary>
		/// 双击网格时发生
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void list_DoubleClick(object sender, System.EventArgs e) {
			//
		}

		private void list_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne) {
		
		}

		/// <summary>
		/// 设置网格的一些样式,使在双击第一列的时候可以弹出修改或二级查询窗口
		/// </summary>
		private void GridStyle(){
			for(int i=0;i<this.list.TableStyles[0].GridColumnStyles.Count;i++){
				((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.DoubleClick  += new EventHandler(this.DoubleClickForGridFirstCol);
				((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.MouseMove    += new MouseEventHandler(this.IsHand);
				((DataGridTextBoxColumn)this.list.TableStyles[0].GridColumnStyles[i]).TextBox.MouseLeave   += new EventHandler(this.NoHand);
			}
		}

		//双击网络第一列时发生
		private void DoubleClickForGridFirstCol(object sender,EventArgs e){

			if(((DataTable)this.list.DataSource).Rows.Count > 0 && this.viewType == "ITEM"){
				if(this.list.CurrentCell.ColumnNumber == 0){ //查看相同条件某同一日期的数据

					OrderList list = new OrderList();

					//条件相等
					list.corpSign  = this.corpSign;   //客户编号
					list.corpName  = this.corpName;   //客户名称
					list.startDate = this.list[this.list.CurrentRowIndex,0].ToString().Replace(" 0:00:00","");   //起始时间
					list.endDate   = this.list[this.list.CurrentRowIndex,0].ToString().Replace(" 0:00:00","");   //结束时间
					list.timeType  = this.timeType;   //时间类型,默认为签约
					list.proSign   = this.proSign;   //产品编号
					list.proName   = this.proName;   //产品名称
					list.executeEr = this.executeEr;   //经办人
					list.djhm      = this.djhm;   //单据号码
					list.viewType  = this.viewType; //显示方式,默认列表,否则为明细

					list.ListInit();
					list.Show();

				}
			}else{
				//修改当前信息
				this.menuItem1_Click(sender,e);
			}
		}

		private void IsHand(object sender,MouseEventArgs e){
			this.ChangeCursor(true);
		}

		private void NoHand(object sender,EventArgs e){
			this.ChangeCursor(false);
		}

		private void ChangeCursor(bool IS){
			if(IS){
				this.Cursor = Cursors.Hand;
			}else{
				this.Cursor = Cursors.Arrow;
			}
		}
	}
}

⌨️ 快捷键说明

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