Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Demo.Model.tb_JC_BOMSub model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_JC_BOMSub set ");
            strSql.Append("MaterialNO=@MaterialNO,");
            strSql.Append("MaterialType=@MaterialType,");
            strSql.Append("ParentNO=@ParentNO,");
            strSql.Append("Amount=@Amount,");
            strSql.Append("LeadTimeOffset=@LeadTimeOffset,");
            strSql.Append("BackFlush=@BackFlush,");
            strSql.Append("Status=@Status");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MaterialNO",     SqlDbType.NVarChar, 64),
                new SqlParameter("@MaterialType",   SqlDbType.NVarChar,  1),
                new SqlParameter("@ParentNO",       SqlDbType.NVarChar, 64),
                new SqlParameter("@Amount",         SqlDbType.Decimal,   9),
                new SqlParameter("@LeadTimeOffset", SqlDbType.Decimal,   9),
                new SqlParameter("@BackFlush",      SqlDbType.NVarChar,  1),
                new SqlParameter("@Status",         SqlDbType.NVarChar,  1),
                new SqlParameter("@ID",             SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = model.MaterialNO;
            parameters[1].Value = model.MaterialType;
            parameters[2].Value = model.ParentNO;
            parameters[3].Value = model.Amount;
            parameters[4].Value = model.LeadTimeOffset;
            parameters[5].Value = model.BackFlush;
            parameters[6].Value = model.Status;
            parameters[7].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Demo.Model.tb_JC_BOMSub DataRowToModel(DataRow row)
 {
     Demo.Model.tb_JC_BOMSub model = new Demo.Model.tb_JC_BOMSub();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["MaterialNO"] != null)
         {
             model.MaterialNO = row["MaterialNO"].ToString();
         }
         if (row["MaterialType"] != null)
         {
             model.MaterialType = row["MaterialType"].ToString();
         }
         if (row["ParentNO"] != null)
         {
             model.ParentNO = row["ParentNO"].ToString();
         }
         if (row["Amount"] != null && row["Amount"].ToString() != "")
         {
             model.Amount = decimal.Parse(row["Amount"].ToString());
         }
         if (row["LeadTimeOffset"] != null && row["LeadTimeOffset"].ToString() != "")
         {
             model.LeadTimeOffset = decimal.Parse(row["LeadTimeOffset"].ToString());
         }
         if (row["BackFlush"] != null)
         {
             model.BackFlush = row["BackFlush"].ToString();
         }
         if (row["Status"] != null)
         {
             model.Status = row["Status"].ToString();
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Demo.Model.tb_JC_BOMSub model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_JC_BOMSub(");
            strSql.Append("ID,MaterialNO,MaterialType,ParentNO,Amount,LeadTimeOffset,BackFlush,Status)");
            strSql.Append(" values (");
            strSql.Append("@ID,@MaterialNO,@MaterialType,@ParentNO,@Amount,@LeadTimeOffset,@BackFlush,@Status)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",             SqlDbType.NVarChar, 64),
                new SqlParameter("@MaterialNO",     SqlDbType.NVarChar, 64),
                new SqlParameter("@MaterialType",   SqlDbType.NVarChar,  1),
                new SqlParameter("@ParentNO",       SqlDbType.NVarChar, 64),
                new SqlParameter("@Amount",         SqlDbType.Decimal,   9),
                new SqlParameter("@LeadTimeOffset", SqlDbType.Decimal,   9),
                new SqlParameter("@BackFlush",      SqlDbType.NVarChar,  1),
                new SqlParameter("@Status",         SqlDbType.NVarChar, 1)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.MaterialNO;
            parameters[2].Value = model.MaterialType;
            parameters[3].Value = model.ParentNO;
            parameters[4].Value = model.Amount;
            parameters[5].Value = model.LeadTimeOffset;
            parameters[6].Value = model.BackFlush;
            parameters[7].Value = model.Status;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Demo.Model.tb_JC_BOMSub GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MaterialNO,MaterialType,ParentNO,Amount,LeadTimeOffset,BackFlush,Status from tb_JC_BOMSub ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = ID;

            Demo.Model.tb_JC_BOMSub model = new Demo.Model.tb_JC_BOMSub();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }