Exemple #1
0
        /// <summary>
        /// returns Product initialization by id
        /// </summary>
        /// <param name="id"></param>
        /// <param name="prodTskNameRepository"></param>
        /// <param name="formatsRepository"></param>
        /// <param name="typeOfTaskRepository"></param>
        /// <returns></returns>
        public Product InitProduct(string id, IProductTaskNameRepository prodTskNameRepository, IFormatsNameRepository formatsRepository, ITypeOfTaskRepository typeOfTaskRepository)
        {

            Product product;
            product = new ProductEmpty();

            if (id == "Buste" ||
                id == "Volantini" ||
                id == "Pieghevoli" ||
                id == "EtichetteCartellini" ||
                id == "CartaIntestata" ||
                id == "Locandine" ||
                id == "FogliMacchina")
            {
                product = new ProductSingleSheet();
            }

            if (
                id == "BigliettiVisita" ||
                id == "EtichetteCartelliniSago" ||
                id == "CartolineInviti" ||
                id == "CartolinePostali" ||
                id == "AltriFormati")
            {
                product = new ProductSingleSheet();
                product.ShowDCut = true;
                //                product.DCut = 0.5;
                product.DCut1 = 0.5;
                product.DCut2 = 0.5;
            }

            if (id == "PuntoMetallico" ||
                id == "SpiraleMetallica" ||
                id == "BrossuraFresata" ||
                id == "BrossuraCucitaFilo" ||
                id == "RivistePostalizzazione" ||
                id == "SchedeNonRilegate")
            {
                product = new ProductBookSheet();
            }

            if (
                id == "Fotoquadri" ||
                id == "SuppRigidi")
            {
                product = new ProductRigid();
                product.ShowDCut = true;
                product.DCut = 0;
                product.DCut1 = 1;
                product.DCut2 = 1;

            }

            if (
                id == "PVC" ||
                id == "Manifesti" ||
                id == "Striscioni" ||
                id == "Poster")
            {
                product = new ProductSoft();
            }

            if (
                id == "EtichetteRotolo" ||
                id == "EtichetteSagRotolo" ||
                id.StartsWith("FasceGommateRotolo"))
            {
                product = new ProductSingleLabelRoll();
            }

            if (
                id == "EtichetteRotoloDouble")
            {
                product = new ProductDoubleLabelRoll();
            }

            product.CodMenuProduct = id;
            product.ProductTaskName = prodTskNameRepository.GetAllById(id);
            product.FormatsName = formatsRepository.GetAllById(id);

            product.SystemTaskList = typeOfTaskRepository.GetAll().ToList();

            product.ProductNameGenerator = ProductRepository.GetProductNameGenerator(id).Generator;
            product.InitProduct();

            return product;

        }
Exemple #2
0
        public ActionResult Excel(HttpPostedFileBase file)
        {
            DataSet ds = new DataSet();
            if (Request.Files["file"].ContentLength > 0)
            {
                string fileExtension =
                                     System.IO.Path.GetExtension(Request.Files["file"].FileName);

                if (fileExtension == ".xls" || fileExtension == ".xlsx")
                {
                    string fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName;
                    if (System.IO.File.Exists(fileLocation))
                    {

                        System.IO.File.Delete(fileLocation);
                    }
                    Request.Files["file"].SaveAs(fileLocation);
                    string excelConnectionString = string.Empty;
                    excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                    fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                    //connection String for xls file format.
                    if (fileExtension == ".xls")
                    {
                        excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
                        fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                    }
                    //connection String for xlsx file format.
                    else if (fileExtension == ".xlsx")
                    {
                        excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                        fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                    }
                    //Create Connection to Excel work book and add oledb namespace
                    OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
                    excelConnection.Open();
                    DataTable dt = new DataTable();

                    dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    if (dt == null)
                    {
                        return null;
                    }

                    String[] excelSheets = new String[dt.Rows.Count];
                    int t = 0;
                    //excel data saves in temp file here.
                    foreach (DataRow row in dt.Rows)
                    {
                        excelSheets[t] = row["TABLE_NAME"].ToString();
                        t++;
                    }
                    OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString);


                    string query = string.Format("Select * from [{0}]", excelSheets[0]);
                    using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1))
                    {
                        dataAdapter.Fill(ds);
                    }

                    excelConnection.Close();
                    excelConnection1.Close();
                }
                if (fileExtension.ToString().ToLower().Equals(".xml"))
                {
                    string fileLocation = Server.MapPath("~/Content/") + Request.Files["FileUpload"].FileName;
                    if (System.IO.File.Exists(fileLocation))
                    {
                        System.IO.File.Delete(fileLocation);
                    }

                    Request.Files["FileUpload"].SaveAs(fileLocation);
                    XmlTextReader xmlreader = new XmlTextReader(fileLocation);
                    // DataSet ds = new DataSet();
                    ds.ReadXml(xmlreader);
                    xmlreader.Close();
                }

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    var a = new ProductEmpty();
                    a.CodProduct = (ds.Tables[0].Rows[i][0].ToString()).PadLeft(6, '0');
                    a.ProductName = ds.Tables[0].Rows[i][1].ToString();
                    a.CodMenuProduct = "Vuoto";

                    var b = productRepository.GetSingle(a.CodProduct);
                    if (b == null)
                    {
                        productRepository.Add(a);
                    }
                    else
                    {
                        b.ProductName = a.ProductName;
                        b.CodMenuProduct = "Vuoto";
                        productRepository.Edit(b);
                    }

                    productRepository.Save();

                    //now we have to create new warehouse article (ptoduct) and new mov of load!!!

                    var mov = new WarehouseArticleMov();
                    //il codice del movimento lo prendo dal codice dell'articolo
                    mov.CodWarehouseArticle = "001P" + b.CodProduct;
                    mov.CodWarehouseArticleMov = warehouseRepository.GetNewMovCode(mov);
                    mov.TypeOfMov = 1;
                    mov.Date = DateTime.Now;
                    mov.Quantity = Convert.ToDouble(ds.Tables[0].Rows[i][2].ToString());


                    if (mov.Quantity != 0)
                    {
                        warehouseRepository.AddMov(mov);
                        warehouseRepository.Save();

                        warehouseRepository.UpdateArticle(warehouseRepository.GetSingle(mov.CodWarehouseArticle));
                        warehouseRepository.Save();
                    }

                }

            }



            return View();
        }
Exemple #3
0
        public virtual void Copy(ProductEmpty to)
        {
            //All properties of object
            //and pointer of sons


        }
Exemple #4
0
        public HttpResponseMessage Test(
            string username,
            string nCom,
            string nPrev,
            string desc,
            string field1,
            string field2,
            string field3,
            string quantity,
            string price)
        {

            this.Init();

            taskCenterRepository.SetDbName(username);
            productRepository.SetDbName(username);
            documentRepository.SetDbName(username);

            //cerco il prodotto ---> se c'è ok
            //altrimenti lo creo come generico!!!

            //cerco la commessa ---> se c'è ok
            //altrimenti la creo

            var prod = productRepository.GetAll().Where(x => x.PapiroPrev == nPrev).FirstOrDefault();

            if (prod == null)
            {
                prod = new ProductEmpty();
                prod.CodProduct = productRepository.GetNewCode(prod);
                prod.CodMenuProduct = "Vuoto";
                prod.PapiroPrev = nPrev;
                prod.ProductName = desc;

                productRepository.Add(prod);
                productRepository.Save();
            }

            var docProd = documentRepository.GetAllDocumentProducts().Where(x => x.CodProduct == prod.CodProduct).FirstOrDefault();

            if (docProd == null)
            {
                docProd = new DocumentProduct();
                docProd.CodProduct = prod.CodProduct;
                docProd.UnitPrice = "0";//Convert.ToDouble(price).ToString();
                docProd.Quantity = 0; // Convert.ToInt16(quantity);

                Estimate e = new Estimate();
                e.CodDocument = documentRepository.GetNewCode(e);
                e.EstimateNumberSerie = DateTime.Now.Year.ToString();
                e.EstimateNumber = documentRepository.GetNewEstimateNumber(e);

                //var docProd = documentRepository.GetDocumentProductByCodDocumentProduct(codDocumentProduct);
                e.DocumentProducts.Add(docProd);

                documentRepository.Add(e);
                documentRepository.Save();

                docProd.Product = prod;
            }


            var c = (Order)documentRepository.GetAll().Where(x => x.PapiroCom == nCom).FirstOrDefault();

            if (c == null)
            {
                c = new Order();
                c.CodDocument = documentRepository.GetNewCode(c);
                c.OrderNumberSerie = DateTime.Now.Year.ToString();
                c.OrderNumber = documentRepository.GetNewOrderNumber(c);
                c.PapiroCom = nCom;

                c.OrderProduct = docProd;
                //c.CodCustomer = docProd.Document.CodCustomer;
                //c.Customer = docProd.Document.Customer;

                c.DateDocument = DateTime.Now;

                var allStates = documentRepository.GetAllStates().Where(x => (x.UseInOrder ?? false)).OrderBy(x => x.StateNumber);

                foreach (var s in allStates)
                {
                    c.DocumentStates.Add(new DocumentState
                    {
                        CodDocument = c.CodDocument,
                        StateNumber = s.StateNumber,
                        CodState = s.CodState,
                        //                    StateName = s.StateName, //derivated!!!
                        ResetLinkedStates = s.ResetLinkedStates,
                        Selected = false
                    });
                }

                documentRepository.Add(c);
                documentRepository.Save();

                //se ci sono dei TaskCenter inizio a buttare i taskcenter nel primo taskcenter (IndexOf==0)
                var taskCenter = taskCenterRepository.GetAll().Where(y => y.IndexOf == 0).FirstOrDefault();

                if (taskCenter != null)
                {
                    DocumentTaskCenter dtc = new DocumentTaskCenter();
                    dtc.CodTaskCenter = taskCenter.CodTaskCenter;
                    dtc.CodDocument = c.CodDocument;

                    if (docProd.Product.ProductRefName == null)
                    {
                        dtc.DocumentName = docProd.Product.ProductName;
                    }
                    else
                    {
                        dtc.DocumentName = docProd.Product.ProductRefName;
                    }


                    dtc.FieldA = field1;
                    dtc.FieldB = field2;
                    dtc.FieldC = field3;

                    if (username.ToLower() == "lamarina")
                    {
                        try
                        {
                            dtc.DocumentName = nCom.Substring(0,nCom.IndexOf('/')) + " " + dtc.DocumentName + " " + field1;
                        }
                        catch (Exception)
                        {
                        }
                        dtc.FieldA = "";
                    }
                    else
                    {
                        dtc.DocumentName = nCom + " " + dtc.DocumentName;
                    }

                    taskCenterRepository.AddNewDocumentTaskCenter(dtc);
                    taskCenterRepository.Save();
                }

            }

            taskCenterRepository.Dispose();
            productRepository.Dispose();
            documentRepository.Dispose();

            return Request.CreateResponse<string>(HttpStatusCode.OK, username);
        }