Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hownet.Model.SumReportInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SumReportInfo set ");
            strSql.Append("MainID=@MainID,");
            strSql.Append("ColorID=@ColorID,");
            strSql.Append("ColorOneID=@ColorOneID,");
            strSql.Append("ColorTwoID=@ColorTwoID,");
            strSql.Append("SizeID=@SizeID,");
            strSql.Append("LastAmount=@LastAmount,");
            strSql.Append("InAmount=@InAmount,");
            strSql.Append("OutAmount=@OutAmount,");
            strSql.Append("Amount=@Amount");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MainID",     SqlDbType.Int,  4),
                new SqlParameter("@ColorID",    SqlDbType.Int,  4),
                new SqlParameter("@ColorOneID", SqlDbType.Int,  4),
                new SqlParameter("@ColorTwoID", SqlDbType.Int,  4),
                new SqlParameter("@SizeID",     SqlDbType.Int,  4),
                new SqlParameter("@LastAmount", SqlDbType.Real, 4),
                new SqlParameter("@InAmount",   SqlDbType.Real, 4),
                new SqlParameter("@OutAmount",  SqlDbType.Real, 4),
                new SqlParameter("@Amount",     SqlDbType.Real, 4),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.MainID;
            parameters[1].Value = model.ColorID;
            parameters[2].Value = model.ColorOneID;
            parameters[3].Value = model.ColorTwoID;
            parameters[4].Value = model.SizeID;
            parameters[5].Value = model.LastAmount;
            parameters[6].Value = model.InAmount;
            parameters[7].Value = model.OutAmount;
            parameters[8].Value = model.Amount;
            parameters[9].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hownet.Model.SumReportInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SumReportInfo(");
            strSql.Append("MainID,ColorID,ColorOneID,ColorTwoID,SizeID,LastAmount,InAmount,OutAmount,Amount)");
            strSql.Append(" values (");
            strSql.Append("@MainID,@ColorID,@ColorOneID,@ColorTwoID,@SizeID,@LastAmount,@InAmount,@OutAmount,@Amount)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MainID",     SqlDbType.Int,  4),
                new SqlParameter("@ColorID",    SqlDbType.Int,  4),
                new SqlParameter("@ColorOneID", SqlDbType.Int,  4),
                new SqlParameter("@ColorTwoID", SqlDbType.Int,  4),
                new SqlParameter("@SizeID",     SqlDbType.Int,  4),
                new SqlParameter("@LastAmount", SqlDbType.Real, 4),
                new SqlParameter("@InAmount",   SqlDbType.Real, 4),
                new SqlParameter("@OutAmount",  SqlDbType.Real, 4),
                new SqlParameter("@Amount",     SqlDbType.Real, 4)
            };
            parameters[0].Value = model.MainID;
            parameters[1].Value = model.ColorID;
            parameters[2].Value = model.ColorOneID;
            parameters[3].Value = model.ColorTwoID;
            parameters[4].Value = model.SizeID;
            parameters[5].Value = model.LastAmount;
            parameters[6].Value = model.InAmount;
            parameters[7].Value = model.OutAmount;
            parameters[8].Value = model.Amount;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hownet.Model.SumReportInfo GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MainID,ColorID,ColorOneID,ColorTwoID,SizeID,LastAmount,InAmount,OutAmount,Amount from SumReportInfo ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && 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"] != null && ds.Tables[0].Rows[0]["MainID"].ToString() != "")
                {
                    model.MainID = int.Parse(ds.Tables[0].Rows[0]["MainID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ColorID"] != null && ds.Tables[0].Rows[0]["ColorID"].ToString() != "")
                {
                    model.ColorID = int.Parse(ds.Tables[0].Rows[0]["ColorID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ColorOneID"] != null && ds.Tables[0].Rows[0]["ColorOneID"].ToString() != "")
                {
                    model.ColorOneID = int.Parse(ds.Tables[0].Rows[0]["ColorOneID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ColorTwoID"] != null && ds.Tables[0].Rows[0]["ColorTwoID"].ToString() != "")
                {
                    model.ColorTwoID = int.Parse(ds.Tables[0].Rows[0]["ColorTwoID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SizeID"] != null && ds.Tables[0].Rows[0]["SizeID"].ToString() != "")
                {
                    model.SizeID = int.Parse(ds.Tables[0].Rows[0]["SizeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastAmount"] != null && ds.Tables[0].Rows[0]["LastAmount"].ToString() != "")
                {
                    model.LastAmount = decimal.Parse(ds.Tables[0].Rows[0]["LastAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["InAmount"] != null && ds.Tables[0].Rows[0]["InAmount"].ToString() != "")
                {
                    model.InAmount = decimal.Parse(ds.Tables[0].Rows[0]["InAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OutAmount"] != null && ds.Tables[0].Rows[0]["OutAmount"].ToString() != "")
                {
                    model.OutAmount = decimal.Parse(ds.Tables[0].Rows[0]["OutAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Amount"] != null && ds.Tables[0].Rows[0]["Amount"].ToString() != "")
                {
                    model.Amount = decimal.Parse(ds.Tables[0].Rows[0]["Amount"].ToString());
                }
                model.A = 1;
                return(model);
            }
            else
            {
                return(null);
            }
        }