Ejemplo n.º 1
0
        public void addProven(List <string> lista, int id, List <OwnedProductView> dataOwnedProduct, int deliveryNoteID)
        {
            ProvenProduct provenProduct = new ProvenProduct();
            Product       product       = new Product();

            foreach (string serial in lista)
            {
                product = context.Product.FirstOrDefault(c => c.serialNo == serial);


                if (product == null)
                {
                    string message =
                        "Zeskanowano serial (" + serial + "), który nie widnieje na fakturze.\nCzy chcesz go dodać?";
                    const string caption = "Edycja";
                    var          result  = MessageBox.Show(message, caption,
                                                           MessageBoxButtons.YesNo,
                                                           MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        addIncorrectProven(id, deliveryNoteID, serial);
                    }
                }
                else
                {
                    addCorrectProven(id, deliveryNoteID, serial);
                }
            }
            dataGridViewProvenProduct.DataSource = null;
            dataGridViewProvenProduct.DataSource = (from c in context.OwnedProductView where c.deliveryNoteID == deliveryNoteID select c).ToList();
            offTheList();
            dataGridViewProvenProduct.Columns["deliveryNoteID"].Visible = false;
        }
        public List <OwnedProductView> loadProducts(int deliveryNoteID)
        {
            this.dataOwnedProduct = (from c in context.OwnedProductView where c.deliveryNoteID == deliveryNoteID select c).ToList();
            dataGridViewProvenProducts.DataSource = this.dataOwnedProduct;
            dataGridViewProvenProducts.Columns["deliveryNoteID"].Visible = false;
            foreach (DataGridViewRow row in dataGridViewProducts.Rows)
            {
                var dataGridViewProductCell = row.Cells[0].Value.ToString().Trim();
                pProduct = context.ProvenProduct.FirstOrDefault(c => c.cSerialNo == dataGridViewProductCell);
                if ((pProduct != null) && (pProduct.cSerialNo.Trim().Equals(dataGridViewProductCell)))
                {
                    row.DefaultCellStyle.BackColor = Color.Green;
                }
            }
            {
                foreach (DataGridViewRow row in dataGridViewProvenProducts.Rows)
                {
                    if (row.Cells[4].Value.Equals(true))
                    {
                        row.DefaultCellStyle.BackColor = Color.Red;
                    }
                }
            }

            return(this.dataOwnedProduct);
        }
Ejemplo n.º 3
0
        public void addIncorrectProven(int id, int deliveryNoteID, string serial)
        {
            ProvenProduct provenProduct = new ProvenProduct();

            provenProduct.usersID        = id;
            provenProduct.checkDate      = DateTime.Now;
            provenProduct.deliveryNoteID = deliveryNoteID;
            provenProduct.cSerialNo      = serial.Trim();
            provenProduct.cCompany       = "";
            provenProduct.cOrderNumber   = "";
            provenProduct.cItemNumber    = 0;
            provenProduct.cProductCode   = "";
            provenProduct.cProductName   = "Produkt nieznany";
            provenProduct.offTheList     = true;

            context.ProvenProduct.Add(provenProduct);
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        public void addCorrectProven(int id, int deliveryNoteID, string serial)
        {
            ProvenProduct provenProduct = new ProvenProduct();
            Product       product       = new Product();

            product = context.Product.FirstOrDefault(c => c.serialNo == serial);
            provenProduct.usersID        = id;
            provenProduct.checkDate      = DateTime.Now;
            provenProduct.deliveryNoteID = deliveryNoteID;
            provenProduct.cSerialNo      = serial.Trim();
            provenProduct.cCompany       = product.company;
            provenProduct.cOrderNumber   = product.orderNumber;
            provenProduct.cItemNumber    = product.itemNumber;
            provenProduct.cProductCode   = product.productCode;
            provenProduct.cProductName   = product.productName;
            provenProduct.offTheList     = false;
            context.ProvenProduct.Add(provenProduct);
            context.SaveChanges();
        }