Exemple #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TaskTypeModel DataRowToModel(DataRow row)
        {
            TaskTypeModel model = new TaskTypeModel();

            if (row != null)
            {
                if (row["TaskTypeCode"] != null && row["TaskTypeCode"].ToString() != "")
                {
                    model.TaskTypeCode = int.Parse(row["TaskTypeCode"].ToString());
                }
                if (row["TaskTypeName"] != null)
                {
                    model.TaskTypeName = row["TaskTypeName"].ToString();
                }
                if (row["TaskTypeValue"] != null)
                {
                    model.TaskTypeValue = row["TaskTypeValue"].ToString();
                }
                if (row["StartLogicAreaID"] != null && row["StartLogicAreaID"].ToString() != "")
                {
                    model.StartLogicAreaID = int.Parse(row["StartLogicAreaID"].ToString());
                }
                if (row["StartDevice"] != null)
                {
                    model.StartDevice = row["StartDevice"].ToString();
                }
                if (row["EndLogicAreaID"] != null && row["EndLogicAreaID"].ToString() != "")
                {
                    model.EndLogicAreaID = int.Parse(row["EndLogicAreaID"].ToString());
                }
                if (row["EndDevice"] != null)
                {
                    model.EndDevice = row["EndDevice"].ToString();
                }
                if (row["ProductStartStatus"] != null)
                {
                    model.ProductStartStatus = row["ProductStartStatus"].ToString();
                }
                if (row["ProductEndStatus"] != null)
                {
                    model.ProductEndStatus = row["ProductEndStatus"].ToString();
                }
                if (row["NeedTime"] != null && row["NeedTime"].ToString() != "")
                {
                    model.NeedTime = int.Parse(row["NeedTime"].ToString());
                }
                if (row["TaskTypeMode"] != null)
                {
                    model.TaskTypeMode = row["TaskTypeMode"].ToString();
                }
                if (row["TaskTypeDescribe"] != null)
                {
                    model.TaskTypeDescribe = row["TaskTypeDescribe"].ToString();
                }
            }
            return(model);
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TaskTypeModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TaskType set ");
            strSql.Append("TaskTypeName=@TaskTypeName,");
            strSql.Append("TaskTypeValue=@TaskTypeValue,");
            strSql.Append("StartLogicAreaID=@StartLogicAreaID,");
            strSql.Append("StartDevice=@StartDevice,");
            strSql.Append("EndLogicAreaID=@EndLogicAreaID,");
            strSql.Append("EndDevice=@EndDevice,");
            strSql.Append("ProductStartStatus=@ProductStartStatus,");
            strSql.Append("ProductEndStatus=@ProductEndStatus,");
            strSql.Append("NeedTime=@NeedTime,");
            strSql.Append("TaskTypeMode=@TaskTypeMode,");
            strSql.Append("TaskTypeDescribe=@TaskTypeDescribe");
            strSql.Append(" where TaskTypeCode=@TaskTypeCode");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskTypeName",       SqlDbType.NVarChar,  50),
                new SqlParameter("@TaskTypeValue",      SqlDbType.NVarChar,  50),
                new SqlParameter("@StartLogicAreaID",   SqlDbType.Int,        4),
                new SqlParameter("@StartDevice",        SqlDbType.NVarChar,  50),
                new SqlParameter("@EndLogicAreaID",     SqlDbType.Int,        4),
                new SqlParameter("@EndDevice",          SqlDbType.NVarChar,  50),
                new SqlParameter("@ProductStartStatus", SqlDbType.NVarChar,  50),
                new SqlParameter("@ProductEndStatus",   SqlDbType.NVarChar,  50),
                new SqlParameter("@NeedTime",           SqlDbType.Int,        4),
                new SqlParameter("@TaskTypeMode",       SqlDbType.NChar,     10),
                new SqlParameter("@TaskTypeDescribe",   SqlDbType.NVarChar, 100),
                new SqlParameter("@TaskTypeCode",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.TaskTypeName;
            parameters[1].Value  = model.TaskTypeValue;
            parameters[2].Value  = model.StartLogicAreaID;
            parameters[3].Value  = model.StartDevice;
            parameters[4].Value  = model.EndLogicAreaID;
            parameters[5].Value  = model.EndDevice;
            parameters[6].Value  = model.ProductStartStatus;
            parameters[7].Value  = model.ProductEndStatus;
            parameters[8].Value  = model.NeedTime;
            parameters[9].Value  = model.TaskTypeMode;
            parameters[10].Value = model.TaskTypeDescribe;
            parameters[11].Value = model.TaskTypeCode;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TaskTypeModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TaskType(");
            strSql.Append("TaskTypeName,TaskTypeValue,StartLogicAreaID,StartDevice,EndLogicAreaID,EndDevice,ProductStartStatus,ProductEndStatus,NeedTime,TaskTypeMode,TaskTypeDescribe)");
            strSql.Append(" values (");
            strSql.Append("@TaskTypeName,@TaskTypeValue,@StartLogicAreaID,@StartDevice,@EndLogicAreaID,@EndDevice,@ProductStartStatus,@ProductEndStatus,@NeedTime,@TaskTypeMode,@TaskTypeDescribe)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskTypeName",       SqlDbType.NVarChar, 50),
                new SqlParameter("@TaskTypeValue",      SqlDbType.NVarChar, 50),
                new SqlParameter("@StartLogicAreaID",   SqlDbType.Int,       4),
                new SqlParameter("@StartDevice",        SqlDbType.NVarChar, 50),
                new SqlParameter("@EndLogicAreaID",     SqlDbType.Int,       4),
                new SqlParameter("@EndDevice",          SqlDbType.NVarChar, 50),
                new SqlParameter("@ProductStartStatus", SqlDbType.NVarChar, 50),
                new SqlParameter("@ProductEndStatus",   SqlDbType.NVarChar, 50),
                new SqlParameter("@NeedTime",           SqlDbType.Int,       4),
                new SqlParameter("@TaskTypeMode",       SqlDbType.NChar,    10),
                new SqlParameter("@TaskTypeDescribe",   SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.TaskTypeName;
            parameters[1].Value  = model.TaskTypeValue;
            parameters[2].Value  = model.StartLogicAreaID;
            parameters[3].Value  = model.StartDevice;
            parameters[4].Value  = model.EndLogicAreaID;
            parameters[5].Value  = model.EndDevice;
            parameters[6].Value  = model.ProductStartStatus;
            parameters[7].Value  = model.ProductEndStatus;
            parameters[8].Value  = model.NeedTime;
            parameters[9].Value  = model.TaskTypeMode;
            parameters[10].Value = model.TaskTypeDescribe;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TaskTypeModel GetModel(int TaskTypeCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 TaskTypeCode,TaskTypeName,TaskTypeValue,StartLogicAreaID,StartDevice,EndLogicAreaID,EndDevice,ProductStartStatus,ProductEndStatus,NeedTime,TaskTypeMode,TaskTypeDescribe from TaskType ");
            strSql.Append(" where TaskTypeCode=@TaskTypeCode");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskTypeCode", SqlDbType.Int, 4)
            };
            parameters[0].Value = TaskTypeCode;

            TaskTypeModel model = new TaskTypeModel();
            DataSet       ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(TaskTypeModel model)
 {
     return(dal.Update(model));
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TaskTypeModel model)
 {
     return(dal.Add(model));
 }