ʵ˹Ĺܡʵ˽ûƷ¼ݿУԱ֪˭˸ƷݸûĻԱͳƷ
 
<%@Register TagPrefix="CC" TagName="Pager" Src="CCPager.ascx"%> 
<%@ Register TagPrefix="CC" TagName="Footer" Src="Footer.ascx" %>
<%@ Register TagPrefix="CC" TagName="Header" Src="Header.ascx" %>
<%@ Page language="c#" Codebehind="BookDetail.cs" AutoEventWireup="false" Inherits="Book_Store.BookDetail" %>
<HTML>
 <HEAD>
     <title>Book Store</title> 
     <meta name="vs_targetSchema" content="http://schemas.microsoft.
com/intellisense/ie3-2nav3-0"> 
     <meta name="GENERATOR" content="YesSoftware CodeCharge v.2.0.5 using 'ASP.NET C#.ccp' build 9/27/2001"> 
     <meta name="CODE_LANGUAGE" Content="C#">
     <meta http-equiv="pragma" content="no-cache">
     <meta http-equiv="expires" content="0"> 
     <meta http-equiv="cache-control" content="no-cache"> 
     <meta http-equiv="Content-Type" content="text/html; charset=
ISO-8859-1">
</HEAD> 

<body style="COLOR: #000000; FONT-FAMILY: Arial, Tahoma, Verdana, Helvetica; BACKGROUND-COLOR: #ffffff">
     <form method="post" runat="server"> 
          <CC:Header id="Header" runat="server" />
          <input type="hidden" id="p_Detail_item_id" runat="server"> <input type="hidden" id="p_Order_order_id" runat="server"> 
          <input type="hidden" id="p_Rating_item_id" runat="server">
          <table>
              <tr>
                  <td valign="top">
                        <table id="Detail_holder" runat="Server" style=
"WIDTH:100%"> 
                            <tr>
                                <td colspan="2"><font style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #ffffff"><asp:label id="DetailForm_Title" runat="server">Book Detail</asp:label></font><br> 
                                </td>
                            </tr>
                            <tr>
                                 <td colspan="2">
                                      <asp:Label id="Detail_ValidationSummary" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 1px" 
                                  runat="server" Visible="false"></asp:Label>
                                      <input type="hidden" id="Detail_item
_id" runat="server">
                                  </td> 
                              </tr> 
                              <tr>
                                  <td width="45" bgColor="#ffff66"><font style="FONT-SIZE: 9pt; COLOR: #000000" color="#ffffff">&#21517;&#31216;:
</font></td> 
                                  <td>
                                      <asp:Label id="Detail_name" style="
FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label>
                                      &nbsp;</td> 
                                  </tr>
                                  <tr>
                                          <td width="45" bgColor="#ffff66"><font style="FONT-SIZE: 9pt; COLOR: #000000">&#20316;
&#32773;:</font></td> 
                                          <td>
                                              <asp:Label id="Detail_author" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label> 
                                              &nbsp;</td>
                                  </tr>
                                  <tr>
                                       <td width="45" bgColor="#ffff66"><font style="FONT-SIZE: 9pt; COLOR: #000000">&#31867;
&#21035;:</font></td> 
                                       <td>
                                           <asp:Label id="Detail_category_id" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server">
</asp:Label> 
                                           &nbsp;</td>
                                   </tr>
                                   <tr>
                                       <td width="45" bgColor="#ffff66"><font style="FONT-SIZE: 9pt; COLOR: #000000">&#20215;
&#26684;:</font></td> 
                                       <td>
                                           <asp:Label id="Detail_price" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label> 
                                           &nbsp;</td>
                                   </tr>
                                   <tr>
                                       <td width="45" bgColor="#ffff66">
<font style="FONT-SIZE: 9pt; COLOR: #000000">&#22270;&#29255;:</font></td> 
                                       <td>
                                           <asp:HyperLink id="Detail_image_url" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server">
</asp:HyperLink>
                                       &nbsp;</td> 
                               </tr>
                                   <tr>
                                       <td width="45" bgColor="#ffff66">
<font style="FONT-SIZE: 9pt; COLOR: #000000">&#35828;&#26126;:</font></td>
                                       <td>
                                           <asp:Label id="Detail_notes" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label> 
                                           &nbsp;</td>
                                       </tr>
                                       <tr>
                                           <td width="45" bgColor="#ffff66">
<font style="FONT-SIZE: 9pt; COLOR: #000000"></font></td> 
                                           <td>
                                               <asp:HyperLink id="Detail_
product_url" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:
HyperLink>
                                               &nbsp;</td>
                                      </tr>
                                  </table>
                              </td>
                         </tr> 
                  </table>
                  <table> 
                    <tr>
                        <td valign="top">
                             <table id="Order_holder" runat="Server" style=
"WIDTH:100%">
                               <tr>
                                   <td colspan="2"><font style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #ffffff"><asp:label id="OrderForm_Title" runat="server"></asp:label></font><br>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                              <asp:Label id="Order_ValidationSummary" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 1px" 
                                                     runat="server" Visible="false"></asp:Label>
                              <input type="hidden" id="Order_order_id" runat="server"> <input type="hidden" id="Order_item_id" runat="server">
                        </td>
                    </tr>
                    <tr>
                        <td><font style="FONT-SIZE: 9pt; COLOR: #000000">
&#25968;&#37327;:</font>&nbsp; 
                            <asp:RequiredFieldValidator id="Order_
quantity_Validator_Req" runat="server" ErrorMessage="The value in field Quantity is required." 

ControlToValidate="Order_quantity" display="None" EnableClientScript=
"False"></asp:RequiredFieldValidator>



                            <asp:CustomValidator id="Order_quantity
_Validator_Num" OnServerValidate="ValidateNumeric" runat="server" 
                                EnableClientScript="False" ErrorMessage=
"The value in field Quantity is incorrect." ControlToValidate="Order_quantity" 

display="None"></asp:CustomValidator></td>
<td>
    <asp:TextBox id="Order_quantity" Columns="10" Text="1" runat="server" />
                                      &nbsp;</td>
                          </tr>
                          <tr>
                              <td align="right" colspan="2">
                                  <input type="button" id="Order_insert" Value="&#28155;&#21152;&#21040;&#36141;&#29289;&#31726;"
                                      runat="server"> 
                              </td>
                          </tr>
                      </table>
                  </td>
              </tr> 
          </table>
          <table>
              <tr>
                  <td valign="top">
                      <table id="Rating_holder" runat="Server" style
="WIDTH:100%"> 
                          <tr>
                              <td colspan="2"><font style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #ffffff"><asp:label id="RatingForm_Title" runat="server">&#28857;&#20987;&#29575;</asp:label></font><br> 
                              </td>
                          </tr>
                          <tr>
                              <td colspan="2">
                                  <asp:Label id="Rating_ValidationSummary" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 1px" 
                                                     runat="server" Visible="false"></asp:Label>
                                  <input type="hidden" id="Rating_item_id" runat="server"> <input type="hidden" id="Rating_rating_count" runat="server"> 
                              </td>
                          </tr>


                          <tr>
                              <td><font style="FONT-SIZE: 9pt; COLOR: #000000">&#24403;&#21069;&#28857;&#20987;&#29575;:</font></td> 
                              <td>
                                  <asp:Label id="Rating_rating_view" style=
"FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label> 
                                  &nbsp;</td>
                          </tr>
                          <tr>
                              <td><font style="FONT-SIZE: 9pt; COLOR: #000000">&#24635;&#35745;&#28857;&#20987;&#29575;:</font></td> 
                              <td>
                                  <asp:Label id="Rating_rating_count_view" style="FONT-SIZE: 9pt; COLOR: #000000" runat="server"></asp:Label> 
                                  &nbsp;</td>
                          </tr>
                          <tr>
                              <td><font style="FONT-SIZE: 9pt; COLOR: 
#000000">&#20320;&#30340;&#28857;&#20987;&#29575;:</font>&nbsp;
                                  <asp:RequiredFieldValidator id="Rating_
rating_Validator_Req" runat="server" ErrorMessage="The value in field Your Rating is required."

ControlToValidate="Rating_rating" display="None" EnableClientScript
="False"></asp:RequiredFieldValidator>
                                  <asp:CustomValidator id="Rating_rating
_Validator_Num" OnServerValidate="ValidateNumeric" runat="server" 
                                        EnableClientScript="False" Error
Message="The value in field Your Rating is incorrect." ControlToValidate=
"Rating_rating" 

display="None"></asp:CustomValidator></td>
                             <td>
                                  <asp:DropDownList style="FONT-SIZE: 9pt; COLOR: #000000" id="Rating_rating" DataTextField="" DataValueField="" 
                                        runat="server"/>
                                    &nbsp;</td>
                          </tr>
                          <tr>
                              <td align="right" colspan="2"> 
                                           <input type="button" id="Rating_
update" Value="&#25237;&#31080;" runat="server"> 
                              </td> 
                          </tr> 
                      </table> 
                  </td> 
              </tr> 
          </table>
          <CC:Footer id="Footer" runat="server" /> 
      </form> 
  </body> 
</HTML> 
Ϊ̨롣
namespace Book_Store 
{ 
 
// 
// ļ:BookDetail.cs 
// 
// 
 
    using System; 
    using System.Collections; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Data.OleDb; 
    using System.Drawing; 
    using System.Web; 
    using System.Web.SessionState; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.HtmlControls; 
 
    /// <summary> 
    ///     Summary description for BookDetail. 
    /// </summary> 

public class BookDetail:System.Web.UI.Page 

{ 

//BookDetail CustomIncludesʼ
    protected CCUtility Utility;

    //Record form DetailͿؼ 
    protected System.Web.UI.WebControls.Label Detail_Validation
Summary; 
    protected System.Web.UI.HtmlControls.HtmlInputHidden Detail_
item_id; 
    protected System.Web.UI.WebControls.Label Detail_name; 
    protected System.Web.UI.WebControls.Label Detail_author; 
    protected System.Web.UI.WebControls.Label Detail_category_id; 
    protected System.Web.UI.WebControls.Label Detail_price; 
    protected System.Web.UI.WebControls.HyperLink Detail_image_url; 
    protected System.Web.UI.WebControls.Label Detail_notes; 
    protected System.Web.UI.WebControls.HyperLink Detail_product_url; 

    //Record form OrderͿؼ 
    protected System.Web.UI.WebControls.Label Order_ValidationSummary; 
    protected System.Web.UI.HtmlControls.HtmlInputButton Order_insert; 
    protected System.Web.UI.HtmlControls.HtmlInputHidden Order_order
_id; 
    protected System.Web.UI.WebControls.TextBox Order_quantity; 
    protected System.Web.UI.HtmlControls.HtmlInputHidden Order_item
_id; 
    //Record form RatingͿؼ 
    protected System.Web.UI.WebControls.Label Rating_Validation
Summary; 
    protected System.Web.UI.HtmlControls.HtmlInputButton Rating
_update; 
    protected System.Web.UI.HtmlControls.HtmlInputHidden Rating
_item_id; 
    protected System.Web.UI.WebControls.Label Rating_rating_view; 
    protected System.Web.UI.WebControls.Label Rating_rating_count
_view;
    protected System.Web.UI.WebControls.DropDownList Rating_rating; 
    protected System.Web.UI.HtmlControls.HtmlInputHidden Rating_rating
_count; 

    // ÿDetailValuesActionsPK's,List
    protected string Detail_FormAction="ShoppingCart.aspx?";
    protected System.Web.UI.HtmlControls.HtmlInputHidden p_Detail
_item_id;
    // ÿOrderValues ActionsPK's,List
    protected string Order_FormAction="ShoppingCart.aspx?";
    protected System.Web.UI.HtmlControls.HtmlInputHidden p_Order_order_id; 
    // ÿRatingValuesActions PK's,List
     protected string Rating_FormAction="BookDetail.aspx?";
    protected System.Web.UI.HtmlControls.HtmlInputHidden p_Rating
_item_id;
    protected System.Web.UI.WebControls.Label DetailForm_Title; 
    protected System.Web.UI.WebControls.Label OrderForm_Title;
    protected System.Web.UI.WebControls.RequiredFieldValidator Order
_quantity_Validator_Req; 
    protected System.Web.UI.WebControls.CustomValidator Order_quantity
_Validator_Num;
    protected System.Web.UI.WebControls.Label RatingForm_Title;
    protected System.Web.UI.WebControls.RequiredFieldValidator Rating
_rating_Validator_Req;
    protected System.Web.UI.WebControls.CustomValidator Rating
_rating_Validator_Num;
    protected System.Web.UI.HtmlControls.HtmlTable Detail_holder;
    protected System.Web.UI.HtmlControls.HtmlTable Order_holder; 
    protected System.Web.UI.HtmlControls.HtmlTable Rating_holder;
    protected String[] Rating_rating_lov = "1;Deficient;2;Regular;
3;Good;4;Very Good;5;Excellent".Split(new Char[] {';'}); 

public BookDetail() 
{ 
this.Init += new System.EventHandler(Page_Init); 
} 

// BookDetail CustomIncludes 
//------------------------------- 

public void ValidateNumeric(object source, ServerValidateEventArgs args) {
            try{
                Decimal temp=Decimal.Parse(args.Value); 
                args.IsValid=true; 
              }catch{
                args.IsValid=false; } 
    }
//===============================
// BookDetail Showʼ
          protected void Page_Load(object sender, EventArgs e)
          {
      Utility=new CCUtility(this);
      //=============================== 
// BookDetail Open Eventʼ 
// BookDetail Open Event
//=============================== 
    //=============================== 
// BookDetail OpenAnyPage Eventʼ 
// BookDetail OpenAnyPage Event 
    //=============================== 
    // 
    //=============================== 
    // BookDetail PageSecurityʼ 
    Utility.CheckSecurity(1); 
    // BookDetail PageSecurity 
    //=============================== 

    if (!IsPostBack){ 

        p_Detail_item_id.Value = Utility.GetParam("item_id"); 
        p_Order_order_id.Value = Utility.GetParam("order_id"); p_Rating_item_id.Value = Utility.GetParam("item_id");Page_Show(sender, e);
    }
} 

protected void Page_Unload(object sender, EventArgs e) 
{
    //
    // CODEGEN:ASP+ Windows Form DesignerҪ.
    // 
    if (Utility!=null) Utility.DBClose(); 
} 

protected void Page_Init(object sender, EventArgs e) 
{
    //
    // CODEGEN:ASP+ Windows Form DesignerҪ.
    //
    InitializeComponent(); 

    Order_insert.ServerClick += new System.EventHandler (this.Order
_Action); 

    Rating_update.ServerClick += new System.EventHandler (this.Rating
_Action); 


} 

      private void InitializeComponent() 
      {
        this.Unload += new System.EventHandler(this.Page_Unload); 
        this.Load += new System.EventHandler(this.Page_Load); 
    } 

