Ejemplo n.º 1
0
        // Book Action begin

        bool Book_insert_Click(Object Src, EventArgs E)
        {
            string sSQL    = "";
            bool   bResult = Book_Validate();

// Book Check Event begin
// Book Check Event end

            string p2_name           = CCUtility.ToSQL(Utility.GetParam("Book_name"), FieldTypes.Text);
            string p2_author         = CCUtility.ToSQL(Utility.GetParam("Book_author"), FieldTypes.Text);
            string p2_category_id    = CCUtility.ToSQL(Utility.GetParam("Book_category_id"), FieldTypes.Number);
            string p2_price          = CCUtility.ToSQL(Utility.GetParam("Book_price"), FieldTypes.Number);
            string p2_product_url    = CCUtility.ToSQL(Utility.GetParam("Book_product_url"), FieldTypes.Text);
            string p2_image_url      = CCUtility.ToSQL(Utility.GetParam("Book_image_url"), FieldTypes.Text);
            string p2_notes          = CCUtility.ToSQL(Utility.GetParam("Book_notes"), FieldTypes.Text);
            string c1_is_recommended = CCUtility.getCheckBoxValue(Utility.GetParam("Book_is_recommended"), "1", "0", FieldTypes.Number);

// Book Insert Event begin
// Book Insert Event end


            if (bResult)
            {
                if (sSQL.Length == 0)
                {
                    sSQL = "insert into items (" +
                           "name," +
                           "author," +
                           "category_id," +
                           "price," +
                           "product_url," +
                           "image_url," +
                           "notes," +
                           "is_recommended)" +
                           " values (" +
                           p2_name + "," +
                           p2_author + "," +
                           p2_category_id + "," +
                           p2_price + "," +
                           p2_product_url + "," +
                           p2_image_url + "," +
                           p2_notes + "," +
                           c1_is_recommended + ")";
                }
                Book_BeforeSQLExecute(sSQL, "Insert");
                OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection);
                try {
                    cmd.ExecuteNonQuery();
                } catch (Exception e) {
                    Book_ValidationSummary.Text   += e.Message;
                    Book_ValidationSummary.Visible = true;
                    return(false);
                }

// Book AfterInsert Event begin
// Book AfterInsert Event end
            }
            return(bResult);
        }
Ejemplo n.º 2
0
        bool Book_update_Click(Object Src, EventArgs E)
        {
            string sWhere = "";
            string sSQL   = "";

            bool bResult = Book_Validate();

            if (bResult)
            {
                if (p_Book_item_id.Value.Length > 0)
                {
                    sWhere = sWhere + "item_id=" + CCUtility.ToSQL(p_Book_item_id.Value, FieldTypes.Number);
                }

// Book Check Event begin
// Book Check Event end

                if (bResult)
                {
                    sSQL = "update items set " +
                           "[name]=" + CCUtility.ToSQL(Utility.GetParam("Book_name"), FieldTypes.Text) +
                           ",[author]=" + CCUtility.ToSQL(Utility.GetParam("Book_author"), FieldTypes.Text) +
                           ",[category_id]=" + CCUtility.ToSQL(Utility.GetParam("Book_category_id"), FieldTypes.Number) +
                           ",[price]=" + CCUtility.ToSQL(Utility.GetParam("Book_price"), FieldTypes.Number) +
                           ",[product_url]=" + CCUtility.ToSQL(Utility.GetParam("Book_product_url"), FieldTypes.Text) +
                           ",[image_url]=" + CCUtility.ToSQL(Utility.GetParam("Book_image_url"), FieldTypes.Text) +
                           ",[notes]=" + CCUtility.ToSQL(Utility.GetParam("Book_notes"), FieldTypes.Text) +
                           ",[is_recommended]=" + CCUtility.getCheckBoxValue(Utility.GetParam("Book_is_recommended"), "1", "0", FieldTypes.Number);


                    sSQL = sSQL + " where " + sWhere;

// Book Update Event begin
// Book Update Event end
                    Book_BeforeSQLExecute(sSQL, "Update");
                    OleDbCommand cmd = new OleDbCommand(sSQL, Utility.Connection);
                    try {
                        cmd.ExecuteNonQuery();
                    } catch (Exception e) {
                        Book_ValidationSummary.Text   += e.Message;
                        Book_ValidationSummary.Visible = true;
                        return(false);
                    }
                }

                if (bResult)
                {
// Book AfterUpdate Event begin
// Book AfterUpdate Event end
                }
            }
            return(bResult);
        }