📄 st_flower.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections ;
namespace ST_GROUP.FlowerPrearrange
{
/// <summary>
/// ST_Flower description for Flower。
/// </summary>
public class ST_Flower:ST_Base
{
public ST_Flower()
{
}
//get all data of Flowers
public DataView ST_GetFlower()
{
String ST_strsql;
DataSet ST_myDs;
ST_strsql="SELECT ST_Flower.*, ST_FlowerType.ST_Name AS ST_TypeName FROM ST_Flower INNER JOIN ST_FlowerType ON ST_Flower.ST_Type = ST_FlowerType.ST_Id";
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
//get top ten best salers
public DataView ST_GetFlowerTop10()
{
String ST_strsql;
DataSet ST_myDs;
ST_strsql="select top 10 ST_id,ST_name from ST_Flower order by ST_sales DESC";
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
/// <summary>
/// add Flower,Operator Storeprocedure "ST_AddFlower"
/// </summary>
/// <param name="tempary">Flower detail,Kind:ArrayList</param>
/// <returns></returns>
public void ST_AddFlower(ArrayList tempary)
{
SqlConnection ST_myCn=new SqlConnection(ST_strConn);
SqlCommand ST_myCm=new SqlCommand("ST_AddFlower",ST_myCn);
ST_myCm.CommandType =CommandType.StoredProcedure ;
ST_myCm.Parameters.Add(new SqlParameter("@ST_name",SqlDbType.VarChar,100));
ST_myCm.Parameters["@ST_name"].Value =tempary[0];
ST_myCm.Parameters.Add(new SqlParameter("@ST_type",SqlDbType.Int));
ST_myCm.Parameters["@ST_type"].Value =tempary[1];
ST_myCm.Parameters.Add(new SqlParameter("@ST_price",SqlDbType.Decimal ));
ST_myCm.Parameters["@ST_price"].Value =tempary[2];
ST_myCm.Parameters.Add(new SqlParameter("@ST_discount",SqlDbType.Decimal ));
ST_myCm.Parameters["@ST_discount"].Value =tempary[3];
ST_myCm.Parameters.Add(new SqlParameter("@ST_cover",SqlDbType.Image ));
ST_myCm.Parameters["@ST_cover"].Value =tempary[4];
ST_myCm.Parameters.Add(new SqlParameter("@ST_description",SqlDbType.Text ));
ST_myCm.Parameters["@ST_description"].Value =tempary[5];
ST_myCm.Parameters.Add(new SqlParameter("@ST_hits",SqlDbType.Int));
ST_myCm.Parameters["@ST_hits"].Value =tempary[6];
ST_myCm.Parameters.Add(new SqlParameter("@ST_sales",SqlDbType.Int));
ST_myCm.Parameters["@ST_sales"].Value =tempary[7];
ST_myCm.Parameters.Add(new SqlParameter("@ST_status",SqlDbType.Bit) );
ST_myCm.Parameters["@ST_status"].Value =tempary[8];
try
{
ST_myCn.Open() ;
ST_myCm.ExecuteNonQuery() ;
}
catch(System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
finally
{
ST_myCm.Dispose() ;
ST_myCn.Close() ;
}
}
/// <summary>
/// Delete ST_Flower By Flowerid
/// </summary>
/// <param name="FlowerId"></param>
public void ST_DeleteFlowerById(int FlowerId)
{
ST_strSQL = "Delete From ST_Flower Where ST_id="+FlowerId;
try
{
ST_ExecuteSql(ST_strSQL);
}
catch
{
throw new Exception("删除失败!");
}
}
/// <summary>
/// Get ST_Flower Cover By FlowerId
/// </summary>
/// <param name="FlowerId">FlowerId</param>
/// <returns></returns>
///
public DataView ST_GetFlowerCover(int FlowerId)
{
String ST_strsql;
DataSet ST_myDs;
ST_strsql="select ST_cover from ST_Flower where ST_id="+FlowerId;
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
/// <summary>
/// Get ST_Flower Message By ST_FlowerType
/// </summary>
/// <param name="id">ST_FlowerType'Id</param>
/// <returns></returns>
public SqlDataReader ST_GetFlowerMessage(int FlowerTypeId)
{
string ST_strsql;
SqlDataReader ST_result;
try
{
SqlConnection ST_myCn=new SqlConnection(ST_strConn);
ST_strsql="select ST_id,ST_name,ST_discount,ST_price,ST_type ,ST_image=case when(not ST_Cover is null) then ' <img src=ST_ReadFlowerCover.aspx?id='+cast(ST_id as varchar(10))+' Border=1 width=80 height=120>' else ' <img src=img/pic.jpg border=1 width=80 height=120>' end from ST_Flower where ST_type="+FlowerTypeId;
SqlCommand ST_myCm=new SqlCommand(ST_strsql,ST_myCn);
ST_myCn.Open ();
ST_result=ST_myCm.ExecuteReader(CommandBehavior.CloseConnection);
return ST_result;
}
catch(System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
}
public DataView ST_GetNewFlower()
{
String ST_strsql;
DataSet ST_myDs;
ST_strsql="select top 10 ST_id,ST_name from ST_Flower order by ST_id desc";
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
public SqlDataReader ST_GetFlowerByHits()
{
string ST_strsql;
SqlDataReader ST_result;
try
{
SqlConnection ST_myCn=new SqlConnection(ST_strConn);
ST_strsql="select top 10 ST_id,ST_name,ST_descr=' '+SUBSTRING(ST_description,0,100)+'......',ST_image=case when(not ST_Cover is null) then ' <img src=ST_ReadFlowerCover.aspx?id='+cast(ST_id as varchar(10))+' Border=1 width=70 height=100>' else ' <img src=img/pic.jpg border=1 width=70 height=100>' end from ST_Flower order by ST_hits DESC";
SqlCommand ST_myCm=new SqlCommand(ST_strsql,ST_myCn);
ST_myCn.Open ();
ST_result=ST_myCm.ExecuteReader(CommandBehavior.CloseConnection);
return ST_result;
}
catch(System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
}
public DataRow ST_GetFlowerDetail(int FlowerId)
{
string ST_strsql;
DataSet ST_myDs;
try
{
ST_strsql="select ST_FlowerType.ST_Name as ST_FlowerTypeName,ST_Flower.ST_id,ST_Flower.ST_name,ST_price,ST_type,ST_Description,ST_discount,ST_hits,ST_status,ST_sales,ST_image=case when(not ST_Cover is null) then ' <img src=ST_ReadFlowerCover.aspx?id='+cast(ST_Flower.ST_id as varchar(10))+' Border=1 width=80 height=120>' else ' <img src=img/pic.jpg border=1 width=80 height=120>' end from ST_Flower join ST_FlowerType on ST_Flower.ST_type=ST_FlowerType.ST_id where ST_Flower.ST_id="+FlowerId;
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].Rows[0];
}
catch(System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
}
/// <summary>
/// Add Flower hits
/// </summary>
/// <param name="FlowerId">Flower ID</param>
/// <returns></returns>
public static void ST_Hits(string FlowerId)
{
ST_strSQL = "Update ST_Flower set ST_hits=ST_hits+1 Where ST_id= " + FlowerId;
try
{
ST_ExecuteSql4Ds(ST_strSQL);
}
catch
{
throw new Exception("更新点击率失败!!");
}
}
/// <summary>
/// ST_Search Flower
/// </summary>
/// <param name="strCondition">search condition</param>
/// <returns></returns>
public static DataSet ST_Search(string strCondition)
{
ST_strSQL = "Select * From ST_FlowerV Where 1=1 " + strCondition + " Order by ST_id";
try
{
return ST_ExecuteSql4Ds(ST_strSQL);
}
catch
{
throw new Exception("查询失败!!");
}
}
/// <summary>
/// ST_Search ST_Flower By name,author,translator,publisher
/// </summary>
/// <param name="Msg"></param>
/// <returns></returns>
public DataSet ST_SearchFlower(string Msg)
{
string ST_str;
ST_str="select * from ST_Flower where ST_name like '%" + Msg + "%' or ST_author like '%" + Msg + "%' or translator like '%" + Msg + "%' or publisher like '%" + Msg + "%' ";
DataSet ST_myDs;
ST_myDs=ST_ExecuteSql4Ds(ST_str);
return ST_myDs;
}
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="pwd"></param>
/// <param name="OrderId"></param>
/// <returns></returns>
public DataSet ST_GetOrderDetail(string name,string pwd,int OrderId)
{
string ST_str;
ST_str=" SELECT ST_Orders.ST_Id, ST_OrderDetails.ST_Quantity, ST_Flower.ST_Name,ST_Flower.ST_Price,ST_Flower.ST_Discount" +
" FROM ST_UserInfo INNER JOIN ST_Orders ON ST_UserInfo.ST_Id = ST_Orders.ST_UserId INNER JOIN" +
" ST_OrderDetails INNER JOIN ST_Flower ON ST_OrderDetails.ST_FlowerId = .ST_Flower.ST_Id ON " +
" ST_Orders.ST_Id = ST_OrderDetails.ST_OrderId where ST_UserInfo.ST_name='"+name+"' and ST_UserInfo.ST_Password='"+
pwd+"' and ST_Orders.ST_id="+OrderId;
DataSet ST_myDs;
ST_myDs=ST_ExecuteSql4Ds(ST_str);
return ST_myDs;
}
}
public class ST_FlowerType:ST_Base
{
public ST_FlowerType()
{
}
//get all data of Flower type
public DataView ST_GetFlowerType()
{
String ST_strsql;
DataSet ST_myDs;
ST_strsql="select * from ST_FlowerType order by ST_id";
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
/// <summary>
/// add types
/// </summary>
/// <param name="name">name</param>
/// <param name="memo">memo</param>
/// <returns></returns>
public void ST_Add(string name,string memo)
{
if(ST_IfExist(name))
{
throw new Exception("type existed");
}
else
{
ST_strSQL = "Insert into ST_FlowerType (ST_Name,ST_memo) Values("
+ "'" + name + "',"
+ "'" + memo + "')" ;
try
{
ST_ExecuteSql(ST_strSQL);
}
catch
{
throw new Exception("注册失败");
}
}
}
/// <summary>
/// delete type
/// </summary>
/// <param name="id">jFlower_id</param>
public void ST_delete(int id)
{
ST_strSQL = "Delete From ST_FlowerType Where ST_id="+id;
try
{
ST_ExecuteSql(ST_strSQL);
}
catch
{
throw new Exception("delete failed!");
}
}
/// <summary>
/// if Flower existed
/// </summary>
/// <param name="BTName"></param>
/// <returns></returns>
public bool ST_IfExist(string BTName)
{
ST_strSQL = "Select Id from ST_FlowerType Where ST_Name='"
+ BTName + "'";
try
{
ST_ExecuteSql4Value(ST_strSQL);
return true;
}
catch
{
return false;
}
}
}
public class Comment:ST_Base
{
/// <summary>
/// Get ST_Flower Comment By FlowerId
/// </summary>
/// <param name="FlowerId"></param>
/// <returns></returns>
public DataView ST_GetCommentByFlowerId(int FlowerId)
{
string ST_strsql;
DataSet ST_myDs;
ST_strsql="select * from ST_Comment where ST_Flowerid="+FlowerId;
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
public DataView ST_GetCommentTop10()
{
string ST_strsql;
DataSet ST_myDs;
ST_strsql="select top 10 ST_Flowerid, ST_CommentCaption=ST_UserName+':'+SUBSTRING(ST_Caption,0,50) from ST_Comment ";
ST_myDs=ST_ExecuteSql4Ds(ST_strsql);
return ST_myDs.Tables[0].DefaultView ;
}
/// <summary>
/// Insert ST_Flower's Comment
/// </summary>
/// <param name="arr"></param>
public void ST_InsertComment(ArrayList arr)
{
SqlConnection ST_myCn=new SqlConnection(ST_strConn);
SqlCommand ST_myCm=new SqlCommand("ST_InsertComment",ST_myCn);
ST_myCm.CommandType =CommandType.StoredProcedure ;
ST_myCm.Parameters.Add(new SqlParameter("@ST_FlowerId",SqlDbType.Int));
ST_myCm.Parameters["@ST_FlowerId"].Value =arr[0];
ST_myCm.Parameters.Add(new SqlParameter("@ST_UserName",SqlDbType.VarChar,50));
ST_myCm.Parameters["@ST_UserName"].Value =arr[1];
ST_myCm.Parameters.Add(new SqlParameter("@ST_Email",SqlDbType.VarChar,50));
ST_myCm.Parameters["@ST_Email"].Value =arr[2];
ST_myCm.Parameters.Add(new SqlParameter("@ST_Caption",SqlDbType.VarChar,100));
ST_myCm.Parameters["@ST_Caption"].Value =arr[3];
ST_myCm.Parameters.Add(new SqlParameter("@ST_Content",SqlDbType.Text ));
ST_myCm.Parameters["@ST_Content"].Value =arr[4];
ST_myCm.Parameters.Add(new SqlParameter("@ST_PublishDate",SqlDbType.DateTime ));
ST_myCm.Parameters["@ST_PublishDate"].Value =arr[5];
try
{
ST_myCn.Open() ;
ST_myCm.ExecuteNonQuery() ;
}
catch(System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
finally
{
ST_myCm.Dispose() ;
ST_myCn.Close() ;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -