rMuD
|
| Posted: 09/28/2004, 9:41 PM |
|
Running CCS 2.3.2.24
I have two tables
Products
product_id (key)
product_qty
etc..
Products_description
product_id (key)
language_id (key)
product_name
I need the Product Name in the editable grid, Update and Cancel Only.. No Insert or Delete
Creating it thru the "Query Builder GUI" looks great on Screen
but after creating the Custom update, all I get is the One or More Parameters error, no matter what I change it too...
When I go to create the Custom Update, the only fields that show in the Where are the Search Form... if I have one, if not it shows nothing which will update all records as teh where clause is where ""
but if I put product_id = {product_id} or {products_products_id} with whatever type I chose it's not pulling from the array that is sent by update_row but from the form or session..
From the other posts, it's easy to do this, but I just can't seem to figure what I am doing wrong when creating this.
From Looking at the Code... I see this as the problem
$wp->AddParameter("1", "postproducts_products_id", ccsInteger, "", "", CCGetFromPost("products_products_id", ""), "", false);
if(!$wp->AllParamsSet()) {
$this->Errors->addError("One or more parameters missing to perform the Update/Delete. The application is misconfigured.");
}
And Possibly should be
$wp->AddParameter("1", "postproducts_products_id", ccsInteger, "", "", $this->products_products_id->GetValue()
, "", false);
if(!$wp->AllParamsSet()) {
$this->Errors->addError("One or more parameters missing to perform the Update/Delete. The application is misconfigured.");
}
also removing the updating to the Primary Key wouldn't be a bad Idea either.
. "products_id=" . $this->ToSQL($this->cp["products.products_id"]->GetDBValue(), $this->cp["products.products_id"]->DataType) . ", "
in the following example....
//UpdateGrid Method @2-1AD7C7C0
function UpdateGrid()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSubmit");
if(!$this->Validate()) return;
$Validation = true;
for($RowNumber = 1; $RowNumber <= $this->TotalRows; $RowNumber++)
{
$this->products_name->SetText($this->FormParameters["products_name"][$RowNumber], $RowNumber);
$this->products_products_id->SetText($this->FormParameters["products_products_id"][$RowNumber], $RowNumber);
$this->products_quantity->SetText($this->FormParameters["products_quantity"][$RowNumber], $RowNumber);
$this->products_uomqty->SetText($this->FormParameters["products_uomqty"][$RowNumber], $RowNumber);
$this->products_model->SetText($this->FormParameters["products_model"][$RowNumber], $RowNumber);
$this->products_image->SetText($this->FormParameters["products_image"][$RowNumber], $RowNumber);
$this->products_price->SetText($this->FormParameters["products_price"][$RowNumber], $RowNumber);
$this->products_status->SetText($this->FormParameters["products_status"][$RowNumber], $RowNumber);
$this->manufacturers_id->SetText($this->FormParameters["manufacturers_id"][$RowNumber], $RowNumber);
if ($this->UpdatedRows >= $RowNumber) {
if($this->UpdateAllowed) { $Validation = ($this->UpdateRow($RowNumber) && $Validation); }
}
else if($this->CheckInsert($RowNumber) && $this->InsertAllowed)
{
$Validation = ($this->InsertRow($RowNumber) && $Validation);
}
}
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterSubmit");
return ($this->Errors->Count() == 0 && $Validation);
}
//End UpdateGrid Method
//UpdateRow Method @2-26838098
function UpdateRow($RowNumber)
{
if(!$this->UpdateAllowed) return false;
$this->ds->products_name->SetValue($this->products_name->GetValue());
$this->ds->products_products_id->SetValue($this->products_products_id->GetValue());
$this->ds->products_quantity->SetValue($this->products_quantity->GetValue());
$this->ds->products_uomqty->SetValue($this->products_uomqty->GetValue());
$this->ds->products_model->SetValue($this->products_model->GetValue());
$this->ds->products_image->SetValue($this->products_image->GetValue());
$this->ds->products_price->SetValue($this->products_price->GetValue());
$this->ds->products_status->SetValue($this->products_status->GetValue());
$this->ds->manufacturers_id->SetValue($this->manufacturers_id->GetValue());
$this->ds->Update();
$errors = "";
if($this->ds->Errors->Count() > 0) {
$errors = $this->ds->Errors->ToString();
$this->RowsErrors[$RowNumber] = $errors;
$this->ds->Errors->Clear();
}
return (($this->Errors->Count() == 0) && !strlen($errors));
}
//End UpdateRow Method
//Update Method @2-BB3FC39E
function Update()
{
$this->CmdExecution = true;
$this->cp["products_name"] = new clsSQLParameter("ctrlproducts_name", ccsText, "", "", $this->products_name->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products.products_id"] = new clsSQLParameter("ctrlproducts_products_id", ccsInteger, "", "", $this->products_products_id->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_quantity"] = new clsSQLParameter("ctrlproducts_quantity", ccsInteger, "", "", $this->products_quantity->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_uomqty"] = new clsSQLParameter("ctrlproducts_uomqty", ccsFloat, "", "", $this->products_uomqty->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_model"] = new clsSQLParameter("ctrlproducts_model", ccsText, "", "", $this->products_model->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_image"] = new clsSQLParameter("ctrlproducts_image", ccsText, "", "", $this->products_image->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_price"] = new clsSQLParameter("ctrlproducts_price", ccsFloat, "", "", $this->products_price->GetValue(), "", false, $this->ErrorBlock);
$this->cp["products_status"] = new clsSQLParameter("ctrlproducts_status", ccsInteger, "", "", $this->products_status->GetValue(), "", false, $this->ErrorBlock);
$this->cp["manufacturers_id"] = new clsSQLParameter("ctrlmanufacturers_id", ccsInteger, "", "", $this->manufacturers_id->GetValue(), "", false, $this->ErrorBlock);
$wp = new clsSQLParameters($this->ErrorBlock);
$wp->AddParameter("1", "postproducts_products_id", ccsInteger, "", "", CCGetFromPost("products_products_id", ""), "", false);
if(!$wp->AllParamsSet()) {
$this->Errors->addError("One or more parameters missing to perform the Update/Delete. The application is misconfigured.");
}
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate");
$wp->Criterion[1] = $wp->Operation(opEqual, "products_id", $wp->GetDBValue("1"), $this->ToSQL($wp->GetDBValue("1"), ccsInteger),false);
$Where =
$wp->Criterion[1];
$this->SQL = "UPDATE products SET "
. "products_name=" . $this->ToSQL($this->cp["products_name"]->GetDBValue(), $this->cp["products_name"]->DataType) . ", "
. "products_id=" . $this->ToSQL($this->cp["products.products_id"]->GetDBValue(), $this->cp["products.products_id"]->DataType) . ", "
. "products_quantity=" . $this->ToSQL($this->cp["products_quantity"]->GetDBValue(), $this->cp["products_quantity"]->DataType) . ", "
. "products_uomqty=" . $this->ToSQL($this->cp["products_uomqty"]->GetDBValue(), $this->cp["products_uomqty"]->DataType) . ", "
. "products_model=" . $this->ToSQL($this->cp["products_model"]->GetDBValue(), $this->cp["products_model"]->DataType) . ", "
. "products_image=" . $this->ToSQL($this->cp["products_image"]->GetDBValue(), $this->cp["products_image"]->DataType) . ", "
. "products_price=" . $this->ToSQL($this->cp["products_price"]->GetDBValue(), $this->cp["products_price"]->DataType) . ", "
. "products_status=" . $this->ToSQL($this->cp["products_status"]->GetDBValue(), $this->cp["products_status"]->DataType) . ", "
. "manufacturers_id=" . $this->ToSQL($this->cp["manufacturers_id"]->GetDBValue(), $this->cp["manufacturers_id"]->DataType);
$this->SQL = CCBuildSQL($this->SQL, $Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteUpdate");
if($this->Errors->Count() == 0 && $this->CmdExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteUpdate");
}
$this->close();
}
//End Update Method
|
|
|
 |
|