Exemplo n.º 1
0
        public bool GetDataIN()
        {
            string res = "";
            string sku, barcode;

            sku     = txtINSKU.Text;
            barcode = txtINBarcode.Text;

            if (sku.Contains('~'))
            {
                sku = sku.Substring(sku.IndexOf('~'), sku.Length - sku.IndexOf('~'));
            }
            if (sku.Contains('/'))
            {
                sku = sku.Remove(sku.IndexOf('/'), sku.Length - sku.IndexOf('/'));
            }

            if (barcode.Contains('~'))
            {
                barcode = barcode.Substring(barcode.IndexOf('~'), barcode.Length - barcode.IndexOf('~'));
            }
            if (barcode.Contains('/'))
            {
                barcode = barcode.Remove(barcode.IndexOf('/'), barcode.Length - barcode.IndexOf('/'));
            }


            InventoryRecord ir = inventory.GetData(sku.Replace("~", "").Replace("/", "").Replace("?", "").Replace(@"\\", ""), barcode.Replace("~", "").Replace("/", "").Replace("?", "").Replace(@"\\", ""), ref res);

            if (IL.Find(x => x.SKU == ir.SKU) != null)
            {
                int o = IL.FindIndex(x => x.SKU == ir.SKU);
                IL[o].Quantity += 1;
                dgvIN.Rows[o].Cells[clmINTotalQuantity.Name].Value = int.Parse(dgvIN.Rows[o].Cells[clmINTotalQuantity.Name].Value.ToString()) + 1;

                txtINTotalSKU.Text = (int.Parse(txtINTotalSKU.Text) + 1).ToString();
                if (!IsRestore)
                {
                    datalog.UpdateLog(IL[o], "IN");
                }
                return(true);
            }
            if (res == "0")
            {
                dgvIN.Rows.Add();
                ir.Quantity = 1;
                IL.Add(ir);
                DataGridViewRow r = dgvIN.Rows[dgvIN.Rows.Count - 1];
                r.Cells[clmINBarCode.Name].Value       = ir.Barcode;
                r.Cells[clmINSKU.Name].Value           = ir.SKU;
                r.Cells[clmINItemName.Name].Value      = ir.ProductName;
                r.Cells[clmINPrice.Name].Value         = Math.Round(ir.Price, 2);
                r.Cells[clmINTotalQuantity.Name].Value = 1;
                r.Cells[seq.Name].Value = dgvIN.Rows.Count;
                if (ir.OrderNumber != 0)
                {
                    r.Cells[clmINOrderNumber.Name].Value = ir.OrderNumber;
                }

                txtINTotalSKU.Text  = (int.Parse(txtINTotalSKU.Text) + 1).ToString();
                txtINTotalUSKU.Text = (int.Parse(txtINTotalUSKU.Text) + 1).ToString();
                if (!IsRestore)
                {
                    datalog.AddToLog(ir, "IN");
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }