protected void UpdateAccept_ServerClick(object sender, EventArgs e) { PreOrderProduct productToUpdate = new PreOrderProduct(Convert.ToInt32(Session["PRODUCTID"]), updateName.Value, updateDescription.Value, Convert.ToInt32(updatePrice.Value), updateDateCreation.Value, updateDateEnd.Value); resultMessage.InnerText = preorderBusiness.updatePreOrderProductService(productToUpdate); Response.Redirect("PreorderAdministration.aspx"); }
public bool UpdatePreOrderProduct(PreOrderProduct product) { bool flag = false; try { ConnectDB(); MySqlCommand query = new MySqlCommand("update productoscontrapedido set nombre= @ name descripción=@description and precio = @price and foto=@image and fechacreacion= @createDate and fechatermino=@finalDate where idProducto =@id;", Conn); Conn.Open(); query.Parameters.AddWithValue("@name", product.Name); query.Parameters.AddWithValue("@description", product.Description); query.Parameters.AddWithValue("@price", product.Price); query.Parameters.AddWithValue("@image", product.Foto); query.Parameters.AddWithValue("@createDate", product.CreateDate); query.Parameters.AddWithValue("@finalDate", product.FinalizeDate); query.Parameters.AddWithValue("@id", product.ProductID); query.ExecuteNonQuery(); flag = true; } catch (Exception e) { Console.WriteLine(e.Message); } finally { disconnectDB(); Conn.Close(); } return(flag); }
protected void productRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "deleteProduct") { ModalPopupExtender popup = (ModalPopupExtender)e.Item.FindControl("deletePopUp"); HiddenField id = (HiddenField)e.Item.FindControl("productID"); Session["PRODUCTID"] = id.Value; DeleteQuestion.InnerText = "¿Desea elimnar el producto seleccionado?"; popup.Show(); } if (e.CommandName == "EditProduct") { ModalPopupExtender updatePopup = (ModalPopupExtender)e.Item.FindControl("EditPopUp"); HiddenField id = (HiddenField)e.Item.FindControl("productID"); Session["PRODUCTID"] = id.Value; PreOrderProduct preorderProduct = new PreOrderProduct(); preorderProduct = preorderBusiness.getPreOrderService(Convert.ToInt32(id.Value)); updateName.Value = preorderProduct.Name; updateDescription.Value = preorderProduct.Description; updatePrice.Value = preorderProduct.Price.ToString(); updateDateCreation.Value = preorderProduct.CreateDate; updateDateEnd.Value = preorderProduct.FinalizeDate; updateMessage.InnerText = "Edite el producto. Use los espacios provistos para introducir los nuevos datos."; updatePopup.Show(); } }
public List <PreOrderProduct> GetAllPreOrderProducts() { List <PreOrderProduct> list = new List <PreOrderProduct>(); try { ConnectDB(); MySqlCommand query = new MySqlCommand("Select * from productoscontrapedido", Conn); Conn.Open(); MySqlDataReader reader = query.ExecuteReader(); while (reader.Read()) { PreOrderProduct product = new PreOrderProduct(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDouble(3), reader.GetString(4), reader.GetString(5), reader.GetString(6)); list.Add(product); } reader.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } finally { disconnectDB(); Conn.Close(); } return(list); }
public bool CreatePreOrderProduct(PreOrderProduct product) { bool flag = false; try { ConnectDB(); MySqlCommand query = new MySqlCommand("Insert into productoscontrapedido(nombre,descripción,precio,foto,fechacreacion,fechatermino) values(@name,@description,@price,@image,@createDate,@finalDate)", Conn); Conn.Open(); query.Parameters.AddWithValue("@name", product.Name); query.Parameters.AddWithValue("@description", product.Description); query.Parameters.AddWithValue("@price", product.Price); query.Parameters.AddWithValue("@image", product.Foto); query.Parameters.AddWithValue("@createDate", product.CreateDate); query.Parameters.AddWithValue("@finalDate", product.FinalizeDate); query.ExecuteNonQuery(); flag = true; } catch (Exception e) { Console.WriteLine(e.Message); } finally { disconnectDB(); Conn.Close(); } return(flag); }
public PreOrderProduct getPreOrderProduct(int id) { PreOrderProduct preOrderProduct = null; try { MySqlCommand query = new MySqlCommand("SELECT * FROM productoscontrapedido where idProducto = @id", Conn); query.Parameters.AddWithValue("@id", id); Conn.Open(); MySqlDataReader reader = query.ExecuteReader(); reader.Read(); preOrderProduct = new PreOrderProduct(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDouble(3), reader.GetString(5), reader.GetString(6)); return(preOrderProduct); } catch (MySqlException e) { Console.WriteLine(e.Message); } finally { disconnectDB(); Conn.Close(); } return(null); }
public string updatePreOrderProductService(PreOrderProduct p) { string result = ""; if (data.UpdatePreOrderProduct(p)) { result = "Producto actualizado correctamente!"; } else { result = "Producto no actualizado!"; } return(result); }
public string addPreOrderProductService(PreOrderProduct p) { string result = ""; if (data.CreatePreOrderProduct(p)) { result = "Producto agregado correctamente!"; } else { result = "Producto no agregado, vuelva a intentar!"; } return(result); }
protected void SavePreOrderProduct_ServerClick(object sender, EventArgs e) { if (productName.Value != null && priceProduct.Value != null && creationDateProduct.Value != null && finishDateProduct.Value != null && productDescription.Value != null && fileToSave != null) { PreOrderProduct product = new PreOrderProduct(productName.Value, productDescription.Value, Convert.ToInt32(priceProduct.Value), "MenuImages/" + fileToSave.FileName, creationDateProduct.Value, finishDateProduct.Value); resultMessage.InnerText = preorderBusiness.addPreOrderProductService(product); clearSpaces(); ModalPopupExtender.Show(); Response.Redirect("PreorderAdministration.aspx"); } else { resultMessage.InnerText = "Debe llenar todos los campos requeridos."; ModalPopupExtender.Show(); } }