private void WbGridView_DoubleClick(object sender, EventArgs e)
 {
     if (xtraTabPage14.PageVisible)
     {
         AddItem.PerformClick();
     }
     else
     {
         OkButton.PerformClick();
     }
 }
 private void WhMatGridView_DoubleClick(object sender, EventArgs e)
 {
     if (isMatList)
     {
         AddItem.PerformClick();
     }
     else if (isDirectList)
     {
         var frm = this.Parent as frmWhCatalog;
         frm.OkButton.PerformClick();
     }
     else
     {
         if (focused_wh_mat != null)
         {
             IHelper.ShowTurnMaterial(focused_wh_mat.MatId);
         }
     }
 }
        private void BarCodeEdit_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && !String.IsNullOrEmpty(BarCodeEdit.Text))
            {
                var    BarCodeSplit = BarCodeEdit.Text.Split('+');
                String kod          = BarCodeSplit[0];

                var row = WhMatGetBS.List.OfType <WhMatGet_Result>().ToList().Find(f => f.BarCode == kod);
                var pos = WhMatGetBS.IndexOf(row);
                WhMatGetBS.Position = pos;

                /*  if (row == null)
                 * {
                 *    MessageBox.Show("Товар не знайдено !");
                 *    BarCodeEdit.Text = "";
                 *    return;
                 * }*/
                if (MatListTabPage.PageVisible)
                {
                    if (row != null)
                    {
                        if (BarCodeSplit.Count() > 2)
                        {
                            var price = Convert.ToDecimal(BarCodeSplit[1] + "," + BarCodeSplit[2]);
                            var frm   = new frmWeightEdit(row.MatName);
                            frm.PriceEdit.EditValue = price;

                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                var wh_row = WhRemainGridView.GetFocusedRow() as MatRemainByWh_Result;

                                custom_mat_list.Add(new CustomMatListWH
                                {
                                    Num      = custom_mat_list.Count() + 1,
                                    MatId    = row.MatId,
                                    Name     = row.MatName,
                                    Amount   = frm.AmountEdit.Value,
                                    Price    = frm.PriceEdit.Value,
                                    WId      = wh_row != null ? wh_row.WId : DBHelper.WhList.FirstOrDefault(w => w.Def == 1).WId,
                                    PTypeId  = null,
                                    Discount = DB.SkladBase().GetDiscount(wb.KaId, row.MatId).FirstOrDefault() ?? 0.00m
                                });

                                MatListGridView.RefreshData();
                            }
                        }
                        else
                        {
                            AddItem.PerformClick();
                        }
                    }
                    else
                    {
                        if (BarCodeEdit.Text.Count() == 13)
                        {
                            var ean13 = new EAN13(BarCodeEdit.Text);

                            var row2 = WhMatGetBS.List.OfType <WhMatGet_Result>().ToList().Find(f => f.Artikul == ean13.artikul);
                            var pos2 = WhMatGetBS.IndexOf(row2);

                            WhMatGetBS.Position = pos2;

                            if (row2 != null)
                            {
                                AddMatToCustomList(ean13.amount);
                            }
                        }
                    }
                }


                BarCodeEdit.Text = "";
            }
        }