Exemplo n.º 1
0
 public void UpdateCard(string path, BEBusinessCard card)
 {
     using (var client = GetClient())
     {
         var response = client.PutAsJsonAsync(path, card).Result;
     }
 }
Exemplo n.º 2
0
 public int CreateCard(string path, BEBusinessCard card)
 {
     using (var client = GetClient())
     {
         var response = client.PostAsJsonAsync(path, card).Result;
         return Convert.ToInt32(response.Content.ReadAsStringAsync().Result);
     }
     return 0;
 }
Exemplo n.º 3
0
 public void DeleteCard(BEBusinessCard card)
 {
     using (var con = new SQLiteConnection("Data Source=" + DB_NAME + ";Version=3;"))
     {
         using (var com = new SQLiteCommand(con))
         {
             string stm = "UPDATE Cards SET IsDeleted = 1 WHERE Id=@Id";
             com.CommandText = stm;
             com.Parameters.AddWithValue("@Id", card.Id);
             con.Open();
             com.ExecuteNonQuery();
         }
     }
 }
Exemplo n.º 4
0
 public List<BEBusinessCard> GetAllBusinessCards()
 {
     List<BEBusinessCard> cards = new List<BEBusinessCard>();
     using (var con = new SQLiteConnection("Data Source=" + DB_NAME + ";Version=3;"))
     {
         using (var com = new SQLiteCommand(con))
         {
             con.Open();
             string stm = "SELECT * FROM Cards WHERE IsDeleted = 0";
             com.CommandText = stm;
             using (SQLiteDataReader reader = com.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     BEBusinessCard card = new BEBusinessCard()
                     {
                         Id = reader.GetInt32(0),
                         Firstname = reader.GetString(1),
                         Lastname = reader.GetString(2),
                         Address = reader.GetString(3),
                         PhoneNumber = reader.GetString(4),
                         Country = reader.GetString(5),
                         City = reader.GetString(6),
                         Company = reader.GetString(7),
                         Title = reader.GetString(8),
                         Homepage = reader.GetString(9),
                         Fax = reader.GetString(10),
                         Postal = reader.GetString(11),
                         Email = reader.GetString(12),
                         Other = reader.GetString(13),
                         EncodedImage = reader.GetString(14),
                         CreatedDate = reader.GetString(15),
                         CreatedUserId = reader.GetInt32(16),
                         IsDeleted = false
                     };
                     cards.Add(card);
                     // Console.WriteLine(reader["Key"] + " : " + reader["Value"]);     // Display the value of the key and value column for every row
                 }
             }
         }
     }
     return cards;
 }
Exemplo n.º 5
0
 public void UpdateCard(BEBusinessCard card)
 {
     using (var con = new SQLiteConnection("Data Source=" + DB_NAME + ";Version=3;"))
     {
         using (var com = new SQLiteCommand(con))
         {
             string stm = "UPDATE Cards SET Firstname = @Firstname, Lastname = @Lastname, Address = @Address, PhoneNumber = @PhoneNumber, Country = @Country, City = @City, Company = @Company, Title = @Title, Homepage = @Homepage, Fax = @Fax, Postal = @Postal, Email = @Email, Other = @Other WHERE Id=@Id";
             com.CommandText = stm;
             com.Parameters.AddWithValue("@Firstname", card.Firstname);
             com.Parameters.AddWithValue("@Lastname", card.Lastname);
             com.Parameters.AddWithValue("@Address", card.Address);
             com.Parameters.AddWithValue("@PhoneNumber", card.PhoneNumber);
             com.Parameters.AddWithValue("@Country", card.Country);
             com.Parameters.AddWithValue("@City", card.City);
             com.Parameters.AddWithValue("@Company", card.Company);
             com.Parameters.AddWithValue("@Title", card.Title);
             com.Parameters.AddWithValue("@Homepage", card.Homepage);
             com.Parameters.AddWithValue("@Fax", card.Fax);
             com.Parameters.AddWithValue("@Postal", card.Postal);
             com.Parameters.AddWithValue("@Email", card.Email);
             com.Parameters.AddWithValue("@Other", card.Other);
             com.Parameters.AddWithValue("@Id", card.Id);
             con.Open();
             com.ExecuteNonQuery();
         }
     }
 }
Exemplo n.º 6
0
 public void InsertCard(BEBusinessCard card)
 {
     using (var con = new SQLiteConnection("Data Source=" + DB_NAME + ";Version=3;"))
     {
         using (var com = new SQLiteCommand(con))
         {
             con.Open();
             string insert = "INSERT INTO Cards (Firstname, Lastname, Address," +
                             " PhoneNumber, Country, City, Company, Title, Homepage, " +
                             "Fax, Postal, Email, Other, EncodedImage, CreatedDate, CreatedUserId, IsDeleted) " +
                             "Values ('" + card.Firstname + "', '" + card.Lastname +
                             "', '" + card.Address + "', '" + card.PhoneNumber +
                             "', '" + card.Country + "', '" + card.City +
                             "', '" + card.Company + "', '" + card.Title +
                             "', '" + card.Homepage + "', '" + card.Fax +
                             "', '" + card.Postal + "', '" + card.Email +
                             "', '" + card.Other + "', '" + card.EncodedImage +
                             "', '" + String.Format("{0:dd-MM-yyyy}", DateTime.Now) + "', '" + card.CreatedUserId + "', 0)";
             com.CommandText = insert;
             com.ExecuteNonQuery();
         }
     }
 }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (pbScannedCard.Image == null)
            {
                MessageBox.Show("Please scan or select a card first");
            }
            else
            {
                var scannedImage = new Bitmap(pbScannedCard.Image);

                Gateway gateway = new Gateway();

                if (!_updating)
                {
                    var card = new BEBusinessCard
                    {
                        Address = txtAddress.Text,
                        City = txtCity.Text,
                        Email = txtEmail.Text,
                        Homepage = txtHomepage.Text,
                        Company = txtCompany.Text,
                        Country = txtCountry.Text,
                        Fax = txtFax.Text,
                        Firstname = txtFirstname.Text,
                        Lastname = txtLastname.Text,
                        PhoneNumber = txtPhone.Text,
                        Postal = txtPostal.Text,
                        Title = txtTitle.Text,
                        Other = txtOther.Text,
                        EncodedImage = _bllScanner.ToBase64String(scannedImage, ImageFormat.Bmp),
                        CreatedDate = String.Format("{0:dd-MM-yyyy}", DateTime.Now),
                        CreatedUserId = _loggedUser.Id
                    };

                    string date = card.CreatedDate;

                    foreach (var node in Collect(tViewClients.Nodes))
                    {
                        if (node != null && node.Tag is BEUser)
                        {
                            BEUser currentUser = (BEUser)node.Tag;
                            if (currentUser.Id == _loggedUser.Id)
                            {
                                CreateNodeForToday(node.Nodes);
                                if (node.FirstNode.Tag.Equals(date))
                                {
                                    int cardId = gateway.CreateCard("Card/PostAndGetCardId", card);
                                    card.Id = cardId;
                                    CreateCardNode(date, card, node.FirstNode);

                                    //_bllScanner.InsertCard(card);
                                    _updating = true;
                                    MessageBox.Show("Contact added");
                                }
                            }
                        }
                    }
                }
                else
                {
                    var card = new BEBusinessCard
                    {
                        Address = txtAddress.Text,
                        City = txtCity.Text,
                        Email = txtEmail.Text,
                        Homepage = txtHomepage.Text,
                        Company = txtCompany.Text,
                        Country = txtCountry.Text,
                        Fax = txtFax.Text,
                        Firstname = txtFirstname.Text,
                        Lastname = txtLastname.Text,
                        PhoneNumber = txtPhone.Text,
                        Postal = txtPostal.Text,
                        Title = txtTitle.Text,
                        Other = txtOther.Text,
                        CreatedDate = String.Format("{0:dd-MM-yyyy}", DateTime.Now),
                        CreatedUserId = _loggedUser.Id
                    };

                    var selectedCard = (BEBusinessCard)tViewClients.SelectedNode.Tag;

                    var cardId = selectedCard.Id;
                    tViewClients.SelectedNode.Text = txtFirstname.Text + " " + txtLastname.Text;
                    card.Id = cardId;
                    card.EncodedImage = selectedCard.EncodedImage;
                    gateway.UpdateCard("Card",card);
                    //_bllScanner.UpdateCard(card);
                    tViewClients.SelectedNode.Tag = card;
                    MessageBox.Show("Contact updated");
                }
            }
        }
