Example #1
0
        public void AddProductHierarchys(XElement XMLProHei)
        {
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {
                    log.Error("Cannot open the Database due to: ", ex);
                    return;
                }
            }
            try
            {
                IEnumerable <XElement> Prohei =
                    from phs in XMLProHei.Elements("Statement").Elements("PRODHIERTABLE").Elements("access")
                    select phs;
                foreach (XElement ph in Prohei)
                {
                    ProHierarchy Pro = new ProHierarchy();
                    Pro.BrandCode    = ph.Element("BrandCode").Value;
                    Pro.BrandName    = ph.Element("BrandName").Value;
                    Pro.SubBrandCode = ph.Element("SubBrandCode").Value;
                    Pro.SubbrandName = ph.Element("SubbrandName").Value;
                    Pro.ProductID    = ph.Element("ProductID").Value;
                    Pro.CompanyID    = ph.Element("CompanyID").Value;
                    Pro.Status       = ph.Element("Status").Value;
                    int result = Pro.Inert_ProHei(Pro, conn);
                    if (result == 1)
                    {
                        log.Info("Insert to PRODHIERTABLE successfull: " + Pro.BrandCode);
                    }
                    else
                    {
                        log.Info("Insert to PRODHIERTABLE failed: " + Pro.BrandCode);
                    }
                }
                conn.Close();
            }

            catch (Exception ex)
            {
                log.Error("Insert into CUSTMSTTABLE failed due to: " + ex);
                return;
            }
        }