Exemple #1
0
        private bool IsGenerateOrders(Articles articles)
        {
            referenceNoValid = String.Empty;
            numberNoValid    = String.Empty;
            if (articles == null | articles.Count <= 0 | !this.IsSceneComplete(articles))
            {
                if (numberNoValid == KD.Const.UnknownId.ToString())
                {
                    numberNoValid = "Aucun";
                }
                MessageBox.Show("L'article: '" + referenceNoValid + "', numéro: '" + numberNoValid + "' n'est pas valide." + Environment.NewLine +
                                "La commande est annulée.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(KD.StringTools.Const.FalseLowerCase, OrderKey.GenerateOrder);
                return(false);
            }
            // '
            string name1        = orderInformations.GetRetailerName1();
            string address      = orderInformations.GetRetailerAddress();
            string postCode     = orderInformations.GetRetailerPostCode();
            string city         = orderInformations.GetRetailerCity();
            string addressEmpty = KD.StringTools.Format.Spaced(KD.StringTools.Const.MinusSign) + KD.StringTools.Format.Spaced(KD.StringTools.Const.MinusSign);

            if (String.IsNullOrEmpty(name1) || address == addressEmpty || String.IsNullOrEmpty(postCode) || String.IsNullOrEmpty(city))
            {
                MessageBox.Show("Veuillez renseigner l'adresse de votre point de vente (site)." + Environment.NewLine + "La commande est annulée.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(KD.StringTools.Const.FalseLowerCase, OrderKey.GenerateOrder);
                return(false);
            }

            string supplierEmail = orderInformations.GetSupplierEmail();

            if (!String.IsNullOrEmpty(supplierEmail))
            {
                string supplierName = orderInformations.GetSupplierName();
                MessageBox.Show("Veuillez supprimer l'adresse email dans le fournisseur '" + supplierName + "'", "InSitu", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(KD.StringTools.Const.FalseLowerCase, OrderKey.GenerateOrder);
                _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(supplierEmail, OrderKey.SupplierEmail);

                orderInformations.SetSupplierEmail(String.Empty);
                //supplierEmail = orderInformations.GetSupplierEmail();

                return(false);
            }
            else
            {
                _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(null, OrderKey.SupplierEmail);
            }

            _pluginWord.CurrentAppli.Scene.SceneSetCustomInfo(KD.StringTools.Const.TrueLowerCase, OrderKey.GenerateOrder);
            return(true);
        }
Exemple #2
0
        public bool ProcessOrder(int callParamsBlock)
        {
            _pluginWord       = new KD.Plugin.Word.Plugin();
            orderInformations = new OrderInformations(this.CurrentAppli, callParamsBlock);

            string supplierName  = orderInformations.GetSupplierName();
            string generateOrder = Order._pluginWord.CurrentAppli.Scene.SceneGetCustomInfo(OrderKey.GenerateOrder);
            string supplierEmail = Order._pluginWord.CurrentAppli.Scene.SceneGetCustomInfo(OrderKey.SupplierEmail);

            if (!String.IsNullOrEmpty(supplierEmail))
            {
                orderInformations.SetSupplierEmail(supplierEmail);
            }

            if (!String.IsNullOrEmpty(generateOrder))
            {
                bool.TryParse(generateOrder, out bool isGenerateOrder);

                if (isGenerateOrder)
                {
                    string retailerNumber = orderInformations.GetRetailerNumber();
                    Order.orderDir     = orderInformations.GetOrderDir();
                    Order.rootOrderDir = orderInformations.GetRootOrderDir();
                    KD.Config.IniFile ordersIniFile = new KD.Config.IniFile(Path.Combine(Order.rootOrderDir, FileEDI.IniOrderFileName));

                    MainForm.EmailTo = ordersIniFile.ReadValue(Eancom.FileEDI.ediSection, Eancom.FileEDI.emailToKey + supplierName);
                    MainForm.EmailCc = ordersIniFile.ReadValue(Eancom.FileEDI.ediSection, Eancom.FileEDI.emailCcKey + supplierName);
                    MainForm.MandatoryDeliveryInformation = ordersIniFile.ReadValue(Eancom.FileEDI.ediSection, OrderKey.MandatoryDeliveryRetailerInformation + retailerNumber);

                    string recipientAddresses = MainForm.EmailTo; // "[email protected];[email protected];[email protected]";
                    recipientAddresses = recipientAddresses.Replace(KD.StringTools.Const.SemiColon, KD.StringTools.Const.Comma);

                    string ccAdress = MainForm.EmailCc;
                    ccAdress = ccAdress.Replace(KD.StringTools.Const.SemiColon, KD.StringTools.Const.Comma);

                    if (!String.IsNullOrEmpty(recipientAddresses))
                    {
                        this.SendMail(recipientAddresses, ccAdress);
                        return(true);
                    }
                }
            }

            MessageBox.Show("La commande n'a pas été généré.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }