Example #1
0
        ////////////Конец Блок МЕНЮ////////////////
        private void Button4_Click(object sender, EventArgs e) //Продажа товара
        {
            if (ToDecimal(tbSumm2.Text) > ToDecimal(tbSummAll.Text))
            {
                tbSumm2.BackColor = Color.LightCoral;
            }
            else
            {
                try
                {
                    Drv.Connect();
                    Drv.GetShortECRStatus();
                    if (Drv.ECRMode == 4)
                    {
                        ОткрытьСменуToolStripMenuItem_Click(sender, e);
                    }
                }
                catch
                { UpdateResult(); } //Если смена закрыта то Открыть как положено

                groupBox3.Visible = false;

                int     CheckType = EnterItems(labelCheckType.Text);
                int     PaymentItemSign_i;
                string  NameProduct_i;
                decimal Price_i;
                double  Quantity_i;
                int     Tax1_i;
                decimal Summ1_i;
                for (int i = 0; i < arrayCheckBox.Length; i++) //Регистрация позиций в чеке
                {
                    if (arrayCheckBox[i].Checked)
                    {
                        PaymentItemSign_i = EnterItems(arrayPaymentItemSign[i].Text);
                        NameProduct_i     = arrayNameProduct[i].Text;
                        Price_i           = ToDecimal(arrayPrice[i].Text);
                        Quantity_i        = Convert.ToDouble(arrayQuantity[i].Text);
                        Summ1_i           = ToDecimal(arraySumm[i].Text);
                        Tax1_i            = EnterItems(arrayTax[i].Text);
                        if (!ShtrihKKT.RegPosition(Drv, CheckType, PaymentItemSign_i, NameProduct_i, Price_i, Quantity_i, Tax1_i, Summ1_i))
                        {
                            break;
                        }
                    }
                }
                if (Drv.ResultCode == 0) //Если позиции пробитилсь то идем дальше
                {
                    ShtrihKKT.SendFIO(Drv, fioCasher, innCasher);

                    if (maskTBPhone.BackColor == Color.LightGreen)
                    {
                        ShtrihKKT.SendCustomerPhoneOrEmail(Drv, maskTBPhone.Text.Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", ""));
                    }
                    else if (tbEmail.BackColor == Color.LightGreen)
                    {
                        ShtrihKKT.SendCustomerPhoneOrEmail(Drv, tbEmail.Text);
                    }

                    if (tbCustomer.BackColor == Color.LightGreen && tbCustomerINN.BackColor == Color.LightGreen)
                    {
                        ShtrihKKT.SendCustomer(Drv, tbCustomer.Text, tbCustomerINN.Text);
                    }

                    decimal cashPayment       = ToDecimal(tbSumm1.Text);
                    decimal electronicPayment = ToDecimal(tbSumm2.Text);
                    int     TaxType           = EnterItems(cB_FN_TaxType.Text);
                    if (ShtrihKKT.CloseChek(Drv, cashPayment, electronicPayment, TaxType))
                    {
                        tbSumm1.Text       = "0,00";
                        tbSumm2.Text       = "0,00";
                        maskTBPhone.Text   = "";
                        tbEmail.Text       = "";
                        tbCustomer.Text    = "";
                        tbCustomerINN.Text = "";
                        InitialArrays();
                        labelCheckType.Text = "Приход";
                        tbSumm1.Visible     = false;
                        tbSumm2.Visible     = false;
                        GetCashReg();
                    }
                    else
                    {
                        UpdateResult();
                    }
                }
                else
                {
                    UpdateResult();
                }
                panel2.Visible = true;
            }
        }