Exemplo n.º 1
0
        private void NewOrderButton_Click(object sender, EventArgs e)
        {
            if (DocNumberTextEdit.Text.Length == 0)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, false,
                                                              "Вы не ввели номер документа", "Создание заказа");

                return;
            }

            if (DocNumberTextEdit.Text != NewOrderInfo.DocNumber)
            {
                GetOrderInfo();
            }

            if (!NewOrderInfo.IsEditOrder && !NewOrderInfo.IsDoubleOrder && !NewOrderInfo.MovePrepare && NewOrderInfo.OrderStatus != Modules.ZOV.NewOrderInfo.OrderStatusType.NewOrder)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, false,
                                                              "Указанный номер документа уже существует", "Создание заказа");
                //label3.Text = "Кухня уже существует";
                label3.Left = panel4.Width / 2 - label3.Width / 2;
                return;
            }

            if (NewOrderInfo.IsPrepare && NewOrderInfo.MovePrepare && !NewOrderInfo.IsNewOrder)
            {
                if (!OrdersManager.IsDoubleOrder(NewOrderInfo.MainOrderID))
                {
                    bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, false,
                                                                  "Заказ не прошёл двойное вбивание, его нельзя перенести на отгрузку", "Перенос кухни");

                    return;
                }
            }

            if (NewOrderInfo.OrderStatus == Modules.ZOV.NewOrderInfo.OrderStatusType.NewOrder &&
                NewOrderInfo.IsDoubleOrder)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, false,
                                                              "Заказ ещё не был создан", "Двойное вбивание");

                return;
            }

            if (DebtCheckBox.Checked && DebtDocNumberTextBox.Text.Length == 0)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, false,
                                                              "Вы не ввели номер документа долга", "Создание заказа");

                return;
            }

            bool IsOrderInProduction = OrdersManager.IsOrderInProduction(NewOrderInfo.MainOrderID);

            if (NewOrderInfo.MovePrepare && !NewOrderInfo.IsDoubleOrder && !IsOrderInProduction)
            {
                Infinium.LightMessageBox.Show(ref TopForm, false,
                                              "Заказ не был отдан в производство. Перенос запрещен",
                                              "Предупреждение");
            }

            object DispatchDate = null;

            int DebtTypeID  = 0;
            int PriceTypeID = -1;

            string Notes         = string.Empty;
            string DocNumber     = string.Empty;
            string DebtDocNumber = string.Empty;

            if (RetailPriceRadio.Checked)
            {
                PriceTypeID = 0;
            }
            if (WholePriceRadio.Checked)
            {
                PriceTypeID = 1;
            }
            if (WallPriceRadio.Checked)
            {
                PriceTypeID = 2;
            }

            if (DebtTypeComboBox.Enabled)
            {
                DebtTypeID = Convert.ToInt32(DebtTypeComboBox.SelectedValue);
            }
            NewOrderInfo.DocDateTime = Security.GetCurrentDate();

            if (DispDateDateTimePicker.Enabled)
            {
                DispatchDate = DispDateDateTimePicker.Value;
                OrdersManager.CurrentDispatchDate = Convert.ToDateTime(DispatchDate);
            }

            if (PrepareCheckBox.Checked)
            {
                NewOrderInfo.DispatchDate = null;
            }
            else
            {
                NewOrderInfo.DispatchDate         = Convert.ToDateTime(DispatchDate);
                OrdersManager.CurrentDispatchDate = Convert.ToDateTime(DispatchDate);
            }

            NewOrderInfo.DoNotDispatch = DoNotDispatchCheckBox.Checked;
            NewOrderInfo.TechDrilling  = cbxTechDrilling.Checked;
            NewOrderInfo.QuicklyOrder  = cbxQuicklyOrder.Checked;
            NewOrderInfo.ToAssembly    = cbIsAssembly.Checked;
            NewOrderInfo.IsNotPaid     = cbIsNotPaid.Checked;
            NewOrderInfo.NeedCalculate = NeedCalculateCheckBox.Checked;

            if (NewOrderInfo.IsNewOrder)
            {
                int FirstOperatorID  = Security.CurrentUserID;
                int SecondOperatorID = 0;

                OrdersManager.CreateNewDispatch(DispatchDate);
                OrdersManager.CreateNewMainOrder(DispatchDate, Convert.ToDateTime(NewOrderInfo.DocDateTime),
                                                 Convert.ToInt32(ClientComboBox.SelectedValue), DocNumberTextEdit.Text,
                                                 DebtTypeID, SampleCheckBox.Checked, PrepareCheckBox.Checked,
                                                 PriceTypeID, NotesMemoEdit.Text, FirstOperatorID, SecondOperatorID, NewOrderInfo.DoNotDispatch, NewOrderInfo.TechDrilling,
                                                 NewOrderInfo.QuicklyOrder, NewOrderInfo.ToAssembly, NewOrderInfo.IsNotPaid, NewOrderInfo.NeedCalculate);
            }

            OrdersManager.CurrentClientID = Convert.ToInt32(ClientComboBox.SelectedValue);
            OrdersManager.IsPrepare       = PrepareCheckBox.Checked;

            NewOrderInfo.ClientID = Convert.ToInt32(ClientComboBox.SelectedValue);

            NewOrderInfo.PriceType = PriceTypeID;
            NewOrderInfo.DebtType  = DebtTypeID;

            NewOrderInfo.IsDebt    = DebtCheckBox.Checked;
            NewOrderInfo.IsSample  = SampleCheckBox.Checked;
            NewOrderInfo.IsPrepare = PrepareCheckBox.Checked;

            NewOrderInfo.DateEnabled = !PrepareCheckBox.Checked;

            NewOrderInfo.Notes = NotesMemoEdit.Text;

            NewOrderInfo.DocNumber = DocNumberTextEdit.Text;
            if (!DebtCheckBox.Checked)
            {
                DebtDocNumberTextBox.Text = string.Empty;
            }
            NewOrderInfo.DebtDocNumber = DebtDocNumberTextBox.Text;
            NewOrderInfo.bPressOK      = true;

            FormEvent            = eClose;
            AnimateTimer.Enabled = true;
        }