public void readBarcode(string barcode)
        {
            bool found = false;
            bool isWeight = false;

            if (g.conf1.Trim() != "" && g.conf3.Trim() != "" && g.conf4.Trim() != "")
            {
                if (barcode.IndexOf(g.conf1) == 0)
                {
                    isWeight = true;

                    foreach (Item it in g.meta)
                    {
                        if (it.med == "")
                        {
                            if (it.isEqual(barcode.Substring(g.conf1.Length, Convert.ToInt32(g.conf4)), g.conf2))
                            {
                                try
                                {
                                    double weight = double.Parse(barcode.Substring(g.conf1.Length + Convert.ToInt32(g.conf3.Length), Convert.ToInt32(g.conf9.Length)).Replace(',', '.'), System.Globalization.NumberFormatInfo.InvariantInfo);
                                    weight = weight * double.Parse(g.conf3.Replace(',', '.'), System.Globalization.NumberFormatInfo.InvariantInfo);
                                    ItemEdit ir = new ItemEdit(g, it.id, weight.ToString());
                                    ir.ShowDialog();
                                    Clipboard.SetDataObject(" ");
                                }
                                catch (Exception) { MessageBox.Show("Неправильные настройки весового товара! Невозможно определить вес!"); }

                                g.LoadMeta();

                                if (g.conf10 != "1")
                                {

                                    for (int i = 0; i < dataGrid.Rows.Count; i++)
                                    {
                                        if (dataGrid1[i, 0].ToString() == it.id)
                                        {
                                            foreach (Item itb in g.meta)
                                            {
                                                if (it.med == "")
                                                {
                                                    if (it.id == dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString())
                                                    {
                                                        dataGrid1[dataGrid1.CurrentRowIndex, 3] = itb.count;
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                return;
                            }
                        }
                    }
                }
            }

            if (isWeight) return;

            foreach (Item it in g.meta)
            {
                if (it.med == "")
                {
                    if (it.barcode == barcode)
                    {
                        found = true;
                        ItemEdit ir = new ItemEdit(g, it.id);
                        ir.ShowDialog();
                        Clipboard.SetDataObject(" ");
                        g.LoadMeta();

                        if (g.conf10 != "1")
                        {
                            for (int i = 0; i < dataGrid.Rows.Count; i++)
                            {
                                if (dataGrid1[i, 0].ToString() == it.id)
                                {
                                    foreach (Item itb in g.meta)
                                    {
                                        if (it.med == "")
                                        {
                                            if (it.id == dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString())
                                            {
                                                dataGrid1[dataGrid1.CurrentRowIndex, 3] = itb.count;
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        return;
                    }
                }
            }

            if (!found)
            {
                DialogResult dialogResult = MessageBox.Show("Обьект не найден в справочнике! Хотите добавить?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (dialogResult == DialogResult.Yes)
                {
                    ItemAdd ir = new ItemAdd(g, barcode,"");
                    ir.ShowDialog();
                    Clipboard.SetDataObject(" ");
                    SetupDataTable("");
                }
            }
        }
        private void dataGrid1_DoubleClick(object sender, EventArgs e)
        {
            Clipboard.SetDataObject(" ");
            try
            {
                ItemEdit ir = new ItemEdit(g, dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString());
                ir.ShowDialog();

                g.LoadMeta();

                foreach (Item it in g.meta)
                {
                    if (it.id == dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString())
                    {
                        dataGrid1[dataGrid1.CurrentRowIndex, 3] = it.count;
                        break;
                    }
                }
            }
            catch (Exception)
            {

            }
            Clipboard.SetDataObject(" ");
        }