/// <summary> /// 增加一条数据 /// </summary> public long Add(JY.Model.OrderFormDetail model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@OrderFormID", SqlDbType.BigInt, 8), new SqlParameter("@OrderFormNo", SqlDbType.NVarChar, 50), new SqlParameter("@ProductID", SqlDbType.Int, 4), new SqlParameter("@ProductNo", SqlDbType.NVarChar, 50), new SqlParameter("@ProductName", SqlDbType.NVarChar, 50), new SqlParameter("@Spec", SqlDbType.NVarChar, 50), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Number", SqlDbType.Int, 4), new SqlParameter("@WebsitePrice", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.OrderFormID; parameters[2].Value = model.OrderFormNo; parameters[3].Value = model.ProductID; parameters[4].Value = model.ProductNo; parameters[5].Value = model.ProductName; parameters[6].Value = model.Spec; parameters[7].Value = model.Price; parameters[8].Value = model.Number; parameters[9].Value = model.WebsitePrice; parameters[10].Value = model.TotalPrice; parameters[11].Value = model.IsDelete; DbHelperSQL.RunProcedure("OrderFormDetail_ADD", parameters, out rowsAffected); return((long)parameters[0].Value); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JY.Model.OrderFormDetail model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@OrderFormID", SqlDbType.BigInt, 8), new SqlParameter("@OrderFormNo", SqlDbType.NVarChar, 50), new SqlParameter("@ProductID", SqlDbType.Int, 4), new SqlParameter("@ProductNo", SqlDbType.NVarChar, 50), new SqlParameter("@ProductName", SqlDbType.NVarChar, 50), new SqlParameter("@Spec", SqlDbType.NVarChar, 50), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Number", SqlDbType.Int, 4), new SqlParameter("@WebsitePrice", SqlDbType.Decimal, 9), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Value = model.ID; parameters[1].Value = model.OrderFormID; parameters[2].Value = model.OrderFormNo; parameters[3].Value = model.ProductID; parameters[4].Value = model.ProductNo; parameters[5].Value = model.ProductName; parameters[6].Value = model.Spec; parameters[7].Value = model.Price; parameters[8].Value = model.Number; parameters[9].Value = model.WebsitePrice; parameters[10].Value = model.TotalPrice; parameters[11].Value = model.IsDelete; DbHelperSQL.RunProcedure("OrderFormDetail_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JY.Model.OrderFormDetail GetModel(long ID) { SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = ID; JY.Model.OrderFormDetail model = new JY.Model.OrderFormDetail(); DataSet ds = DbHelperSQL.RunProcedure("OrderFormDetail_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["OrderFormID"] != null && ds.Tables[0].Rows[0]["OrderFormID"].ToString() != "") { model.OrderFormID = long.Parse(ds.Tables[0].Rows[0]["OrderFormID"].ToString()); } if (ds.Tables[0].Rows[0]["OrderFormNo"] != null && ds.Tables[0].Rows[0]["OrderFormNo"].ToString() != "") { model.OrderFormNo = ds.Tables[0].Rows[0]["OrderFormNo"].ToString(); } if (ds.Tables[0].Rows[0]["ProductID"] != null && ds.Tables[0].Rows[0]["ProductID"].ToString() != "") { model.ProductID = int.Parse(ds.Tables[0].Rows[0]["ProductID"].ToString()); } if (ds.Tables[0].Rows[0]["ProductNo"] != null && ds.Tables[0].Rows[0]["ProductNo"].ToString() != "") { model.ProductNo = ds.Tables[0].Rows[0]["ProductNo"].ToString(); } if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "") { model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString(); } if (ds.Tables[0].Rows[0]["Spec"] != null && ds.Tables[0].Rows[0]["Spec"].ToString() != "") { model.Spec = ds.Tables[0].Rows[0]["Spec"].ToString(); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Number"] != null && ds.Tables[0].Rows[0]["Number"].ToString() != "") { model.Number = int.Parse(ds.Tables[0].Rows[0]["Number"].ToString()); } if (ds.Tables[0].Rows[0]["WebsitePrice"] != null && ds.Tables[0].Rows[0]["WebsitePrice"].ToString() != "") { model.WebsitePrice = decimal.Parse(ds.Tables[0].Rows[0]["WebsitePrice"].ToString()); } if (ds.Tables[0].Rows[0]["TotalPrice"] != null && ds.Tables[0].Rows[0]["TotalPrice"].ToString() != "") { model.TotalPrice = decimal.Parse(ds.Tables[0].Rows[0]["TotalPrice"].ToString()); } if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } return(model); } else { return(null); } }