示例#1
0
        internal static void LogACCESSORY(ACCESSORY accessory, string logHeader)
        {
            if (!DoLogging)
            {
                return;
            }

            string accHeader = logHeader + "ACCESSORY ";

            //LogEQUIPMENT( (EQUIPMENT)accessory, accHeader );

            Log.Trace(accHeader + "equipmentCode=" + accessory.equipmentCode);
            Log.Trace(accHeader + "lastDSSN=" + accessory.lastDSSN);

            LogPROPERTIES(accessory.property, logHeader);
        }
示例#2
0
 public bool addAccessories(ACCESSORY a, PRODUCT p)
 {
     return(db.addAccessories(a, p));
 }
示例#3
0
 public bool updateAccessories(ACCESSORY a, PRODUCT p)
 {
     return(db.updateAccessories(a, p));
 }
示例#4
0
        protected void btnAddProduct_Click(object sender, EventArgs e)
        {
            bool result = false;

            try
            {
                //create a product object
                PRODUCT newProduct = new PRODUCT();
                newProduct.Name = txtName.Text;
                newProduct.ProductDescription = txtPrice.Text;
                if (drpProductType.SelectedIndex == 0)
                {
                    PRODUCT   p = new PRODUCT();
                    ACCESSORY a = new ACCESSORY();
                    if (btnAddProduct.Text != "Save")
                    {
                        string ID = function.GenerateRandomProductID();
                        newProduct.ProductID = ID;
                        a.TreatmentID        = ID;
                        a.Qty = 0;
                    }
                    else if (btnAddProduct.Text == "Save")
                    {
                        a.TreatmentID = productID;
                    }
                    a.Colour             = txtcolour.Text;
                    a.BrandID            = drpBrandList.SelectedValue.ToString();
                    p.Name               = txtName.Text;
                    p.ProductDescription = txtProductDescription.Text;
                    p.Price              = Convert.ToDecimal(txtPrice.Text);
                    p.ProductType        = drpProductType.SelectedValue.ToString();
                    a.supplierID         = drpListSupplier.SelectedValue.ToString();

                    if (btnAddProduct.Text != "Save")
                    {
                        result    = handler.addAccessories(a, p);
                        productID = newProduct.ProductID;
                    }
                    else if (btnAddProduct.Text == "Save")
                    {
                        //run updated product BLL method for accessory
                        result = handler.updateAccessories(a, p);
                    }
                }
                else if (drpProductType.SelectedIndex == 1)
                {
                    PRODUCT   p = new PRODUCT();
                    TREATMENT t = new TREATMENT();
                    if (btnAddProduct.Text != "Save")
                    {
                        string prodID = function.GenerateRandomProductID();
                        newProduct.ProductID = ID;
                        t.TreatmentID        = prodID;
                        t.Qty = 0;
                    }
                    else if (btnAddProduct.Text == "Save")
                    {
                        t.TreatmentID = productID;
                    }
                    t.BrandID            = drpBrandList.SelectedValue.ToString();
                    p.Name               = txtName.Text;
                    p.ProductDescription = txtProductDescription.Text;
                    p.Price              = Convert.ToDecimal(txtPrice.Text);
                    p.ProductType        = drpProductType.SelectedValue.ToString();
                    t.supplierID         = drpListSupplier.SelectedValue.ToString();
                    t.TreatmentType      = txtcolour.Text;

                    if (btnAddProduct.Text != "Save")
                    {
                        result    = handler.addTreatments(t, p);
                        productID = newProduct.ProductID;
                    }
                    else if (btnAddProduct.Text == "Save")
                    {
                        //run updated product BLL method fot treatment
                        result = handler.updateTreatments(t, p);
                    }
                }

                Boolean fileOK = false;
                string  path   = Server.MapPath("~/Theam/img/");
                if (flUploadServiceimg.HasFile)
                {
                    String fileExtension =
                        System.IO.Path.GetExtension(flUploadServiceimg.FileName).ToLower();
                    String[] allowedExtensions =
                    { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }
                }

                if (File.Exists(path + productID + ".jpg"))
                {
                    File.Delete(path + productID + ".jpg");
                }

                if (fileOK)
                {
                    flUploadServiceimg.PostedFile.SaveAs(path + productID + ".jpg");
                }
            }
            catch (Exception Err)
            {
                function.logAnError(Err.ToString());
                Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An Error Occured Communicating With The Data Base, Try Again Later");
            }

            if (result == true)
            {
                Response.Redirect("../cheveux/Products.aspx?ProductID=" + productID);
            }
            else
            {
                Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An Error Occured Communicating With The Data Base, Try Again Later");
            }
        }