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

            strSql.Append("update Valve set ");
            strSql.Append("Valve_Name=@Valve_Name,");
            strSql.Append("Valve_longitude=@Valve_longitude,");
            strSql.Append("Valve_dimensionality=@Valve_dimensionality,");
            strSql.Append("Valve_Description=@Valve_Description,");
            strSql.Append("Msc_ID=@Msc_ID,");
            strSql.Append("Valve_Brand=@Valve_Brand,");
            strSql.Append("Valve_Specification=@Valve_Specification,");
            strSql.Append("Valve_Diameter=@Valve_Diameter,");
            strSql.Append("Valve_Manufacturer=@Valve_Manufacturer");
            strSql.Append(" where Valve_ID=@Valve_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Valve_Name",           SqlDbType.NVarChar,  50),
                new SqlParameter("@Valve_longitude",      SqlDbType.Float,      8),
                new SqlParameter("@Valve_dimensionality", SqlDbType.Float,      8),
                new SqlParameter("@Valve_Description",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Msc_ID",               SqlDbType.Int,        4),
                new SqlParameter("@Valve_Brand",          SqlDbType.NVarChar,  50),
                new SqlParameter("@Valve_Specification",  SqlDbType.NVarChar, 150),
                new SqlParameter("@Valve_Diameter",       SqlDbType.NChar,     10),
                new SqlParameter("@Valve_Manufacturer",   SqlDbType.NChar,     10),
                new SqlParameter("@Valve_ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Valve_Name;
            parameters[1].Value = model.Valve_longitude;
            parameters[2].Value = model.Valve_dimensionality;
            parameters[3].Value = model.Valve_Description;
            parameters[4].Value = model.Msc_ID;
            parameters[5].Value = model.Valve_Brand;
            parameters[6].Value = model.Valve_Specification;
            parameters[7].Value = model.Valve_Diameter;
            parameters[8].Value = model.Valve_Manufacturer;
            parameters[9].Value = model.Valve_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ValveEntity DataRowToModel(DataRow row)
        {
            ValveEntity model = new ValveEntity();

            if (row != null)
            {
                if (row["Valve_ID"] != null && row["Valve_ID"].ToString() != "")
                {
                    model.Valve_ID = int.Parse(row["Valve_ID"].ToString());
                }
                if (row["Valve_Name"] != null)
                {
                    model.Valve_Name = row["Valve_Name"].ToString();
                }
                if (row["Valve_longitude"] != null && row["Valve_longitude"].ToString() != "")
                {
                    model.Valve_longitude = decimal.Parse(row["Valve_longitude"].ToString());
                }
                if (row["Valve_dimensionality"] != null && row["Valve_dimensionality"].ToString() != "")
                {
                    model.Valve_dimensionality = decimal.Parse(row["Valve_dimensionality"].ToString());
                }
                if (row["Valve_Description"] != null)
                {
                    model.Valve_Description = row["Valve_Description"].ToString();
                }
                if (row["Msc_ID"] != null && row["Msc_ID"].ToString() != "")
                {
                    model.Msc_ID = int.Parse(row["Msc_ID"].ToString());
                }
                if (row["Valve_Brand"] != null)
                {
                    model.Valve_Brand = row["Valve_Brand"].ToString();
                }
                if (row["Valve_Specification"] != null)
                {
                    model.Valve_Specification = row["Valve_Specification"].ToString();
                }
                if (row["Valve_Diameter"] != null)
                {
                    model.Valve_Diameter = row["Valve_Diameter"].ToString();
                }
                if (row["Valve_Manufacturer"] != null)
                {
                    model.Valve_Manufacturer = row["Valve_Manufacturer"].ToString();
                }
            }
            return(model);
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ValveEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Valve(");
            strSql.Append("Valve_Name,Valve_longitude,Valve_dimensionality,Valve_Description,Msc_ID,Valve_Brand,Valve_Specification,Valve_Diameter,Valve_Manufacturer)");
            strSql.Append(" values (");
            strSql.Append("@Valve_Name,@Valve_longitude,@Valve_dimensionality,@Valve_Description,@Msc_ID,@Valve_Brand,@Valve_Specification,@Valve_Diameter,@Valve_Manufacturer)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Valve_Name",           SqlDbType.NVarChar,  50),
                new SqlParameter("@Valve_longitude",      SqlDbType.Float,      8),
                new SqlParameter("@Valve_dimensionality", SqlDbType.Float,      8),
                new SqlParameter("@Valve_Description",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Msc_ID",               SqlDbType.Int,        4),
                new SqlParameter("@Valve_Brand",          SqlDbType.NVarChar,  50),
                new SqlParameter("@Valve_Specification",  SqlDbType.NVarChar, 150),
                new SqlParameter("@Valve_Diameter",       SqlDbType.NChar,     10),
                new SqlParameter("@Valve_Manufacturer",   SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.Valve_Name;
            parameters[1].Value = model.Valve_longitude;
            parameters[2].Value = model.Valve_dimensionality;
            parameters[3].Value = model.Valve_Description;
            parameters[4].Value = model.Msc_ID;
            parameters[5].Value = model.Valve_Brand;
            parameters[6].Value = model.Valve_Specification;
            parameters[7].Value = model.Valve_Diameter;
            parameters[8].Value = model.Valve_Manufacturer;

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

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

            strSql.Append("select  top 1 Valve_ID,Valve_Name,Valve_longitude,Valve_dimensionality,Valve_Description,Msc_ID,Valve_Brand,Valve_Specification,Valve_Diameter,Valve_Manufacturer from Valve ");
            strSql.Append(" where Valve_ID=@Valve_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Valve_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = Valve_ID;

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

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