using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using HySoft.DBUtility;//Please add references
namespace HySoft.BaseCallCenter.DAL
{
	/// <summary>
	/// 数据访问类:T_Wo_WorkOrderTypeState
	/// </summary>
	public partial class T_Wo_WorkOrderTypeState
	{
		public T_Wo_WorkOrderTypeState()
		{}
		#region  Method



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(HySoft.BaseCallCenter.Model.T_Wo_WorkOrderTypeState model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_Wo_WorkOrderTypeState(");
			strSql.Append("F_WorkOrderTypeId,F_WorkOrderStateId)");
			strSql.Append(" values (");
			strSql.Append("@F_WorkOrderTypeId,@F_WorkOrderStateId)");
			SqlParameter[] parameters = {
					new SqlParameter("@F_WorkOrderTypeId", SqlDbType.Int,4),
					new SqlParameter("@F_WorkOrderStateId", SqlDbType.Int,4)};
			parameters[0].Value = model.F_WorkOrderTypeId;
			parameters[1].Value = model.F_WorkOrderStateId;

			DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(HySoft.BaseCallCenter.Model.T_Wo_WorkOrderTypeState model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_Wo_WorkOrderTypeState set ");
			strSql.Append("F_WorkOrderTypeId=@F_WorkOrderTypeId,");
			strSql.Append("F_WorkOrderStateId=@F_WorkOrderStateId");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
					new SqlParameter("@F_WorkOrderTypeId", SqlDbType.Int,4),
					new SqlParameter("@F_WorkOrderStateId", SqlDbType.Int,4)};
			parameters[0].Value = model.F_WorkOrderTypeId;
			parameters[1].Value = model.F_WorkOrderStateId;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public int Delete(int F_WORKORDERTYPEID)
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_Wo_WorkOrderTypeState ");
            strSql.Append(" where F_WorkOrderTypeId=@F_WorkOrderTypeId");
            SqlParameter[] parameters = { new SqlParameter("@F_WorkOrderTypeId", SqlDbType.Int, 4), };
              parameters[0].Value = F_WORKORDERTYPEID;
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
                return rows;
			}
			else
			{
				return 0;
			}
		}
     

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public HySoft.BaseCallCenter.Model.T_Wo_WorkOrderTypeState GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 F_WorkOrderTypeId,F_WorkOrderStateId from T_Wo_WorkOrderTypeState ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
};

			HySoft.BaseCallCenter.Model.T_Wo_WorkOrderTypeState model=new HySoft.BaseCallCenter.Model.T_Wo_WorkOrderTypeState();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["F_WorkOrderTypeId"]!=null && ds.Tables[0].Rows[0]["F_WorkOrderTypeId"].ToString()!="")
				{
					model.F_WorkOrderTypeId=int.Parse(ds.Tables[0].Rows[0]["F_WorkOrderTypeId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_WorkOrderStateId"]!=null && ds.Tables[0].Rows[0]["F_WorkOrderStateId"].ToString()!="")
				{
					model.F_WorkOrderStateId=int.Parse(ds.Tables[0].Rows[0]["F_WorkOrderStateId"].ToString());
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select F_WorkOrderTypeId,F_WorkOrderStateId ");
			strSql.Append(" FROM T_Wo_WorkOrderTypeState ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" F_WorkOrderTypeId,F_WorkOrderStateId ");
			strSql.Append(" FROM T_Wo_WorkOrderTypeState ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "T_Wo_WorkOrderTypeState";
			parameters[1].Value = "F_WorkOrderTypeId";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
	}
}

