/// <summary> /// 更新一条数据 /// </summary> public bool Update(DataService.Model.SendOrder model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SendOrder set "); strSql.Append("OrderDetailID=@OrderDetailID,"); strSql.Append("GroupID=@GroupID,"); strSql.Append("BuildAddr=@BuildAddr,"); strSql.Append("SendType=@SendType,"); strSql.Append("SendArea=@SendArea,"); strSql.Append("RealArea=@RealArea,"); strSql.Append("Price=@Price,"); strSql.Append("RealPrice=@RealPrice,"); strSql.Append("Remark=@Remark,"); strSql.Append("AddTime=@AddTime"); strSql.Append(" where SendOrderID=@SendOrderID "); SqlParameter[] parameters = { new SqlParameter("@OrderDetailID", SqlDbType.Int, 4), new SqlParameter("@GroupID", SqlDbType.Int, 4), new SqlParameter("@BuildAddr", SqlDbType.VarChar, 200), new SqlParameter("@SendType", SqlDbType.Int, 4), new SqlParameter("@SendArea", SqlDbType.Decimal, 9), new SqlParameter("@RealArea", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Real, 4), new SqlParameter("@RealPrice", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@SendOrderID", SqlDbType.Int, 4) }; parameters[0].Value = model.OrderDetailID; parameters[1].Value = model.GroupID; parameters[2].Value = model.BuildAddr; parameters[3].Value = model.SendType; parameters[4].Value = model.SendArea; parameters[5].Value = model.RealArea; parameters[6].Value = model.Price; parameters[7].Value = model.RealPrice; parameters[8].Value = model.Remark; parameters[9].Value = model.AddTime; parameters[10].Value = model.SendOrderID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DataService.Model.SendOrder DataRowToModel(DataRow row) { DataService.Model.SendOrder model = new DataService.Model.SendOrder(); if (row != null) { if (row["SendOrderID"] != null && row["SendOrderID"].ToString() != "") { model.SendOrderID = int.Parse(row["SendOrderID"].ToString()); } if (row["OrderDetailID"] != null && row["OrderDetailID"].ToString() != "") { model.OrderDetailID = int.Parse(row["OrderDetailID"].ToString()); } if (row["GroupID"] != null && row["GroupID"].ToString() != "") { model.GroupID = int.Parse(row["GroupID"].ToString()); } if (row["BuildAddr"] != null) { model.BuildAddr = row["BuildAddr"].ToString(); } if (row["SendType"] != null && row["SendType"].ToString() != "") { model.SendType = int.Parse(row["SendType"].ToString()); } if (row["SendArea"] != null && row["SendArea"].ToString() != "") { model.SendArea = decimal.Parse(row["SendArea"].ToString()); } if (row["RealArea"] != null && row["RealArea"].ToString() != "") { model.RealArea = decimal.Parse(row["RealArea"].ToString()); } if (row["Price"] != null && row["Price"].ToString() != "") { model.Price = decimal.Parse(row["Price"].ToString()); } if (row["RealPrice"] != null && row["RealPrice"].ToString() != "") { model.RealPrice = decimal.Parse(row["RealPrice"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DataService.Model.SendOrder model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SendOrder("); strSql.Append("SendOrderID,OrderDetailID,GroupID,BuildAddr,SendType,SendArea,RealArea,Price,RealPrice,Remark,AddTime)"); strSql.Append(" values ("); strSql.Append("@SendOrderID,@OrderDetailID,@GroupID,@BuildAddr,@SendType,@SendArea,@RealArea,@Price,@RealPrice,@Remark,@AddTime)"); SqlParameter[] parameters = { new SqlParameter("@SendOrderID", SqlDbType.Int, 4), new SqlParameter("@OrderDetailID", SqlDbType.Int, 4), new SqlParameter("@GroupID", SqlDbType.Int, 4), new SqlParameter("@BuildAddr", SqlDbType.VarChar, 200), new SqlParameter("@SendType", SqlDbType.Int, 4), new SqlParameter("@SendArea", SqlDbType.Decimal, 9), new SqlParameter("@RealArea", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Real, 4), new SqlParameter("@RealPrice", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@AddTime", SqlDbType.DateTime) }; parameters[0].Value = model.SendOrderID; parameters[1].Value = model.OrderDetailID; parameters[2].Value = model.GroupID; parameters[3].Value = model.BuildAddr; parameters[4].Value = model.SendType; parameters[5].Value = model.SendArea; parameters[6].Value = model.RealArea; parameters[7].Value = model.Price; parameters[8].Value = model.RealPrice; parameters[9].Value = model.Remark; parameters[10].Value = model.AddTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DataService.Model.SendOrder GetModel(int SendOrderID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SendOrderID,OrderDetailID,GroupID,BuildAddr,SendType,SendArea,RealArea,Price,RealPrice,Remark,AddTime from SendOrder "); strSql.Append(" where SendOrderID=@SendOrderID "); SqlParameter[] parameters = { new SqlParameter("@SendOrderID", SqlDbType.Int, 4) }; parameters[0].Value = SendOrderID; DataService.Model.SendOrder model = new DataService.Model.SendOrder(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }