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

📄 taskservice.asmx.cs

📁 ASP.NET的一些开发实例,有论坛管理系统等
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.oleDbConnection1.ConnectionString = "Provider=MSDAORA.1;Password=acarsgroup;User ID=acarsgroup;Data Source=NOCDB";
			// 
			// oleDbDataAdapter1
			// 
			this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
			this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
			this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																										new System.Data.Common.DataTableMapping("Table", "任务空间", new System.Data.Common.DataColumnMapping[] {
																																																				new System.Data.Common.DataColumnMapping("任务编号", "任务编号"),
																																																				new System.Data.Common.DataColumnMapping("发布时间", "发布时间"),
																																																				new System.Data.Common.DataColumnMapping("任务内容", "任务内容"),
																																																				new System.Data.Common.DataColumnMapping("发布人", "发布人"),
																																																				new System.Data.Common.DataColumnMapping("执行人", "执行人"),
																																																				new System.Data.Common.DataColumnMapping("备注", "备注"),
																																																				new System.Data.Common.DataColumnMapping("任务名称", "任务名称"),
																																																				new System.Data.Common.DataColumnMapping("完成时间", "完成时间"),
																																																				new System.Data.Common.DataColumnMapping("执行人是否浏览", "执行人是否浏览"),
																																																				new System.Data.Common.DataColumnMapping("是否共享", "是否共享")})});
			this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT 任务编号, 发布时间, 任务内容, 发布人, 执行人, 备注, 任务名称, 完成时间, 执行人是否浏览, 是否共享 FROM 任务空间";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
			// 
			// oleDbInsertCommand1
			// 
			this.oleDbInsertCommand1.CommandText = "INSERT INTO 任务空间(任务编号, 发布时间, 任务内容, 发布人, 执行人, 备注, 任务名称, 完成时间, 执行人是否浏览, 是否共享) VALUE" +
				"S (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
			this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务编号", System.Data.OleDb.OleDbType.VarChar, 20, "任务编号"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("发布时间", System.Data.OleDb.OleDbType.DBTimeStamp, 0, "发布时间"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务内容", System.Data.OleDb.OleDbType.VarChar, 2000, "任务内容"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("发布人", System.Data.OleDb.OleDbType.VarChar, 25, "发布人"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("执行人", System.Data.OleDb.OleDbType.VarChar, 25, "执行人"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("备注", System.Data.OleDb.OleDbType.VarChar, 2000, "备注"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务名称", System.Data.OleDb.OleDbType.VarChar, 500, "任务名称"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("完成时间", System.Data.OleDb.OleDbType.DBTimeStamp, 0, "完成时间"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("执行人是否浏览", System.Data.OleDb.OleDbType.VarChar, 100, "执行人是否浏览"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("是否共享", System.Data.OleDb.OleDbType.VarChar, 1, "是否共享"));
			// 
			// oleDbUpdateCommand1
			// 
			this.oleDbUpdateCommand1.CommandText = @"UPDATE 任务空间 SET 任务编号 = ?, 发布时间 = ?, 任务内容 = ?, 发布人 = ?, 执行人 = ?, 备注 = ?, 任务名称 = ?, 完成时间 = ?, 执行人是否浏览 = ?, 是否共享 = ? WHERE (任务编号 = ?) AND (执行人 = ?)";
			this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务编号", System.Data.OleDb.OleDbType.VarChar, 20, "任务编号"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("发布时间", System.Data.OleDb.OleDbType.DBTimeStamp, 0, "发布时间"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务内容", System.Data.OleDb.OleDbType.VarChar, 2000, "任务内容"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("发布人", System.Data.OleDb.OleDbType.VarChar, 25, "发布人"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("执行人", System.Data.OleDb.OleDbType.VarChar, 25, "执行人"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("备注", System.Data.OleDb.OleDbType.VarChar, 2000, "备注"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("任务名称", System.Data.OleDb.OleDbType.VarChar, 500, "任务名称"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("完成时间", System.Data.OleDb.OleDbType.DBTimeStamp, 0, "完成时间"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("执行人是否浏览", System.Data.OleDb.OleDbType.VarChar, 100, "执行人是否浏览"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("是否共享", System.Data.OleDb.OleDbType.VarChar, 1, "是否共享"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_任务编号", System.Data.OleDb.OleDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "任务编号", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_执行人", System.Data.OleDb.OleDbType.VarChar, 25, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "执行人", System.Data.DataRowVersion.Original, null));
			// 
			// oleDbDeleteCommand1
			// 
			this.oleDbDeleteCommand1.CommandText = "DELETE FROM 任务空间 WHERE (任务编号 = ?) AND (执行人 = ?)";
			this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_任务编号", System.Data.OleDb.OleDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "任务编号", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_执行人", System.Data.OleDb.OleDbType.VarChar, 25, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "执行人", System.Data.DataRowVersion.Original, null));
			// 
			// dataSet11
			// 
			this.dataSet11.DataSetName = "DataSet1";
			this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.dataSet11.Namespace = "http://www.tempuri.org/DataSet1.xsd";
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();

		}

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

		[WebMethod]
		public bool AddTask(WorkGroupService.task.task task)
		{
			try
			{
				this.oleDbConnection1.Open();
				this.oleDbInsertCommand1.Parameters[0].Value=task.tNo;
				this.oleDbInsertCommand1.Parameters[1].Value=task.tDate;
				this.oleDbInsertCommand1.Parameters[2].Value=task.tContent;
				this.oleDbInsertCommand1.Parameters[3].Value=task.tPromulgator;
				this.oleDbInsertCommand1.Parameters[4].Value=task.tExecutor;
				if(!System.DBNull.Equals(task.tRemark,System.DBNull.Value))
					this.oleDbInsertCommand1.Parameters[5].Value=task.tRemark;
				this.oleDbInsertCommand1.Parameters[6].Value=task.tName.ToString();
				this.oleDbInsertCommand1.Parameters[7].Value=task.tEndDate;
				this.oleDbInsertCommand1.Parameters[8].Value=task.tScan;
				this.oleDbInsertCommand1.Parameters[9].Value=task.tShare;
				this.oleDbInsertCommand1.ExecuteNonQuery();
				return true;
			}
			catch(Exception e)
			{
				bs.Write("AddTask(WorkGroupService.task task)");
				bs.Write(e.Message);
				return false;
			}
			finally
			{
				this.oleDbConnection1.Close();
			}

		}
		

		[WebMethod] 
		public bool DeleteTask(WorkGroupService.task.task task)
		{
			try
			{
				this.oleDbConnection1.Open();
				this.oleDbDeleteCommand1.Parameters[0].Value=task.tNo;
				this.oleDbDeleteCommand1.Parameters[1].Value=task.tExecutor;
				this.oleDbDeleteCommand1.ExecuteNonQuery();
				return true;
			}
			catch(Exception e)
			{
				bs.Write("DeleteTask(WorkGroupService.task.task task)");
				bs.Write(e.Message);
				return false;
			}
			finally
			{
				this.oleDbConnection1.Close();
			}
		}


		[WebMethod]
		public bool ModTask(WorkGroupService.task.task task)
		{
			try
			{
				this.oleDbConnection1.Open();
				this.oleDbUpdateCommand1.Parameters[0].Value=task.tNo;
				this.oleDbUpdateCommand1.Parameters[1].Value=task.tDate;
				this.oleDbUpdateCommand1.Parameters[2].Value=task.tContent;
				this.oleDbUpdateCommand1.Parameters[3].Value=task.tPromulgator;
				this.oleDbUpdateCommand1.Parameters[4].Value=task.tExecutor;
				if(!System.DBNull.Equals(task.tRemark,System.DBNull.Value))
					this.oleDbUpdateCommand1.Parameters[5].Value=task.tRemark;
				this.oleDbUpdateCommand1.Parameters[6].Value=task.tName.ToString();
				this.oleDbUpdateCommand1.Parameters[7].Value=task.tEndDate;
				this.oleDbUpdateCommand1.Parameters[8].Value=task.tScan;
				this.oleDbUpdateCommand1.Parameters[9].Value=task.tShare;
				this.oleDbUpdateCommand1.Parameters[10].Value=task.tNo;
				this.oleDbUpdateCommand1.Parameters[11].Value=task.tExecutor;
				this.oleDbUpdateCommand1.ExecuteNonQuery();
				return true;
			}
			catch(Exception e)
			{
				bs.Write("ModTask(WorkGroupService.task task)");
				bs.Write(e.Message);
				return false;
			}
			finally
			{
				this.oleDbConnection1.Close();
			}

		}
		
		[WebMethod]
		public WorkGroupService.task.task GetTask(string[] pks)
		{
			WorkGroupService.task.task GetTs=new WorkGroupService.task.task();
			string sqlwhere=string.Format("任务编号='{0}' and 执行人='{1}'",pks[0].Trim(),pks[1].Trim());
			string sql=this.selectSql(sqlwhere);
			DataSet ds=this.bs.CreateDataSetFromSql(sql);
			GetTs.tNo=ds.Tables[0].Rows[0]["任务编号"].ToString();
			GetTs.tName=ds.Tables[0].Rows[0]["任务名称"].ToString();
			GetTs.tDate=DateTime.Parse(ds.Tables[0].Rows[0]["发布时间"].ToString());
			GetTs.tEndDate=DateTime.Parse(ds.Tables[0].Rows[0]["完成时间"].ToString());
			GetTs.tExecutor=ds.Tables[0].Rows[0]["执行人"].ToString();
			GetTs.tPromulgator=ds.Tables[0].Rows[0]["发布人"].ToString();
			GetTs.tContent=ds.Tables[0].Rows[0]["任务内容"].ToString();
			GetTs.tRemark=ds.Tables[0].Rows[0]["备注"].ToString();
			GetTs.tScan=ds.Tables[0].Rows[0]["执行人是否浏览"].ToString();
			GetTs.tShare=ds.Tables[0].Rows[0]["是否共享"].ToString();
			return GetTs;
		}

		[WebMethod]
		public string selectSql(string sqlwhere)
		{
			if(sqlwhere.Trim()!=string.Empty)
				this.oleDbSelectCommand1.CommandText=string.Format("{0} where {1}",this.oleDbSelectCommand1.CommandText,sqlwhere);
			return this.oleDbSelectCommand1.CommandText;
		}

		/// <summary>
		/// 生成任务编号
		/// </summary>
		/// <returns>任务编号</returns>
		[WebMethod]
		public string CreateTaskNO(string str)
		{
			this.oleDbSelectCommand1.CommandText=string.Format("{0} Order by 任务编号 DESC",this.oleDbSelectCommand1.CommandText);
			this.oleDbConnection1.Open();
			System.Data.OleDb.OleDbDataReader dr=this.oleDbSelectCommand1.ExecuteReader();
			string tNO=string.Empty;
			while (dr.Read())
			{
				tNO=dr["任务编号"].ToString().Substring(dr["任务编号"].ToString().Length-4,4);
				int nBH=Convert.ToInt32(tNO) +1;

				tNO=nBH.ToString();
				tNO=tNO.PadLeft(4,'0');
				dr.Close();
				return str+tNO;
			}
			dr.Close();
			this.oleDbConnection1.Close();
			tNO=str+"0001";
			return tNO;
		}
	}
}

⌨️ 快捷键说明

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