Exemplo n.º 1
0
        public static void SerializeNow(Invoice inv)
        {
            //setup a memory stream object that is needed
            //to hold the obj in memory during the
            //format and transformation process
            MemoryStream myStream = new MemoryStream();

            //setup the binary formatting obj that
            //performs the format process
            BinaryFormatter myFormat = new BinaryFormatter();

            //we call the serailize method, passing the
            //stream so we know where to save and obj it
            //will transform
            myFormat.Serialize(myStream, inv);

            //now that the obj is serialized, covert to
            //Base64 for encoding and easy storage
            string serializedValue = Convert.ToBase64String(myStream.ToArray());

            //call the Insert method of the DA class
            DataAdapter.Insert(serializedValue);

            //close the stream
            myStream.Close();
        }
Exemplo n.º 2
0
 private void btnLoadInvoice_Click(object sender, EventArgs e)
 {
     lstBxInvoices.Items.Clear();
     invoices = DataAdapter.Get();
     foreach (Invoice inv in invoices)
     {
         lstBxInvoices.Items.Add(inv);
     }
 }
Exemplo n.º 3
0
 private void btnStoreInvoice_Click(object sender, EventArgs e)
 {
     DataAdapter.ClearDB();
     foreach (Invoice inv in invoices)
     {
         Serializer.SerializeNow(inv);
     }
     lstBxInvoices.Items.Clear();
     btnStoreInvoice.Enabled    = false;
     btnPrintInvoice.Enabled    = false;
     btnDeleteInvoice.Enabled   = false;
     btnUnselectInvoice.Enabled = false;
     //invoices = new ArrayList();
 }
Exemplo n.º 4
0
 private void FormList_Load(object sender, EventArgs e)
 {
     btnDeleteInvoice.Enabled      = false;
     btnDeletePackage.Enabled      = false;
     btnUnselectInvoice.Enabled    = false;
     btnUnselectPackage.Enabled    = false;
     btnPrintInvoice.Enabled       = false;
     btnPrintShippingLabel.Enabled = false;
     btnStoreInvoice.Enabled       = false;
     btnCreateInvoice.Enabled      = false;
     // Load the invoices from db onload
     invoices = DataAdapter.Get();
     foreach (Invoice inv in invoices)
     {
         lstBxInvoices.Items.Add(inv);
     }
 }