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

            strSql.Append("update tb_OrdeDistribution set ");
            strSql.Append("OrderId=@OrderId,");
            strSql.Append("TypeId=@TypeId,");
            strSql.Append("PriceType=@PriceType,");
            strSql.Append("DistributionNum=@DistributionNum,");
            strSql.Append("WorkersId=@WorkersId,");
            strSql.Append("DistributionId=@DistributionId,");
            strSql.Append("Price=@Price,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderId",         SqlDbType.Int,        4),
                new SqlParameter("@TypeId",          SqlDbType.Int,        4),
                new SqlParameter("@PriceType",       SqlDbType.Int,        4),
                new SqlParameter("@DistributionNum", SqlDbType.NVarChar, 100),
                new SqlParameter("@WorkersId",       SqlDbType.Int,        4),
                new SqlParameter("@DistributionId",  SqlDbType.Int,        4),
                new SqlParameter("@Price",           SqlDbType.Decimal,    9),
                new SqlParameter("@Remark",          SqlDbType.NText),
                new SqlParameter("@Id",              SqlDbType.Int, 4)
            };
            parameters[0].Value = model.OrderId;
            parameters[1].Value = model.TypeId;
            parameters[2].Value = model.PriceType;
            parameters[3].Value = model.DistributionNum;
            parameters[4].Value = model.WorkersId;
            parameters[5].Value = model.DistributionId;
            parameters[6].Value = model.Price;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Leadin.Model.OrdeDistribution DataRowToModel(DataRow row)
 {
     Leadin.Model.OrdeDistribution model = new Leadin.Model.OrdeDistribution();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["OrderId"] != null && row["OrderId"].ToString() != "")
         {
             model.OrderId = int.Parse(row["OrderId"].ToString());
         }
         if (row["TypeId"] != null && row["TypeId"].ToString() != "")
         {
             model.TypeId = int.Parse(row["TypeId"].ToString());
         }
         if (row["PriceType"] != null && row["PriceType"].ToString() != "")
         {
             model.PriceType = int.Parse(row["PriceType"].ToString());
         }
         if (row["DistributionNum"] != null)
         {
             model.DistributionNum = row["DistributionNum"].ToString();
         }
         if (row["WorkersId"] != null && row["WorkersId"].ToString() != "")
         {
             model.WorkersId = int.Parse(row["WorkersId"].ToString());
         }
         if (row["DistributionId"] != null && row["DistributionId"].ToString() != "")
         {
             model.DistributionId = int.Parse(row["DistributionId"].ToString());
         }
         if (row["Price"] != null && row["Price"].ToString() != "")
         {
             model.Price = decimal.Parse(row["Price"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Leadin.Model.OrdeDistribution model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_OrdeDistribution(");
            strSql.Append("OrderId,TypeId,PriceType,DistributionNum,WorkersId,DistributionId,Price,Remark)");
            strSql.Append(" values (");
            strSql.Append("@OrderId,@TypeId,@PriceType,@DistributionNum,@WorkersId,@DistributionId,@Price,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderId",         SqlDbType.Int,        4),
                new SqlParameter("@TypeId",          SqlDbType.Int,        4),
                new SqlParameter("@PriceType",       SqlDbType.Int,        4),
                new SqlParameter("@DistributionNum", SqlDbType.NVarChar, 100),
                new SqlParameter("@WorkersId",       SqlDbType.Int,        4),
                new SqlParameter("@DistributionId",  SqlDbType.Int,        4),
                new SqlParameter("@Price",           SqlDbType.Decimal,    9),
                new SqlParameter("@Remark",          SqlDbType.NText)
            };
            parameters[0].Value = model.OrderId;
            parameters[1].Value = model.TypeId;
            parameters[2].Value = model.PriceType;
            parameters[3].Value = model.DistributionNum;
            parameters[4].Value = model.WorkersId;
            parameters[5].Value = model.DistributionId;
            parameters[6].Value = model.Price;
            parameters[7].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Leadin.Model.OrdeDistribution GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,OrderId,TypeId,PriceType,DistributionNum,WorkersId,DistributionId,Price,Remark from tb_OrdeDistribution ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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