        protected void Page_Show(object sender, EventArgs e) 
        {
    Detail_Show();
    Order_Show(); 
    Rating_Show();

        } 

// BookDetail Show

// Login 

private bool Detail_Validate(){
 bool result=true;
 Detail_ValidationSummary.Text=""; 

 for(int i=0;i<Page.Validators.Count;i++){ 
          if (((System.Web.UI.WebControls.BaseValidator)Page.Validators[i]).ID.ToString().St artsWith("Detail")){ 
              if (!Page.Validators[i].IsValid){ 

Detail_ValidationSummary.Text+=Page.Validators[i].ErrorMessage+"<br>";
                  result=false; 
        } 
    } 
} 

Detail_ValidationSummary.Visible=(!result);
return result; 
}

/*=============================== 
Display Record Form 
-------------------------------*/

void Detail_Show() { 

// Detail Showʼ

bool ActionInsert=true; 

  if (p_Detail_item_id.Value.Length > 0 ) { 
      string sWhere = ""; 

      sWhere += "item_id=" + CCUtility.ToSQL(p_Detail_item_id.Value, FieldTypes.Number); 

// Detail Open Eventʼ 
// Detail Open Event
        string sSQL = "select * from items where " + sWhere;
        OleDbDataAdapter dsCommand = new OleDbDataAdapter(sSQL, Utility
.Connection);
        DataSet ds = new DataSet();
        DataRow row; 

        if (dsCommand.Fill(ds, 0, 1, "Detail") > 0) { 
        row = ds.Tables[0].Rows[0]; 

Detail_item_id.Value = CCUtility.GetValue(row, "item_id"); 

Detail_name.Text =Server.HtmlEncode(CCUtility.GetValue(row, "name")
.ToString()); 

Detail_author.Text =Server.HtmlEncode(CCUtility.GetValue(row, 
"author").ToString()); 

Detail_category_id.Text =Server.HtmlEncode(Utility.Dlookup
("categories", "name", "category_id=" + CCUtility.ToSQL(CCUtility
.GetValue(row, "category_id"), FieldTypes.Number)).ToString()); 

Detail_price.Text =Server.HtmlEncode(CCUtility.GetValue(row, "price")
.ToString()); 

Detail_image_url.Text =CCUtility.GetValue(row, "image_url"); 

Detail_image_url.NavigateUrl=CCUtility.GetValue(row, "product_url")+""; 

Detail_notes.Text =CCUtility.GetValue(row, "notes"); Detail_
product_url.Text =Server.HtmlEncode(CCUtility.GetValue(row, "product
_url").ToString()); 

    Detail_product_url.NavigateUrl=CCUtility.GetValue(row, "product_url")+""; 

    ActionInsert=false; 

// Detail ShowEdit Eventʼ
// Detail ShowEdit Event

 } 
} 

            if (ActionInsert){ 

            String pValue; 

            pValue = Utility.GetParam("item_id");Detail_item_id.Value = pValue; 
// Detail ShowInsert Eventʼ 
// Detail ShowInsert Event
} 


// Detail Open Eventʼ
// Detail Open Event

// Detail Show Event ʼ
Detail_image_url.ImageUrl=Detail_image_url.Text;
Detail_product_url.Text="ѯΰҵamymax@126.com/(010)62993455";
// Detail Show Event 

// Detail Show 

// Detail Close Eventʼ
// Detail Close Event

 } 

// Detail Actionʼ

void Detail_BeforeSQLExecute(string SQL,String Action){

// Detail BeforeExecute Eventʼ
// Detail BeforeExecute Event

} 

// Login

private bool Order_Validate(){
 bool result=true;
 Order_ValidationSummary.Text=""; 

 for(int i=0;i<Page.Validators.Count;i++){ 

if (((System.Web.UI.WebControls.BaseValidator)Page.Validators[i]).ID.ToString().St artsWith("Order")){ 
        if (!Page.Validators[i].IsValid){ 
 
Order_ValidationSummary.Text+=Page.Validators[i].ErrorMessage+"<br>";  
            result=false; 
        } 
    } 
} 

 Order_ValidationSummary.Visible=(!result); 
 return result; 
} 

/*=============================== 
Display Record Form 
-------------------------------*/ 

void Order_Show() { 

// Order Showʼ

 bool ActionInsert=true; 
  if (p_Order_order_id.Value.Length > 0 ) { 
      string sWhere = ""; 

      sWhere += "order_id=" + CCUtility.ToSQL(p_Order_order_id.Value, FieldTypes.Number); 

// Order Open Eventʼ
// Order Open Event
      string sSQL = "select * from orders where " + sWhere; 
      OleDbDataAdapter dsCommand = new OleDbDataAdapter(sSQL, Utility.Connection);
      DataSet ds = new DataSet();
      DataRow row; 

        if (dsCommand.Fill(ds, 0, 1, "Order") > 0) { 
      row = ds.Tables[0].Rows[0]; 

Order_order_id.Value = CCUtility.GetValue(row, "order_id"); 

Order_quantity.Text = CCUtility.GetValue(row, "quantity"); 
Order_item_id.Value = CCUtility.GetValue(row, "item_id"); 

Order_insert.Visible=false; 
      ActionInsert=false;

// Order ShowEdit Eventʼ
// Order ShowEdit Event

}} 
      if (ActionInsert){ 

    String pValue; 

    pValue = Utility.GetParam("item_id");Order_item_id.Value = pValue; 
// Order ShowInsert Eventʼ
// Order ShowInsert Event

} 
} 

// Order Actionʼ

bool Order_insert_Click(Object Src, EventArgs E) { 
        string sSQL=""; 
        bool bResult=Order_Validate(); 

// Order Check Eventʼ
// Order Check Event

        string s1_UserID=CCUtility.ToSQL(Session["UserID"].ToString(), FieldTypes.Number); 
        string p2_quantity=CCUtility.ToSQL(Utility.GetParam("Order_quantity"), FieldTypes.Number) ; 
        string p2_item_id=CCUtility.ToSQL(Utility.GetParam("Order_item_id"), FieldTypes.Number) ; 
// Order Insert Eventʼ
// Order Insert Event

        if (bResult){ 

        if (sSQL.Length==0){ 
      sSQL = "insert into orders (" +
           "[member_id]," + 
           "quantity," + 
           "item_id)" + 
           " values (" +
           s1_UserID + "," + 
           p2_quantity + "," + 
           p2_item_id + ")"; 
       }
       Order_BeforeSQLExecute(sSQL,"Insert"); 
       OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection);
       try {
              cmd.ExecuteNonQuery(); 
       } catch(Exception e) {
             Order_ValidationSummary.Text += e.Message;  
             Order_ValidationSummary.Visible = true;  
            return false; 
       } 

// Order AfterInsert Eventʼ
// Order AfterInsert Event
       } 
       return bResult;
   } 

 void Order_BeforeSQLExecute(string SQL,String Action){ 

// Order BeforeExecute Eventʼ
// Order BeforeExecute Event

  } 

void Order_Action(Object Src, EventArgs E) {
bool bResult=true;
  if (((HtmlInputButton)Src).ID.IndexOf("insert")>0) bResult=Order_
insert_Click(Src,E); 

  if (bResult)Response.Redirect(Order_FormAction+""); 
} 
// Order Action
// Login 

private bool Rating_Validate(){ 
 bool result=true; 
 Rating_ValidationSummary.Text=""; 
 for(int i=0;i<Page.Validators.Count;i++){ 
          if (((System.Web.UI.WebControls.BaseValidator)Page.Validators[i]).ID.ToString().St artsWith("Rating")){ 
               if (!Page.Validators[i].IsValid){ 

Rating_ValidationSummary.Text+=Page.Validators[i].ErrorMessage+"<br>"; 
                   result=false; 
        } 
    }
} 

 Rating_ValidationSummary.Visible=(!result); 
 return result; 
} 

/*=============================== 
ʾ¼ 
-------------------------------*/ 

void Rating_Show() { 

// Rating Showʼ
Utility.buildListBox(Rating_rating.Items,Rating_rating_lov,null,""); 

  bool ActionInsert=true; 

  if (p_Rating_item_id.Value.Length > 0 ) { 
      string sWhere = ""; 

      sWhere += "item_id=" + CCUtility.ToSQL(p_Rating_item_id.Value, FieldTypes.Number); 

// Rating Open Eventʼ
// Rating Open Event
        string sSQL = "select * from items where " + sWhere; 
        OleDbDataAdapter dsCommand = new OleDbDataAdapter(sSQL, Utility
.Connection);
        DataSet ds = new DataSet();
        DataRow row; 

        if (dsCommand.Fill(ds, 0, 1, "Rating") > 0) { 
        row = ds.Tables[0].Rows[0];

Rating_item_id.Value = CCUtility.GetValue(row, "item_id"); 
Rating_rating_view.Text =CCUtility.GetValue(row, "rating"); 

Rating_rating_count_view.Text =Server.HtmlEncode(CCUtility.GetValue(row, "rating_count").ToString()); 

    {string s; 
    s=CCUtility.GetValue(row, "rating"); 

    try {Rating_rating.SelectedIndex=Rating_rating.Items.IndexOf(Rating_rating.Items.Fi ndByValue(s)); 
    }catch{}} 

Rating_rating_count.Value = CCUtility.GetValue(row, "rating_count"); 

    ActionInsert=false; 

// Rating ShowEdit Eventʼ
// Rating ShowEdit Event

}} 

    if (ActionInsert){

    String pValue;

    pValue = Utility.GetParam("item_id");Rating_item_id.Value = pValue;
Rating_update.Visible=false; 

// Rating ShowInsert Eventʼ
// Rating ShowInsert Event

} 


// Rating Open Eventʼ
// Rating Open Event

// Rating Show Eventʼ
 if (Int16.Parse(Rating_rating_view.Text)==0){ 
 Rating_rating_view.Text="Not rated yet"; 
 Rating_rating_count_view.Text=""; 
}else{ 
  Rating_rating_view.Text="<img src=images/" + System.Math.Round
(Double.Parse(Rating_rating.SelectedItem.Value)/Double.Parse (Rating_rating_count.Value)) + "stars.g if >"; 
} 
// Rating Show Event 

// Rating Show 

// Rating Close Eventʼ
// Rating Close Event

 }

// Rating Actionʼ

 void Rating_BeforeSQLExecute(string SQL,String Action){ 

// Rating BeforeExecute Eventʼ
// Rating BeforeExecute Event 

} 

bool Rating_update_Click(Object Src, EventArgs E) { 
    string sWhere = "";
    string sSQL =""; 

    bool bResult=Rating_Validate(); 
      if (bResult){ 
      if (p_Rating_item_id.Value.Length > 0) {
          sWhere = sWhere + "item_id=" + CCUtility.ToSQL(p_Rating
_item_id.Value, FieldTypes.Number);
      } 

// Rating Check Eventʼ
// Rating Check Event

      if (bResult){ 

      sSQL = "update items set " +
      "[rating]=" +CCUtility.ToSQL(Utility.GetParam("Rating_rating"),FieldTypes.Number) + 
      ",[rating_count]=" +CCUtility.ToSQL(Utility.GetParam("Rating_rating_count"),FieldTypes.Number); 

        sSQL = sSQL + " where " + sWhere; 

// Rating Update Eventʼ
sSQL="update items set rating=rating+" + Rating_rating.SelectedItem.
Value + ", rating_count=rating_count+1 where item_id=" + Rating_item_id.Value; 
// Rating Update Event 
Rating_BeforeSQLExecute(sSQL,"Update"); 
      OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection);
            try {
                    cmd.ExecuteNonQuery(); 
            } catch(Exception e) {
                  Rating_ValidationSummary.Text += e.Message;
                  Rating_ValidationSummary.Visible = true;
                  return false; 
            } 
      } 

      if (bResult){ 
// Rating AfterUpdate Eventʼ
// Rating AfterUpdate Event
      }
      }
      return bResult; 
} 

void Rating_Action(Object Src, EventArgs E) {
bool bResult=true; 
if (((HtmlInputButton)Src).ID.IndexOf("update")>0) bResult=Rating_
update_Click(Src,E); 

if (bResult)Response.Redirect(Rating_FormAction+"item_id=" + Server.
UrlEncode(Utility.GetParam("item_id")) + "&");
}
// Rating Action  

      } 
} 

