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

📄 wf_order.aspx.cs

📁 某大型国企试用的网上订餐管理系统完整源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
			DGEdit.DataBind() ;
			Dt1=dataSet1.Tables["t_order_detail"];			
			foreach ( DataGridItem  Dg in DGEdit.Items)
			{
				foreach ( DataRow  Dr in Dt1.Rows)
				{
					//TextBox5.Text+=Dr["Quantity"].ToString();
					if ( Dr["food_id"].ToString()==Dg.Cells[2].Text )  
					{

						((CheckBox)Dg.Cells[0].Controls[1]).Checked = true;
						((TextBox)Dg.Cells[5].Controls[1]).Text=Dr["Quantity"].ToString();
					//	TextBox5.Text+=Dr[0]["Quantity"].ToString();
					}
				}
			}
				 Button1_Click(sender,e);

		}

		private void BAdd_Click(object sender, System.EventArgs e)
		{
			DataTable Dt1;
			string str1,order_id_str,str2;

			if (!BAdd.Enabled)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:已经超过订餐时间!"")</script>");
				return;
			}

			price_str=0;
			if(TBMemo.Text=="")
			{
					TBMemo.Text=" ";
			}
			Button1_Click(sender,e);
			str2=(price_str*100).ToString();

			str1="'"+strCurDate +" "+ strCurTime +":00','"+strDinner+"','"+DDLDest.SelectedItem.Text+"','"+strUser+
				"','"+strUserName+"','"+strDept+"','"+strDeptName+"',"+str2 +",'"+
				WorkFoodState1+"','"+TBMemo.Text+"'";
		
			Insertstr="INSERT INTO T_order(`Date` ,`Kind` ,`Send_dest`,`User_id`,`Name` ,`Department_id`,`Department` ,`Totel_price`,`Free`,`Memo`) VALUES ( "+str1+")";
			insertdataTo_order(); 
			Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_ORDER, Global.ACTION_ADD,Insertstr);
			Findselectdata();
			connectionDB();
			dataSet1.Tables["t_order"].Clear();
			odbcDataAdapter1.Fill ( dataSet1 , "T_order" ) ;							
			order_id_str=dataSet1.Tables["t_order"].Rows[0]["Order_id"].ToString();
			//order_id_str = DGFind.SelectedItem .Cells [1].Text;
			//TBMemo.Text=DGFind.SelectedItem .Cells [1].Text;
			//return;
			////////////////////////////////////////////////////////////////////////////////////////// 
			odbcDataAdapter1.SelectCommand.CommandText ="select `Order_id` ,`food_id`,`Quantity` from t_order_detail where Order_id= "+order_id_str;
			odbcDataAdapter1.SelectCommand.Connection = odbcConnection1;
			odbcDataAdapter1.Fill(dataSet1, "t_order_detail");
			System.Data.Odbc.OdbcCommandBuilder  commandBulider;
			commandBulider = new System.Data.Odbc.OdbcCommandBuilder(odbcDataAdapter1); 
			odbcDataAdapter1.UpdateCommand = commandBulider.GetUpdateCommand();
			odbcDataAdapter1.InsertCommand = commandBulider.GetInsertCommand();
			odbcDataAdapter1.DeleteCommand = commandBulider.GetDeleteCommand();
			DataRow Dr1;
			Dt1=dataSet1.Tables["t_order_detail"];
			foreach ( DataGridItem  Dg in DGEdit.Items)
			{
				if (((CheckBox)Dg.Cells[0].Controls[1]).Checked)  
				{
					Dr1 = Dt1.NewRow();
					Dr1["Order_id"] = Convert.ToInt32(order_id_str);
					Dr1["food_id"]  = Convert.ToUInt32(Dg.Cells[2].Text);
					Dr1["Quantity"] = Convert.ToDouble(((TextBox)Dg.Cells[5].Controls[1]).Text);
					Dt1.Rows.Add(Dr1);	
				//	TBMemo.Text += order_id_str + "|||" + Dg.Cells[2].Text + "|||" + ((TextBox)Dg.Cells[5].Controls[1]).Text;
				}
				//DataGrid1.DataSource = dataSet1.Tables [ "t_order_detail" ].DefaultView ; 
				//DataGrid1.DataBind();	
				odbcDataAdapter1.Update(dataSet1,"t_order_detail");
				Label3.Text = "您已经订了"+T_order_count.ToString()+"份"+strDinnerName+"餐"; 
			}
		}
		private void insertdataTo_order()
		{
			int i=1;
			connectionDB();
			odbcInsertCommand1.CommandText = Insertstr;
			odbcInsertCommand1.Connection = odbcConnection1;
			i = odbcInsertCommand1.ExecuteNonQuery ();
			if (i != 1)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:增加数据错误!"")</script>");

				//lblMessage.Text = "发生错误。";
			}
			closeDB();
		}
		private void BDele_Click(object sender, System.EventArgs e)
		{
			string DeletedataStr;
			int iUpdateRowCount;
			string order_id_index_str;

			if (!BDele.Enabled)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:已经超过订餐时间!"")</script>");
				return;
			}

			lblMessage.Text = "";

			if (DGFind.SelectedIndex < 0) //unselected
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:未选择记录!请先选择一条记录,然后进行删除。"")</script>");

		//		lblMessage.Text = "未选择记录!请先选择一条记录,然后进行删除。";
				return;
			}
			else
			{
				order_id_index_str= DGFind.SelectedItem .Cells [1].Text;
				DeletedataStr = "delete from T_order " +
					"where order_id = "+order_id_index_str;
			}

			connectionDB();
			odbcCommand1.CommandText = DeletedataStr;
			odbcCommand1.Connection = odbcConnection1;
			iUpdateRowCount = odbcCommand1.ExecuteNonQuery ();
			if (iUpdateRowCount != 1)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:删除记录时出错,请检查!"")</script>");
		//		lblMessage.Text = "错误!删除记录时出错,请检查。";
			}
			else
			{
				DGFind.SelectedIndex = -1;
				DeletedataStr= "delete from t_order_detail "+ 
					"where order_id = "+order_id_index_str;
			//	TBMemo.Text=DeletedataStr;
				odbcCommand1.CommandText = DeletedataStr;
				odbcCommand1.Connection = odbcConnection1;
				iUpdateRowCount = odbcCommand1.ExecuteNonQuery ();

				  Findselectdata();
             Label3.Text = "您已经订了"+T_order_count.ToString()+"份"+strDinnerName+"餐";
				 Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_ORDER,Global.ACTION_DELETE,DeletedataStr);
				DGFind.SelectedIndex = -1;
			    closeDB();

			}

		}

		private void BUpdate_Click(object sender, System.EventArgs e)
		{
			string order_id_str;

			if (!BUpdate.Enabled)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:已经超过订餐时间!"")</script>");
				return;
			}

			if (DGFind.SelectedIndex < 0) 
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:未选择记录!请先选择一条记录,然后进行修改!"")</script>");

				//lblMessage.Text = "未选择记录!请先选择一条记录,然后进行修改。";
				return;
			}
			Button1_Click(sender,e);
			string str2=(price_str*100).ToString();
			order_id_str= DGFind.SelectedItem .Cells [1].Text;

			Updatastr="UPDATE T_order set " +
				"`Send_dest` = '" +DDLDest.SelectedItem.Text + "', " +
				"`Free` = '" + WorkFoodState1  + "', " +
				"`Totel_price` = " + str2  + ", " +
				"`Memo` = '" + TBMemo.Text  + "' " +
				"where order_id="+order_id_str; 
			//lblMessage.Text = Updatastr;
			Updata_T_order(Updatastr,order_id_str);
			Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_ORDER,Global.ACTION_UPDATE,Updatastr);
			Label3.Text = "您已订定了"+T_order_count.ToString()+"份"+strDinnerName+"餐";
			DGFind.SelectedIndex = -1;
			

		}
		private void Updata_T_order(string updatastr1,string order_id_index_str1)
		{
			int iUpdateRowCount;
			connectionDB();
			//TextBox5.Text=updatastr1;
			odbcCommand1.CommandText = updatastr1;
			odbcCommand1.Connection = odbcConnection1;
			iUpdateRowCount = odbcCommand1.ExecuteNonQuery ();
			if (iUpdateRowCount != 1)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:修改数据库出错,请检查!"")</script>");

			//	lblMessage.Text = "错误!修改数据库出错,请检查。";
			}
			else
			{
				DGFind.SelectedIndex = -1;
				Findselectdata();
				connectionDB();

				Updata_T_order_detail( order_id_index_str1);
			}
		}

		private void Updata_T_order_detail(string  order_id_index_str2)
		{
			DataTable Dt1;
			int iUpdateRowCount;
			/*	odbcDataAdapter1 =new System.Data.Odbc.OdbcDataAdapter ("select `Order_id` ,`food_id`,`Quantity` from t_order_detail where Order_id= "+order_id_index_str2,odbcConnection1 ) ;
				//dataSet1.Tables["t_order_detail"].Clear();
				odbcDataAdapter1.Fill ( dataSet1 , "t_order_detail" ) ;
				odbcDataAdapter1.Fill ( dataSet1 , "T_Current_Menu" ) ;
				DataGrid1.DataSource = dataSet1.Tables [ "t_order_detail" ].DefaultView ; 
				DataGrid1.DataBind();	

				System.Data.Odbc.OdbcCommandBuilder  commandBulider;
				commandBulider = new System.Data.Odbc.OdbcCommandBuilder(odbcDataAdapter1); 
				odbcDataAdapter1.UpdateCommand = commandBulider.GetUpdateCommand();
				odbcDataAdapter1.InsertCommand = commandBulider.GetInsertCommand();
				odbcDataAdapter1.DeleteCommand = commandBulider.GetDeleteCommand();
				DataRow Dr1;
				Dt1=dataSet1.Tables["t_order_detail"];
				foreach ( DataGridItem  Dg in DGEdit.Items)
				{
					foreach ( DataRow  Dr in Dt1.Rows)
					{
						if ( Dr["food_id"].ToString()==Dg.Cells[2].Text )  
						{
							//dr["check1"] 
							((CheckBox)Dg.Cells[0].Controls[1]).Checked = true;
						}
					}
					DataGrid1.DataSource = dataSet1.Tables [ "t_order_detail" ].DefaultView ; 
					DataGrid1.DataBind();	
				//	odbcDataAdapter1.Update(dataSet1,"t_order_detail");
				}*/
			Updatastr= "delete from t_order_detail "+ 
				"where order_id = "+order_id_index_str2;

			odbcCommand1.CommandText = Updatastr;
			odbcCommand1.Connection = odbcConnection1;
			iUpdateRowCount = odbcCommand1.ExecuteNonQuery ();
			odbcDataAdapter1.SelectCommand.CommandText = "select `Order_id` ,`food_id`,`Quantity` from t_order_detail where Order_id= "+order_id_index_str2;
			odbcDataAdapter1.SelectCommand.Connection = odbcConnection1;
			odbcDataAdapter1.Fill ( dataSet1 , "t_order_detail" ) ;
			System.Data.Odbc.OdbcCommandBuilder  commandBulider;
			commandBulider = new System.Data.Odbc.OdbcCommandBuilder(odbcDataAdapter1); 
			odbcDataAdapter1.UpdateCommand = commandBulider.GetUpdateCommand();
			odbcDataAdapter1.InsertCommand = commandBulider.GetInsertCommand();
			odbcDataAdapter1.DeleteCommand = commandBulider.GetDeleteCommand();
			DataRow Dr1;
			Dt1=dataSet1.Tables["t_order_detail"];
			foreach ( DataGridItem  Dg in DGEdit.Items)
			{
				if (((CheckBox)Dg.Cells[0].Controls[1]).Checked)  
				{
					Dr1 = Dt1.NewRow();
					Dr1["Order_id"] = Convert.ToInt32(order_id_index_str2);
					Dr1["food_id"]  = Convert.ToUInt32(Dg.Cells[2].Text);
					Dr1["Quantity"] = Convert.ToDouble(((TextBox)Dg.Cells[5].Controls[1]).Text);
					Dt1.Rows.Add(Dr1);	
				//	TBMemo.Text +=order_id_index_str2;
				}
				//DataGrid1.DataSource = dataSet1.Tables [ "t_order_detail" ].DefaultView ; 
				//DataGrid1.DataBind();	
				odbcDataAdapter1.Update(dataSet1,"t_order_detail");
			}
		}

		private void CBWorkFood_CheckedChanged(object sender, System.EventArgs e)
		{
			if(CBWorkFood.Checked)
			{
				WorkFoodState1="1";
			}
			else
				WorkFoodState1="0";

		}

		private void DGEdit_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		  foreach ( DataGridItem  Dg in DGEdit.Items)
			{
				if (((CheckBox)Dg.Cells[0].Controls[1]).Checked)  
				{
				  price_str=price_str+(float)Convert.ToDouble(DGFind.SelectedItem .Cells[8].Text);
					if (CBWorkFood.Checked)
					{	
						Label4.Text="总金额:"+price_str.ToString()+"元;工作餐标准:"+Totel_price.ToString()+"元;" +
							"剩余标准:"+(Totel_price-price_str).ToString()+"元";
						Label2.Text = Label4.Text;
					}
					else

					{
						Label4.Text="总金额:"+price_str.ToString() +"元";
						Label2.Text = Label4.Text;

					}
			
				}
			}
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			foreach ( DataGridItem  Dg in DGEdit.Items)
			{
				if (((CheckBox)Dg.Cells[0].Controls[1]).Checked)  
				{
					price_str =price_str+(float)Convert.ToDouble(Dg.Cells[4].Text)*(float)Convert.ToDouble(((TextBox)Dg.Cells[5].Controls[1]).Text);//    DGFind.SelectedItem .Cells [8].Text);
					if (CBWorkFood.Checked)
					{

						Label4.Text="总金额:"+price_str.ToString()+"元;工作餐标准:"+Totel_price.ToString()+"元;" +
							"剩余标准:"+(Totel_price-price_str).ToString()+"元";
						Label2.Text = Label4.Text;
					}
					else
					{
						Label4.Text="总金额:"+price_str.ToString() +"元";
						Label2.Text = Label4.Text;

					}
				}
			}
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{

		}

		private void DGFind_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			  DGFind.CurrentPageIndex=e.NewPageIndex;
           Findselectdata();
			   // PageIndexNbr();
		}



	}
}

⌨️ 快捷键说明

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