示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Hownet.Model.SamplesAmount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SamplesAmount set ");
            strSql.Append("MainID=@MainID,");
            strSql.Append("MainTableTypeID=@MainTableTypeID,");
            strSql.Append("ColorID=@ColorID,");
            strSql.Append("SizeID=@SizeID,");
            strSql.Append("Amount=@Amount,");
            strSql.Append("SamplesID=@SamplesID,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",              SqlDbType.Int,      4),
                new SqlParameter("@MainID",          SqlDbType.Int,      4),
                new SqlParameter("@MainTableTypeID", SqlDbType.Int,      4),
                new SqlParameter("@ColorID",         SqlDbType.Int,      4),
                new SqlParameter("@SizeID",          SqlDbType.Int,      4),
                new SqlParameter("@Amount",          SqlDbType.Int,      4),
                new SqlParameter("@SamplesID",       SqlDbType.Int,      4),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.MainID;
            parameters[2].Value = model.MainTableTypeID;
            parameters[3].Value = model.ColorID;
            parameters[4].Value = model.SizeID;
            parameters[5].Value = model.Amount;
            parameters[6].Value = model.SamplesID;
            parameters[7].Value = model.Remark;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hownet.Model.SamplesAmount GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MainID,MainTableTypeID,ColorID,SizeID,Amount,SamplesID,Remark from SamplesAmount ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MainID"].ToString() != "")
                {
                    model.MainID = int.Parse(ds.Tables[0].Rows[0]["MainID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MainTableTypeID"].ToString() != "")
                {
                    model.MainTableTypeID = int.Parse(ds.Tables[0].Rows[0]["MainTableTypeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ColorID"].ToString() != "")
                {
                    model.ColorID = int.Parse(ds.Tables[0].Rows[0]["ColorID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SizeID"].ToString() != "")
                {
                    model.SizeID = int.Parse(ds.Tables[0].Rows[0]["SizeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Amount"].ToString() != "")
                {
                    model.Amount = int.Parse(ds.Tables[0].Rows[0]["Amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SamplesID"].ToString() != "")
                {
                    model.SamplesID = int.Parse(ds.Tables[0].Rows[0]["SamplesID"].ToString());
                }
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                model.A      = 1;
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hownet.Model.SamplesAmount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SamplesAmount(");
            strSql.Append("MainID,MainTableTypeID,ColorID,SizeID,Amount,SamplesID,Remark)");
            strSql.Append(" values (");
            strSql.Append("@MainID,@MainTableTypeID,@ColorID,@SizeID,@Amount,@SamplesID,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MainID",          SqlDbType.Int,      4),
                new SqlParameter("@MainTableTypeID", SqlDbType.Int,      4),
                new SqlParameter("@ColorID",         SqlDbType.Int,      4),
                new SqlParameter("@SizeID",          SqlDbType.Int,      4),
                new SqlParameter("@Amount",          SqlDbType.Int,      4),
                new SqlParameter("@SamplesID",       SqlDbType.Int,      4),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.MainID;
            parameters[1].Value = model.MainTableTypeID;
            parameters[2].Value = model.ColorID;
            parameters[3].Value = model.SizeID;
            parameters[4].Value = model.Amount;
            parameters[5].Value = model.SamplesID;
            parameters[6].Value = model.Remark;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }