예제 #1
0
        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("");
                }
            }
        }
예제 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     ItemAdd ir = new ItemAdd(g, "","");
     ir.ShowDialog();
     SetupDataTable("");
 }