Ejemplo n.º 1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            log.Debug("Save button clicked");

            SQLiteConnection conn = SQLiteConnectionFactory.GetPrimaryDBConnection();
            ProviderDAO dao = new ProviderDAO();
            Provider provider = new Provider();

            try
            {
                label_message.ForeColor = Color.Blue;
                provider.ProviderName = textBox_providerName.Text;

                if (isUpdate)
                {
                    provider.ProviderId = Convert.ToInt32(label_providerId.Text);
                    log.Debug("Attempting to update provider " + provider.ProviderId + ": " + provider.ProviderName);
                    dao.Update(provider, conn);
                    label_message.Text = "Updated Provider " + provider.ProviderName;
                    log.Debug("Update provider successful");
                }
                else
                {
                    log.Debug("Attempting to save new provider: " + provider.ProviderName);
                    dao.Create(provider, conn);
                    label_message.Text = "Saved new Provider " + provider.ProviderName;
                    log.Debug("Create new provider successful");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                log.Error("Error saving/updating provider", ex);
                label_message.ForeColor = Color.Red;
                label_message.Text = ex.Message;
            }
        }
Ejemplo n.º 2
0
 private Provider InsertTestProvider(SQLiteConnection conn, int i)
 {
     ProviderDAO providerDAO = new ProviderDAO();
     string name = GetRandomName() + i;
     Provider p = new Provider() { ProviderName = name };
     providerDAO.Create(p, conn);
     p.ProviderId = providerDAO.Read("SELECT * FROM providers WHERE provider_id = (SELECT max(provider_id) FROM providers)", conn)[0].ProviderId;
     return p;
 }
Ejemplo n.º 3
0
 private Provider InsertTestProvider(SQLiteConnection conn)
 {
     ProviderDAO providerDAO = new ProviderDAO();
     Provider p = new Provider() { ProviderName = "HuntTestProvider" };
     providerDAO.Create(p, conn);
     p.ProviderId = providerDAO.Read("SELECT * FROM providers WHERE provider_name = 'HuntTestProvider'", conn)[0].ProviderId;
     return p;
 }