Example #1
0
 public void ManipulateDB(Box b, ManipulationType type)
 {
     SqlCommand cmd = new SqlCommand();
     cmd.Connection = DatabaseConnection.GetInstance();
     switch (type)
     {
         case ManipulationType.Insert:
             // create INSERT SQL string
             cmd.CommandText = "INSERT INTO ScanExpert_DEV_TEST (DateIn, productCode recipient_name recipient_loc recipient_address recipient_tel recipient_cc date_out delivered_to sender deliverer ware document customs comment creator) VALUES('" + b.DateIn + "', 'b.productCode', 'b.recipient_name', 'b.recipient_loc', 'b.recipient_address', 'b.recipient_tel', 'b.recipient_cc', 'b.date_out', 'b.delivered_to', 'b.sender', 'b.deliverer', 'b.ware', 'b.document', 'b.customs', 'b.comment', 'b.creator')";
             break;
         case ManipulationType.Update:
             // create Update SQL string
             cmd.CommandText = "UPDATE ScanExpert_DEV_TEST SET DateIn=@DateIn productCode=@productCode recipient_name=@recipient_name recipient_loc=@recipient_loc recipient_address=@recipient_address recipient_tel=@recipient_tel recipient_cc=@recipient_cc date_out=@date_out delivered_to=@delivered_to sender=@sender deliverer=@deliverer ware=@ware document=@document customs=@customs comment=@comment creator=@creator WHERE Id=@Id";
             break;
         case ManipulationType.Delete:
             // create DELETE SQL string
             cmd.CommandText = "DELETE FROM ScanExpert_DEV_TEST WHERE Id=@Id";
             cmd.Parameters.AddWithValue("@Id", b.ID);
             break;
         default:
             break;
     }
     // exutenonquery= sqlcommand ausführen aber keine Datenbankabfrage
     cmd.ExecuteNonQuery();
     // die liste der boxen wird geupdated nachdem id hinzugefügt wurde
     this.UpdateBoxes();
 }
Example #2
0
 public void UpdateBoxes()
 {
     DataTable dt = DatabaseActions.GetSELECTQuery("SELECT * FROM ScanExpert_DEV_TEST");
     foreach (DataRow row in dt.Rows)
     {
         Box b = new Box(row);
         this.Boxes.Add(b);
     }
 }