Exemplo n.º 8
0
 private void ShowResults(BEBusinessCard card)
 {
     txtFirstname.Text = card.Firstname;
     txtLastname.Text = card.Lastname;
     txtAddress.Text = card.Address;
     txtCity.Text = card.City;
     txtPostal.Text = card.Postal;
     txtCountry.Text = card.Country;
     txtTitle.Text = card.Title;
     txtCompany.Text = card.Company;
     txtPhone.Text = card.PhoneNumber;
     txtFax.Text = card.Fax;
     txtEmail.Text = card.Email;
     txtHomepage.Text = card.Homepage;
     txtOther.Text = card.Other;
     _updating = false;
     btnSave.Enabled = true;
     btnSave.Text = "Save contact";
 }
Exemplo n.º 9
0
        private void CreateCardNode(string date, BEBusinessCard card, TreeNode localDateNode)
        {
            if (localDateNode == null)
            {
                var userNode = new TreeNode { Text = _loggedUser.Username, Tag = _loggedUser };

                var dateNode = new TreeNode { Text = date, Tag = new object[] { date } };

                var clientNode = new TreeNode { Text = card.Firstname + " " + card.Lastname, Tag = card };

                dateNode.Nodes.Add(clientNode);
                userNode.Nodes.Add(dateNode);
                tViewClients.Nodes.Add(userNode);
                tViewClients.SelectedNode = clientNode;
            }
            else
            {
                var clientNode = new TreeNode { Text = card.Firstname + " " + card.Lastname, Tag = card };
                localDateNode.Nodes.Add(clientNode);
                tViewClients.SelectedNode = clientNode;
            }
        }
Exemplo n.º 10
0
 public void DeleteCard(BEBusinessCard contact)
 {
     _sql.DeleteCard(contact);
 }
Exemplo n.º 11
0
 public void UpdateCard(BEBusinessCard card)
 {
     _sql.UpdateCard(card);
 }
Exemplo n.º 12
0
 public void SetupVcfContact(StringBuilder vcf, BEBusinessCard card)
 {
     vcf.Append("BEGIN:VCARD" + Environment.NewLine);
     vcf.Append("FN:" + card.Firstname + " " + card.Lastname + Environment.NewLine);
     vcf.Append("N:" + card.Lastname + ";" + card.Firstname + Environment.NewLine);
     vcf.Append("TITLE:" + card.Title + Environment.NewLine);
     vcf.Append("ORG:" + card.Company + Environment.NewLine);
     vcf.Append("EMAIL:" + card.Email + Environment.NewLine);
     vcf.Append("TEL;fax:" + card.Fax + Environment.NewLine);
     vcf.Append("ADR;TYPE=intl,work,postal,parcel:;;" + card.Address + ";" + card.City + ";;" + card.Postal + ";" +
                card.Country + Environment.NewLine);
     vcf.Append("TEL;WORK;VOICE:" + card.PhoneNumber + Environment.NewLine);
     if (!String.IsNullOrEmpty(card.Homepage))
         vcf.Append(@"URL;type=pref:http\://" + card.Homepage + Environment.NewLine);
     vcf.Append("VERSION:2.1" + Environment.NewLine);
     vcf.Append("END:VCARD" + Environment.NewLine);
 }
Exemplo n.º 13
0
 public void InsertCard(BEBusinessCard card)
 {
     _sql.InsertCard(card);
 }
Exemplo n.º 14
0
        public BEBusinessCard GetScannedCard(BEUser loggedUser)
        {
            var card = new BEBusinessCard
            {
                Firstname = Sdk.GetText(SDKWrapper.Fields.FirstName) + " " + Sdk.GetText(SDKWrapper.Fields.MiddleName),

            Lastname = Sdk.GetText(SDKWrapper.Fields.LastName),
            Address = Sdk.GetText(SDKWrapper.Fields.Address1_Line1),
            City =  Sdk.GetText(SDKWrapper.Fields.Address1_City),
            Postal = Sdk.GetText(SDKWrapper.Fields.Address1_PostalCode),
            Country =  Sdk.GetText(SDKWrapper.Fields.Address1_Country),
            Title = Sdk.GetText(SDKWrapper.Fields.Title),
            Company = Sdk.GetText(SDKWrapper.Fields.Company),
            PhoneNumber = Sdk.GetText(SDKWrapper.Fields.Phone),
            Fax = Sdk.GetText(SDKWrapper.Fields.Fax),
            Email = Sdk.GetText(SDKWrapper.Fields.Email),
            Homepage = Sdk.GetText(SDKWrapper.Fields.WebSite),
            Other = Sdk.GetText(SDKWrapper.Fields.Other),
            EncodedImage = "d",
            CreatedDate = DateTime.Now.ToString(),
            CreatedUserId = loggedUser.Id

            };
            return card;
        }