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

            if (row != null)
            {
                if (row["palletID"] != null)
                {
                    model.palletID = row["palletID"].ToString();
                }
                if (row["palletCata"] != null)
                {
                    model.palletCata = row["palletCata"].ToString();
                }
                if (row["bind"] != null && row["bind"].ToString() != "")
                {
                    if ((row["bind"].ToString() == "1") || (row["bind"].ToString().ToLower() == "true"))
                    {
                        model.bind = true;
                    }
                    else
                    {
                        model.bind = false;
                    }
                }
                if (row["stepNO"] != null && row["stepNO"].ToString() != "")
                {
                    model.stepNO = int.Parse(row["stepNO"].ToString());
                }
                if (row["batchName"] != null)
                {
                    model.batchName = row["batchName"].ToString();
                }
                if (row["tag1"] != null)
                {
                    model.tag1 = row["tag1"].ToString();
                }
                if (row["tag2"] != null)
                {
                    model.tag2 = row["tag2"].ToString();
                }
                if (row["tag3"] != null)
                {
                    model.tag3 = row["tag3"].ToString();
                }
                if (row["tag4"] != null)
                {
                    model.tag4 = row["tag4"].ToString();
                }
                if (row["tag5"] != null)
                {
                    model.tag5 = row["tag5"].ToString();
                }
            }
            return(model);
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(palletModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update pallet set ");
            strSql.Append("palletCata=@palletCata,");
            strSql.Append("bind=@bind,");
            strSql.Append("stepNO=@stepNO,");
            strSql.Append("batchName=@batchName,");
            strSql.Append("tag1=@tag1,");
            strSql.Append("tag2=@tag2,");
            strSql.Append("tag3=@tag3,");
            strSql.Append("tag4=@tag4,");
            strSql.Append("tag5=@tag5");
            strSql.Append(" where palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@palletCata", SqlDbType.NVarChar, 50),
                new SqlParameter("@bind",       SqlDbType.Bit,       1),
                new SqlParameter("@stepNO",     SqlDbType.Int,       4),
                new SqlParameter("@batchName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@tag1",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag2",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag3",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag4",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag5",       SqlDbType.NVarChar, 50),
                new SqlParameter("@palletID",   SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.palletCata;
            parameters[1].Value = model.bind;
            parameters[2].Value = model.stepNO;
            parameters[3].Value = model.batchName;
            parameters[4].Value = model.tag1;
            parameters[5].Value = model.tag2;
            parameters[6].Value = model.tag3;
            parameters[7].Value = model.tag4;
            parameters[8].Value = model.tag5;
            parameters[9].Value = model.palletID;

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

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

            strSql.Append("insert into pallet(");
            strSql.Append("palletID,palletCata,bind,stepNO,batchName,tag1,tag2,tag3,tag4,tag5)");
            strSql.Append(" values (");
            strSql.Append("@palletID,@palletCata,@bind,@stepNO,@batchName,@tag1,@tag2,@tag3,@tag4,@tag5)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@palletID",   SqlDbType.NVarChar, 50),
                new SqlParameter("@palletCata", SqlDbType.NVarChar, 50),
                new SqlParameter("@bind",       SqlDbType.Bit,       1),
                new SqlParameter("@stepNO",     SqlDbType.Int,       4),
                new SqlParameter("@batchName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@tag1",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag2",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag3",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag4",       SqlDbType.NVarChar, 50),
                new SqlParameter("@tag5",       SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.palletID;
            parameters[1].Value = model.palletCata;
            parameters[2].Value = model.bind;
            parameters[3].Value = model.stepNO;
            parameters[4].Value = model.batchName;
            parameters[5].Value = model.tag1;
            parameters[6].Value = model.tag2;
            parameters[7].Value = model.tag3;
            parameters[8].Value = model.tag4;
            parameters[9].Value = model.tag5;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public palletModel GetModel(string palletID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 palletID,palletCata,bind,stepNO,batchName,tag1,tag2,tag3,tag4,tag5 from pallet ");
            strSql.Append(" where palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@palletID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = palletID;

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

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