Example #1
0
 // The final step is to save data to the database this method savee all the order bodies in the orsrg list to the database for each in it. This is done one by one.
 public void SaveOrder()
 {
     foreach (var orsg in orsrgList)
     {
         orsrg addOrsrg = new orsrg();
         addOrsrg = orsg;
         orderEnteties.orsrg.Add(addOrsrg);
         SaveChanges();
     }
 }
Example #2
0
        // This method handles the sublines and their creation.
        public void CreateSubLines(string orderNr, string subRegel, string subArtCode, string subOms45)
        {
            orsrg nieuwe = new orsrg()
            ;

            nieuwe.ordernr         = orderNr;
            nieuwe.afldat          = DateTime.Now;
            nieuwe.regel           = subRegel;
            nieuwe.syscreated      = Convert.ToDateTime(DateTime.Now);
            nieuwe.artcode         = null;
            nieuwe.oms45           = subArtCode;
            nieuwe.oms45_f         = "SubRegel";
            nieuwe.magcode         = "INDU";
            nieuwe.esr_aantal      = 0;
            nieuwe.btw_code        = "21";
            nieuwe.korting         = 0;
            nieuwe.syscreator      = 1;
            nieuwe.CSRekregValue00 = 0;
            nieuwe.sysmodified     = DateTime.Now;
            nieuwe.syscreated      = DateTime.Now;
            nieuwe.sysguid         = Guid.NewGuid();
            nieuwe.instruction     = subOms45;

            nieuwe.ar_soort   = "T";
            nieuwe.afl_week   = "21";
            nieuwe.prijslijst = "";
            nieuwe.res_id     = 1;

            nieuwe.unitcode = "";

            nieuwe.StatisticalFactor = 0;
            nieuwe.Division          = 100;
            nieuwe.sysmodifier       = 1;
            nieuwe.CSrekregFactor    = 1;
            nieuwe.kstplcode         = "001CC001";
            nieuwe.prijs83           = 0;


            nieuwe.prijs_n       = Math.Round(nieuwe.prijs83);
            nieuwe.unitfactor    = 1;
            nieuwe.vvp           = Math.Round(nieuwe.prijs83 / 2);
            nieuwe.koers         = 1;
            nieuwe.bdr_vat_val   = 21;
            nieuwe.bdr_ev_ed_val = Math.Round(nieuwe.prijs83);
            nieuwe.bdr_val       = Math.Round((nieuwe.bdr_ev_ed_val * 1.21) * nieuwe.esr_aantal, 2);

            nieuwe.CSRekregValue00 = nieuwe.esr_aantal;
            nieuwe.CSRekregValue01 = nieuwe.esr_aantal;
            nieuwe.CSRekregValue02 = 1000;
            nieuwe.CSRekregValue03 = 0;
            nieuwe.CSRekregValue04 = 0;
            nieuwe.CSRekregValue05 = 0;
            nieuwe.CSRekregValue06 = 0;
            nieuwe.CSRekregValue07 = 0;
            nieuwe.CSRekregValue08 = 0;
            nieuwe.CSRekregValue09 = 0;
            nieuwe.CSRekregValue10 = 0;

            nieuwe.CSRekregRoundedValue00 = nieuwe.esr_aantal;
            nieuwe.CSRekregRoundedValue01 = nieuwe.esr_aantal;
            nieuwe.CSRekregRoundedValue02 = 1000;
            nieuwe.CSRekregRoundedValue03 = 0;
            nieuwe.CSRekregRoundedValue04 = 0;
            nieuwe.CSRekregRoundedValue05 = 0;
            nieuwe.CSRekregRoundedValue06 = 0;
            nieuwe.CSRekregRoundedValue07 = 0;
            nieuwe.CSRekregRoundedValue08 = 0;
            nieuwe.CSRekregRoundedValue09 = 0;
            nieuwe.CSRekregRoundedValue10 = 0;
            nieuwe.CSRekregLabelOms00     = "aantal";

            nieuwe.CSPickITQtyOrdered        = 0;
            nieuwe.CSPickITQuantityPicked    = 0;
            nieuwe.CSPickITQuantityCrossDock = 0;
            nieuwe.CSPickITTransferLineID    = 0;
            nieuwe.IntrastatEnabled          = true;
            nieuwe.CSPickITCWStatusCWDB      = "G";
            nieuwe.CSPickITCWStatusSalesDB   = "1";

            // uncomment " orderEnteties.orsrg.Add(nieuwe);"  code  bellow and comment the code withing the try domain. in order to recive custum build validation errors
            // they usualy provide moore information about the error then those build my micriosoft
            try
            {
                // in this domain the code saves the data to a list of order body entitities and later those are written to the database in the SaveChanges() method.

                //   orderEnteties.orsrg.Add(nieuwe);
                orsrgList.Add(nieuwe);
            }
            catch (DbEntityValidationException e)
            {
                // custom build validation errors , this domain is only entered when  orderEnteties.orsrg.Add(nieuwe); is uncommented and orsrgList.Add(nieuwe); is commetned
                // in the try domain.

                foreach (var eve in e.EntityValidationErrors)
                {
                    MessageBox.Show("Entity of type \"" + eve.Entry.Entity.GetType().Name + "\" in state \"" + eve.Entry.State + "\" has the following validation errors:");
                    foreach (var ve in eve.ValidationErrors)
                    {
                        MessageBox.Show("- Property: \"" + ve.PropertyName + "\", Value: \"" + eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName) + "\", Error: \"" + ve.ErrorMessage + "\"");
                    }
                }
            }
        }
Example #3
0
        // this method handles the creation of the plates.
        public void CreateOrderBodyPlaat(string orderNr, string regel, DateTime afldat, string artCode, string oms45, string oms45_f, string magCode, float quantity,
                                         float esr_aantal, string btw_code, float korting, int syscreator, float CSRekRegelVal, float CSRekRegelVal2, float CsRekRegVal3, DateTime sysMod, DateTime sysCreated)
        {
            Items      artikel    = new Items();
            ItemPrices itemPrices = new ItemPrices();

            itemPrices = orderEnteties.ItemPrices.FirstOrDefault(x => x.ItemCode == artCode);
            artikel    = orderEnteties.Items.FirstOrDefault(x => x.ItemCode == artCode);

            orsrg nieuwe = new orsrg();

            nieuwe.ordernr    = orderNr;
            nieuwe.regel      = regel;
            nieuwe.afldat     = Convert.ToDateTime(afldat);
            nieuwe.syscreated = Convert.ToDateTime(afldat);
            nieuwe.artcode    = artCode;
            nieuwe.oms45      = oms45;
            nieuwe.oms45_f    = oms45_f;
            nieuwe.magcode    = magCode;

            nieuwe.btw_code            = btw_code;
            nieuwe.korting             = Math.Round(korting, 2);
            nieuwe.syscreator          = syscreator;
            nieuwe.CSRekregValue00     = Math.Round(CSRekRegelVal);
            nieuwe.CSRekregValue01     = Math.Round(CSRekRegelVal2 * 1000, 3, MidpointRounding.ToEven);
            nieuwe.CSRekregValue02     = Math.Round(CsRekRegVal3 * 1000, 3, MidpointRounding.ToEven);
            nieuwe.CSRekregFormulaName = "OPPERVLAK";
            nieuwe.sysmodified         = sysMod;
            nieuwe.syscreated          = sysCreated;
            nieuwe.sysguid             = Guid.NewGuid();

            nieuwe.ar_soort   = "I";
            nieuwe.afl_week   = "21";
            nieuwe.prijslijst = "SALESPRICE";
            nieuwe.res_id     = 1;

            if (artikel != null)
            {
                nieuwe.unitcode = artikel.PackageDescription;
            }

            nieuwe.StatisticalFactor = 0;
            nieuwe.Division          = 100;
            nieuwe.sysmodifier       = syscreator;
            nieuwe.CSrekregFactor    = 1;
            nieuwe.kstplcode         = "001CC001";

            if (artikel != null)
            {
                nieuwe.prijs83 = Math.Round((double)artikel.SalesPackagePrice, 2);
            }

            nieuwe.prijs_n       = Math.Round(nieuwe.prijs83, 2);
            nieuwe.unitfactor    = 1;
            nieuwe.vvp           = Math.Round(nieuwe.prijs83 / 2);
            nieuwe.koers         = 1;
            nieuwe.bdr_vat_val   = 21;
            nieuwe.bdr_ev_ed_val = nieuwe.prijs83;
            nieuwe.bdr_val       = Math.Round((nieuwe.bdr_ev_ed_val * 1.21) * esr_aantal, 2);

            nieuwe.CSRekregValue03 = 0;
            nieuwe.CSRekregValue04 = 0;
            nieuwe.CSRekregValue05 = 0;
            nieuwe.CSRekregValue06 = 0;
            nieuwe.CSRekregValue07 = 0;
            nieuwe.CSRekregValue08 = 0;
            nieuwe.CSRekregValue09 = 0;
            nieuwe.CSRekregValue10 = 0;
            nieuwe.esr_aantal      = Math.Round((double)(nieuwe.CSRekregValue00 * nieuwe.CSRekregValue01 * nieuwe.CSRekregValue02), 3);

            nieuwe.CSRekregRoundedValue00 = quantity;
            nieuwe.CSRekregRoundedValue01 = Math.Round((CSRekRegelVal2 * 1000) / (double)nieuwe.CSRekregRoundedValue00);
            nieuwe.CSRekregRoundedValue02 = Math.Round((CsRekRegVal3 * 1000) / (double)nieuwe.CSRekregRoundedValue00);
            nieuwe.CSRekregRoundedValue03 = 0;
            nieuwe.CSRekregRoundedValue04 = 0;
            nieuwe.CSRekregRoundedValue05 = 0;
            nieuwe.CSRekregRoundedValue06 = 0;
            nieuwe.CSRekregRoundedValue07 = 0;
            nieuwe.CSRekregRoundedValue08 = 0;
            nieuwe.CSRekregRoundedValue09 = 0;
            nieuwe.CSRekregRoundedValue10 = 0;
            nieuwe.CSRekregLabelOms00     = "aantal";
            nieuwe.CSRekregLabelOms01     = "lengte";
            nieuwe.CSRekregLabelOms02     = "breedte";

            nieuwe.CSPickITQtyOrdered        = 0;
            nieuwe.CSPickITQuantityPicked    = 0;
            nieuwe.CSPickITQuantityCrossDock = 0;
            nieuwe.CSPickITTransferLineID    = 0;
            nieuwe.IntrastatEnabled          = true;
            nieuwe.CSPickITCWStatusCWDB      = "G";
            nieuwe.CSPickITCWStatusSalesDB   = "1";

            // uncomment " orderEnteties.orsrg.Add(nieuwe);"  code  bellow and comment the code withing the try domain. in order to recive custum build validation errors
            // they usualy provide moore information about the error then those build my micriosoft
            try
            {
                // in this domain the code saves the data to a list of order body entitities and later those are written to the database in the SaveChanges() method.

                //   orderEnteties.orsrg.Add(nieuwe);
                orsrgList.Add(nieuwe);
            }
            catch (DbEntityValidationException e)
            {
                // custom build validation errors , this domain is only entered when  orderEnteties.orsrg.Add(nieuwe); is uncommented and orsrgList.Add(nieuwe); is commetned
                // in the try domain.

                foreach (var eve in e.EntityValidationErrors)
                {
                    MessageBox.Show("Entity of type \"" + eve.Entry.Entity.GetType().Name + "\" in state \"" + eve.Entry.State + "\" has the following validation errors:");
                    foreach (var ve in eve.ValidationErrors)
                    {
                        MessageBox.Show("- Property: \"" + ve.PropertyName + "\", Value: \"" + eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName) + "\", Error: \"" + ve.ErrorMessage + "\"");
                    }
                }
            }
        }