private void BtnSaveChange_Click(object sender, EventArgs e) { Inventory.ProductRow row = invent.Product.FindByID(txtID.Text.Trim()); if (row != null) { row.Barcode = txtBarcode.Text.Trim(); row.Name = txtName.Text.Trim(); row.StockQty = Convert.ToInt32(txtStockQty.Text.Trim()); row.StockLevel = Convert.ToInt32(txtStockLevel.Text.Trim()); row.UnitPrice = Convert.ToDecimal(txtUnitPrice.Text.Trim()); row.CategoryID = Convert.ToInt32(cboCategory.SelectedValue); row.UnitTypeID = Convert.ToInt32(cboUnitType.SelectedValue); row.Desc = txtDescription.Text.Trim(); row.IsForSale = chkAvailableForSale.Checked; if (pictureBox1.Image != null) { row.Image = ConvertImageToBytes(pictureBox1.Image); } } this.ClearForm(); btnSave.Click -= BtnSaveChange_Click; btnSave.Click += btnSave_Click; // //pro_adapter.Update(invent.Product); pro_adapter.Update(row); }
private void updateRow() { string name = txtProductName.Text; decimal price = decimal.Parse("2.50"); int quant = int.Parse("50"); int categID = int.Parse(ddlCategory.SelectedValue); int id = int.Parse(txtProductNumber.Text); int result = adpProduct.Update(name, price, quant, categID, id); if (result == 1) { lblErrorMessage.Text = "Product Update "; lblErrorMessage.ForeColor = System.Drawing.Color.Yellow; txtProductName.Text = ""; txtProductNumber.Text = ""; txtPrice.Text = ""; txtQuantity.Text = ""; Refresh(); } else { lblErrorMessage.Text = "Product NOT Updated"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } }
protected void btnAddItem_Click(object sender, EventArgs e) { try { DataRow Inventorydata = dsInventory.Product.NewRow(); // Create a new row of service_order table in memory //update record with user's input Inventorydata[1] = this.txtProduct.Text; Inventorydata[3] = this.ddlBrand.SelectedValue; Inventorydata[2] = this.txtDescription.Text; ProductTableAdapter ProductTable = new ProductTableAdapter(); dsInventory.Product.Rows.Add(Inventorydata); // add the rows to the dataset ProductTable.Update(Inventorydata); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsInventory.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database lblMessage.Text = "Created 1"; //Refresh the page to show the record being deleted Response.Redirect("Default.aspx"); // Redirect the user to dexpage on to show created data lblMessage.Text = "Created"; } catch { lblMessage.Text = "Failed"; } }
/// <summary> /// Method called when AddProduct button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAddProduct_Click(object sender, EventArgs e) { string productName = txtProductName.Text; string productDesc = txtPtoductDesc.Text; int productQty = int.Parse(txtProductQty.Text); string productType = ddlProductType.SelectedValue; decimal productPrice = decimal.Parse(txtProductPrice.Text); string productBrand = txtProductBrand.Text; string productImage = flProductImage.FileName; int userId = user.UserId; int categoryId = int.Parse(ddlProductCategory.SelectedValue); bool result = false; if (product != null && Request.QueryString["ProductId"] != null) { if (!flProductImage.HasFile) { productImage = product.ProductImage; } else { productImage = flProductImage.FileName; } result = true; } else { result = uploadFile(); } if (!flProductImage.HasFile || result) { int rowInserted; if (product != null && Request.QueryString["ProductId"] != null) { rowInserted = adpProduct.Update( productName, productDesc, productType, productPrice, productBrand, productImage, userId, categoryId, productQty, product.ProductId); } else { if (!flProductImage.HasFile) { productImage = "default.jpg"; } rowInserted = adpProduct.Insert(productName, productDesc, productType, productPrice, productBrand, productImage, userId, categoryId, productQty); } if (rowInserted > 0) { Response.Redirect("~/MyProducts.aspx"); } else { } } }
public int Update(ProductInfo info) { //找出原本的info ProductInfo Beforceinfo = GetProductForEdit(info.p_id); if (Beforceinfo.pc_id == info.pc_id) { return(db.Update(info.pc_id, info.pcs_id, info.p_name, info.p_serial, info.p_status, info.p_show, info.p_show_hot, info.p_detail, info.p_stock, info.p_stock_unit, info.p_price1, info.p_price2, info.p_price3, info.p_price4, info.p_price5, info.p_createDate, info.p_editDate, info.p_hits, info.p_sorting, info.p_img, info.p_files, info.l_id, info.p_id)); } else { List <ProductInfo> infosBeforce = GetProductSortingWithDelete(Beforceinfo.pc_id, Beforceinfo.p_sorting); foreach (ProductInfo infos in infosBeforce) { db.Update(infos.pc_id, infos.pcs_id, infos.p_name, infos.p_serial, infos.p_status, infos.p_show, infos.p_show_hot, infos.p_detail, infos.p_stock, infos.p_stock_unit, infos.p_price1, infos.p_price2, infos.p_price3 , infos.p_price4, infos.p_price5, infos.p_createDate, infos.p_editDate, infos.p_hits, infos.p_sorting - 1, infos.p_img, info.p_files, info.l_id, infos.p_id); } return(db.Update(info.pc_id, info.pcs_id, info.p_name, info.p_serial, info.p_status, info.p_show, info.p_show_hot, info.p_detail, info.p_stock, info.p_stock_unit, info.p_price1, info.p_price2, info.p_price3, info.p_price4, info.p_price5, info.p_createDate, info.p_editDate, info.p_hits, InsertSorting(info.pc_id), info.p_img, info.p_files, info.l_id, info.p_id)); } }
public void Update(Product product) { _product.Update(product.Name, product.BrandId, product.Description, product.Price, product.Size, product.Stock, product.CategoryId, product.Colour, product.ProductId); }