private void btnNuevoProveedor_Click(object sender, EventArgs e)
 {
     if (this.txtRutProveedor.Text.Trim().Length == 0)
     {
         toolTip1.Show("Rut no puede quedar en blanco.", txtRutProveedor);
         Libreria.Utilidades.LimpiarForm(this);
     }
     else if (this.txtNombreIngreso.Text.Trim().Length == 0)
     {
         toolTip1.Show("Rut no puede quedar en blanco.", txtNombreIngreso);
         Libreria.Utilidades.LimpiarForm(this);
     }
     else
     {
         MongoHandler MH = new MongoHandler(
         "mongodb://" + ConfigurationManager.AppSettings["ServidorMongo"],
         ConfigurationManager.AppSettings["BDMongo"]);
         if (MH.mensaje.Length != 0)
         {
             MessageBox.Show(MH.mensaje.ToString());
         }
         else
         {
             Proveedor P = new Proveedor
             {
                 Rut = this.txtRutProveedor.Text,
                 Nombre = this.txtNombreIngreso.Text,
                 NombreFantasia = this.txtNombreFantaIngreso.Text,
                 Mail = this.txtMailIngreso.Text,
                 Telefonos = this.txtFonosIngreso.Text.Split(',').ToList(),
                 Direccion = this.txtDireccionIngreso.Text
             };
             if (MH.GuardarProveedor(P))
             {
                 MessageBox.Show(MH.mensaje.ToString(), "Estado Ingreso",
                     MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.txtRutProveedor.Focus();
                 Libreria.Utilidades.LimpiarForm(this);
             }
             else
             {
                 MessageBox.Show(MH.mensaje.ToString(), "Estado Ingreso",
                     MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 public Boolean GuardarProveedor(Proveedor P)
 {
     try
     {
         coleccion = bd.GetCollection<Proveedor>("Proveedor");
         coleccion.EnsureIndex(new IndexKeysBuilder().
             Ascending("Rut"), IndexOptions.SetUnique(true));
         this.mensaje.Append(coleccion.Insert(P).Response.ToString());
         return true;
     }
     catch (MongoSafeModeException MSME)
     {
         this.mensaje.Append("Rut Duplicado: " + P.Rut);
     }
     catch (Exception E)
     {
         this.mensaje.Append(E.Message);
     }
     return false;
 }