public void PredefinedInsert()
        {
            var fc = new FormatClass
            {
              Height = 200,
              Width = 200,
            };

              ImpressioDbContext.Instance.FormatClasses.Add(fc);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(fc.FormatClassId);

              var pm = new PrintMachine
            {
              EasyColor = 333,
              Name = "mach",
              FormatClass = fc,
            };
              ImpressioDbContext.Instance.PrintMachines.Add(pm);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(pm.PrintMachineId);
              Assert.IsNotNull(pm.FormatClass);

              var mspeed = new MachineSpeedCost
            {
              CostPerK = 100,
              PrintMachine = pm,
              Speed = 5000,
            };
              ImpressioDbContext.Instance.MachineSpeedCosts.Add(mspeed);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(mspeed.MachineSpeedCostId);
              Assert.IsNotNull(mspeed.PrintMachine);
              Assert.IsNotNull(mspeed.FkPrintMachine);

              ImpressioDbContext.Instance.GetValidationErrors();

              var p = new Paper
            {
              Name = "Paper",
              Price1 = 230,
              Weight = 90,
              SizeW = 500,
              SizeH = 200,
            };
              ImpressioDbContext.Instance.Papers.Add(p);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(p.PaperId);
        }
示例#2
0
        private void GeneratePreview()
        {
            if (ValidateColumnInput())
              {
            paperBindingSource.Clear();
            var command = new OleDbCommand(string.Format("SELECT * FROM [{0}]", excelSheet.Text), Connection);
            var reader = command.ExecuteReader();
            var counter = 0;

            while (reader != null && reader.Read())
            {
              if (counter > 210) { break; }
              var paper = new Paper
                        {
                          ItemNumber = numberRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[numberRow.Properties.Value.ToString()]),
                          Name = reader[nameRow.Properties.Value.ToString()].ToString(),
                          Direction = directionRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[directionRow.Properties.Value.ToString()]),
                          Amount1 = quantity1.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity1.Properties.Value.ToString()]),
                          Amount2 = quantity2.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity2.Properties.Value.ToString()]),
                          Amount3 = quantity3.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity3.Properties.Value.ToString()]),
                          Price1 = Convert.ToInt32(reader[price1.Properties.Value.ToString()]),
                          Price2 = price2.Properties.Value == null ? 0 : Convert.ToInt32(reader[price2.Properties.Value.ToString()]),
                          Price3 = price3.Properties.Value == null ? 0 : Convert.ToInt32(reader[price3.Properties.Value.ToString()]),
                          Price4 = price4.Properties.Value == null ? 0 : Convert.ToInt32(reader[price4.Properties.Value.ToString()]),
                          SizeH = widthRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[widthRow.Properties.Value.ToString()]),
                          SizeW = lenghtRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[lenghtRow.Properties.Value.ToString()]),
                          Vendor = vendorRow.Properties.Value == null ? null : reader[vendorRow.Properties.Value.ToString()].ToString(),
                          Weight = weightRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[weightRow.Properties.Value.ToString()])
                        };
              paperBindingSource.Add(paper);
              counter++;
            }
              }
        }
示例#3
0
        private void ImportExcel()
        {
            if (ValidateColumnInput())
              {
            var command = new OleDbCommand(string.Format("SELECT * FROM [{0}]", excelSheet.Text), Connection);
            var reader = command.ExecuteReader();
            var errorMsg = string.Empty;

            while (reader != null && reader.Read())
            {
              try
              {
            var paper = new Paper
            {
              ItemNumber = numberRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[numberRow.Properties.Value.ToString()]),
              Name = reader[nameRow.Properties.Value.ToString()].ToString(),
              Direction = directionRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[directionRow.Properties.Value.ToString()]),
              Amount1 = quantity1.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity1.Properties.Value.ToString()]),
              Amount2 = quantity2.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity2.Properties.Value.ToString()]),
              Amount3 = quantity3.Properties.Value == null ? 0 : Convert.ToInt32(reader[quantity3.Properties.Value.ToString()]),
              Price1 = Convert.ToInt32(reader[price1.Properties.Value.ToString()]),
              Price2 = price2.Properties.Value == null ? 0 : Convert.ToInt32(reader[price2.Properties.Value.ToString()]),
              Price3 = price3.Properties.Value == null ? 0 : Convert.ToInt32(reader[price3.Properties.Value.ToString()]),
              Price4 = price4.Properties.Value == null ? 0 : Convert.ToInt32(reader[price4.Properties.Value.ToString()]),
              SizeH = widthRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[widthRow.Properties.Value.ToString()]),
              SizeW = lenghtRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[lenghtRow.Properties.Value.ToString()]),
              Vendor = vendorRow.Properties.Value == null ? null : reader[vendorRow.Properties.Value.ToString()].ToString(),
              Weight = weightRow.Properties.Value == null ? 0 : Convert.ToInt32(reader[weightRow.Properties.Value.ToString()])
            };

            var exists = from p in ImpressioDbContext.Instance.Papers where p.ItemNumber == paper.ItemNumber select p;

            if (exists.Any())
            {
              var existingPaper = exists.First();
              paper.PaperId = existingPaper.PaperId;
            }
            else
            {
              ImpressioDbContext.Instance.Papers.Add(paper);
              ImpressioDbContext.Instance.SaveChanges();
            }
              }
              catch (Exception exception)
              {
            errorMsg += exception + Environment.NewLine;
              }
            }
            if (!string.IsNullOrEmpty(errorMsg))
            {
              XtraMessageBox.Show(errorMsg, "Aufgetretene Fehler beim Import");
            }
            Close();
              }
        }