public override bool Save() { if (textName.Text.Trim() == "") { _manager.Alert("Please enter a name for your product."); return(false); } Product product; Products products = new Products(UserSession.LoginUser);; if (_productID < 0) { product = products.AddNewProduct(); product.OrganizationID = UserSession.LoginUser.OrganizationID; } else { products.LoadByProductID(_productID); if (products.IsEmpty) { return(false); } product = products[0]; } product.Name = textName.Text; product.Description = textDescription.Text; product.Collection.Save(); _fieldControls.RefID = product.ProductID; _fieldControls.SaveCustomFields(); return(true); }
public static string CreateProduct(RestCommand command) { Products items = new Products(command.LoginUser); Product item = items.AddNewProduct(); item.ReadFromXml(command.Data, true); item.OrganizationID = command.Organization.OrganizationID; item.Collection.Save(); item.UpdateCustomFieldsFromXml(command.Data); return(Products.GetProduct(command.LoginUser, item.ProductID).GetXml("Product", true)); }
static void Main(string[] args) { INFITF.Application catia; try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); } catia.Visible = true; ProductDocument pdctDoc = (ProductDocument)catia.Documents.Add("Product"); Product pdct = pdctDoc.Product; Products pdcts = pdct.Products; object[] tpath = { @"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\Titanicp.40(Assy)\Assembly\Hull.CATPart" }; pdcts.AddComponentsFromFiles(tpath, "*"); Product pdct1 = pdcts.AddNewProduct("ass1"); //Products ass1 = pdct1.Products; object[] tpath1 = { @"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\Titanicp.40(Assy)\Assembly\Castle.CATPart", @"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\Titanicp.40(Assy)\Assembly\Funnel.CATPart" }; pdct1.Products.AddComponentsFromFiles(tpath1, "*"); //ass1.AddComponentsFromFiles(tpath1,"*"); Product pdctRef = pdct1.ReferenceProduct; object[] aDistance = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 60, 0, 0 }; //x-vector x,y,z / y(x,y,z) / z(x,y,z) / 이동x,y,z Product pdct2 = pdcts.AddComponent(pdctRef); pdct2.Move.Apply(aDistance); aDistance[9] = 120; Product pdct3 = pdcts.AddComponent(pdctRef); pdct3.Move.Apply(aDistance); pdct.ExtractBOM(CatFileType.catFileTypeText, @"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\Titanicp.40(Assy)\Bom.txt"); pdct.ExtractBOM(CatFileType.catFileTypeHTML, @"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\Titanicp.40(Assy)\BOM.html"); }
private Product AddProduct(Products TargetProduct, string Name) { try { Product Tdocument = TargetProduct.AddNewProduct(Name); //(ProductDocument)TargetProduct.Application.Documents.Add("Product"); //Tdocument.Product.set_PartNumber(Name); return(Tdocument); } catch (Exception) { return(null);; } }
protected void addNewProduct(object sender, EventArgs e) { /* the barcode scanner cause the page to act as thought the submit product button has been clicked * the page.valid will only try to pass the product details to the database once client side validation has been passed */ if (Page.IsValid) { // the method passes the product details entered by the user to the AddNewProduct() method in the HWW.cs file Products addProd = new Products(); addProd.productName = Convert.ToString(TextProdName.Text); addProd.prodBar = Convert.ToInt64(TextProdBarcode.Text); addProd.prodMinLevel = Convert.ToInt32(TextProdMinLevel.Text); addProd.prodStockLevel = Convert.ToInt32(TextProdStockLevel.Text); addProd.prodStockCode = Convert.ToString(TextProdStockCode.Text).ToUpper(); addProd.prodCatID = Convert.ToInt32(DDLProdCat.SelectedValue); addProd.AddNewProduct(); //If an error occurs when adding the product to the database then display the error messgae tot the user String errNumber = Convert.ToString(addProd.errNo); if (addProd.errNo.Equals(2627) && (addProd.errMsg.Contains("Error in Adding barcode"))) { //Error message displayed if the barcode already exists in the database LblDupBarcode.Text = "The barcode already exists in the database"; LblDupStockCode.Text = string.Empty; } else if (addProd.errNo.Equals(2627) && (addProd.errMsg.Contains("Error in Adding product"))) { //Error message displayed if the stockcode already exists in the database LblDupStockCode.Text = "The stock code already exists in the database"; LblDupBarcode.Text = string.Empty; } else { //displays a confirmation that the product has been added to the database TxtProdAdded.Text = "The product " + addProd.productName + " has been successfully added to the database"; LblDupBarcode.Text = string.Empty; LblDupStockCode.Text = string.Empty; TxtProdAdded.Visible = true; TextProdName.Text = string.Empty; TextProdBarcode.Text = string.Empty; TextProdMinLevel.Text = string.Empty; TextProdStockLevel.Text = string.Empty; TextProdStockCode.Text = string.Empty; DDLProdCat.ClearSelection(); } } //closes if page is valid }//closes the addNewProduct class
//private void BindFlavour() //{ // try // { // DataTable dt = new DataTable(); // dt = local_product.getFlavourname(); // if (dt.Rows.Count > 0) // { // ddFlavour.DataSource = dt; // ddFlavour.DataTextField = "FlavourName"; // ddFlavour.DataValueField = "FlavourID"; // ddFlavour.DataBind(); // ddFlavour.Items.Insert(0, "Select Flavour"); // } // } // catch // { } //} protected void btnAddProduct_Click(object sender, EventArgs e) { if (txtProductName.Text.Length > 0) { if (string.IsNullOrEmpty(Convert.ToString(ViewState["ID"]))) { try { if (UploadImage.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; string smallPath = "~/Upload/small/"; string ImageFile = Path.GetFileName(Server.MapPath(UploadImage.PostedFile.FileName)); ImageFile = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + ImageFile; thumbPath = thumbPath + ImageFile; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage.PostedFile.InputStream); //System.Drawing.Image objImage = ScaleImage(bmpUploadedImage, 170); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); smallPath = smallPath + ImageFile; System.Drawing.Image objImage2 = ScaleImage2(bmpUploadedImage); objImage2.Save(Server.MapPath(smallPath), ImageFormat.Png); imgPath = imgPath + ImageFile; UploadImage.SaveAs(MapPath(imgPath)); string categoryid = Convert.ToString(ddCategory.SelectedValue); Int32 subcategoryid = 0; if (ddSubCategory.SelectedIndex > 0) { subcategoryid = Convert.ToInt32(ddSubCategory.SelectedValue); } string producturl = txtProducturl.Text; string producttitle = txtProductTitle.Text; string productkeywords = txtProductKeywords.Text; string productshortDes = txtProductShortDes.Text; string name = txtProductName.Text.Trim(); string variantnames = txtVariant.Text; string variantquantity = txtVariantquantity.Text; decimal price = Convert.ToDecimal(txtPrice.Text.Trim()); bool active; if (CheckBox1.Checked == true) { active = true; } else { active = false; } txtProductCode.Text = ""; if (txtProductName.Text != "")//SKU code { txtProductCode.Text = txtProductName.Text + " " + txtPrice.Text; } Int32 discount = 0; if (txtDiscount.Text.Length > 0) { discount = Convert.ToInt32(txtDiscount.Text.Trim()); } // Int32 quantity = Convert.ToInt32(txtQuantity.Text.Trim()); Int32 quantity = 0; string date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string brand = txtBrand.Text.Trim(); string shippingcharges = "0"; //Shipping Charges if (txtshippingcharges.Text.Length > 0) { shippingcharges = txtshippingcharges.Text.Trim(); } string weightlbl = "0"; //Weight if (txtProductCapacity.Text != "") { weightlbl = txtProductCapacity.Text.Trim(); } string flavour = ""; //Flavour int selectproduct = 1; if (rdOfferProduct.Checked == true) { selectproduct = 1; } else if (rdNewproduct.Checked == true) { selectproduct = 2; } else if (rdBestSeller.Checked == true) { selectproduct = 3; } else if (rdFeature.Checked == true) { selectproduct = 4; } string description = CKEditor1.Text; int success = 0; success = local_product.AddNewProduct(producturl, producttitle, productkeywords, productshortDes, name, variantnames, variantquantity, price, ImageFile, ImageFile, active, txtProductCode.Text, discount, date, subcategoryid, quantity, brand, shippingcharges, weightlbl, flavour, categoryid, selectproduct, description); if (success != 0) { clear(); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Product Added Successfully"; ViewState["ID"] = null; } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Product Addition Failed"; } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Select Product Photo"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } else //Update Product { string ImageFile; if (UploadImage.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; string smsllPath = "~/Upload/small/"; ImageFile = Path.GetFileName(Server.MapPath(UploadImage.PostedFile.FileName)); ImageFile = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + ImageFile; thumbPath = thumbPath + ImageFile; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage.PostedFile.InputStream); //System.Drawing.Image objImage = ScaleImage(bmpUploadedImage, 170); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); smsllPath = smsllPath + ImageFile; System.Drawing.Image objImage2 = ScaleImage2(bmpUploadedImage); objImage2.Save(Server.MapPath(smsllPath), ImageFormat.Png); imgPath = imgPath + ImageFile; UploadImage.SaveAs(MapPath(imgPath)); } else { ImageFile = lblImage.Text; } try { string productid = Request.QueryString["id"]; string producturl = txtProducturl.Text.Trim(); string producttitle = txtProductTitle.Text.Trim(); string productkeywords = txtProductKeywords.Text.Trim(); string productshortDes = txtProductShortDes.Text.Trim(); string name = txtProductName.Text.Trim(); string description = CKEditor1.Text; decimal price = Convert.ToDecimal(txtPrice.Text.Trim()); string variantnames = txtVariant.Text.Trim(); string variantquantity = txtVariantquantity.Text.Trim(); bool active; if (CheckBox1.Checked == true) { active = true; } else { active = false; } string productcode = ""; if (txtProductCode.Text != "")//SKU code { productcode = txtProductCode.Text.Trim(); } Int32 discount = 0; if (txtDiscount.Text.Length > 0) { discount = Convert.ToInt32(txtDiscount.Text.Trim()); } //Int32 quantity = Convert.ToInt32(txtQuantity.Text.Trim()); Int32 quantity = 0; string date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string categoryid = Convert.ToString(ddCategory.SelectedValue); Int32 subcategoryid = 0; if (ddSubCategory.SelectedIndex > 0) { subcategoryid = Convert.ToInt32(ddSubCategory.SelectedValue); } string brand = txtBrand.Text.Trim(); string shippingcharges = txtshippingcharges.Text.Trim(); string weightlbl = txtProductCapacity.Text.Trim(); //string flavour = ddFlavour.SelectedValue; string flavour = ""; int selectproduct = 1; if (rdOfferProduct.Checked == true) { selectproduct = 1; } else if (rdNewproduct.Checked == true) { selectproduct = 2; } else if (rdBestSeller.Checked == true) { selectproduct = 3; } else if (rdFeature.Checked == true) { selectproduct = 4; } int success = 0; success = local_product.UpdateNewProduct(productid, producturl, producttitle, productkeywords, productshortDes, name, description, price, variantnames, variantquantity, ImageFile, ImageFile, active, productcode, discount, date, quantity, brand, shippingcharges, weightlbl, flavour, subcategoryid, categoryid, selectproduct); if (success != 0) { clear(); ViewState["ID"] = null; btnAddProduct.Text = "Add Product"; lblMessage.ForeColor = Color.Green; lblMessage.Text = "Product Updated Successfully"; Response.Redirect("~/admin/EditProduct.aspx", false); } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Product Update Failed"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Enter Product Name"; } }
protected void btnAddProduct_Click(object sender, EventArgs e) { if (txtProductName.Text.Length > 0) { if (string.IsNullOrEmpty(Convert.ToString(ViewState["ID"]))) { try { string categoryid = Convert.ToString(ddCategory.SelectedValue); Int32 subcategoryid = 0; Int32 subsubcategoryid = 0; if (ddSubCategory.SelectedIndex > 0) { subcategoryid = Convert.ToInt32(ddSubCategory.SelectedValue); if (ddSubSubCategory.SelectedIndex > 0) { subsubcategoryid = Convert.ToInt32(ddSubSubCategory.SelectedValue); } } string name = txtProductName.Text.Trim(); string price = txtprice.Text.Trim(); string ImageFile = ""; if (UploadImage.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; ImageFile = Path.GetFileName(Server.MapPath(UploadImage.PostedFile.FileName)); ImageFile = ImageFile.Replace(" ", "-"); ImageFile = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + ImageFile; thumbPath = thumbPath + ImageFile; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage.PostedFile.InputStream); //System.Drawing.Image objImage = ScaleImage(bmpUploadedImage, 170); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); imgPath = imgPath + ImageFile; UploadImage.SaveAs(MapPath(imgPath)); } else { ImageFile = ""; ImageFile = ""; } string description = CKEditor1.Text; //string date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // string date = System.DateTime.Now.ToString("dd/mm/yyyy"); int success = 0; success = local_product.AddNewProduct(name, price, ImageFile, ImageFile, description, subcategoryid, subcategoryid, categoryid); if (success != 0) { clear(); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Product Added Successfully"; ViewState["ID"] = null; } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Product Addition Failed"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } else //Update Product { try { string productid = Request.QueryString["id"]; string name = txtProductName.Text.Trim(); string price = txtprice.Text.Trim(); string ImageFile; if (UploadImage.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; ImageFile = Path.GetFileName(Server.MapPath(UploadImage.PostedFile.FileName)); ImageFile = ImageFile.Replace(" ", "-"); ImageFile = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + ImageFile; thumbPath = thumbPath + ImageFile; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage.PostedFile.InputStream); //System.Drawing.Image objImage = ScaleImage(bmpUploadedImage, 170); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); imgPath = imgPath + ImageFile; UploadImage.SaveAs(MapPath(imgPath)); } else { ImageFile = lblImage.Text; } string description = CKEditor1.Text; //string date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string categoryid = Convert.ToString(ddCategory.SelectedValue); Int32 subcategoryid = 0; if (ddSubCategory.SelectedIndex > 0) { subcategoryid = Convert.ToInt32(ddSubCategory.SelectedValue); } int success = 0; success = local_product.UpdateNewProduct(productid, name, price, ImageFile, ImageFile, description, subcategoryid, categoryid); if (success != 0) { clear(); ViewState["ID"] = null; btnAddProduct.Text = "Add Product"; lblMessage.ForeColor = Color.Green; lblMessage.Text = "Product Updated Successfully"; Response.Redirect("~/admin/EditProduct.aspx", false); } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Product Update Failed"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Enter Product Name"; } }