protected void btnAgregar_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { try { if (CaptchaControl1.IsValid) { Proveedor prov = new Proveedor(); if (!String.IsNullOrEmpty(txtIdProveedor.Value)) { prov.Id = Convert.ToInt32(txtIdProveedor.Value); } prov.Email = txtEmail.Text.Trim(); prov.CUIT = txtCuit.Text.Trim(); prov.IIBB = txtIIBB.Text.Trim(); prov.RazonSocial = txtRazonsocial.Text.Trim(); prov.Alta = Convert.ToDateTime(txtFechaAlta.Text.Trim()); prov.Gateway = cboGateway.SelectedValue; prov.IdGateway = txtIdGateway.Text.Trim(); prov.NombreResp = txtNombreResponsable.Text.Trim(); prov.ApellidoResp = txtApellidoResponsable.Text.Trim(); prov.DNIResp = txtDNIResponsable.Text.Trim(); prov.CargoResp = txtCargoResponsable.Text.Trim(); prov.UrlImagen = (txtImagen.Text.Trim() == "") ? "Images/Logos/travelpay.png" : txtImagen.Text.Trim(); prov.Telefonos = txtTelefonos.Text.Trim(); prov.ClaveEncNPS = txtClaveEncNPS.Text.Trim(); prov.DevNPS = Convert.ToBoolean(cboDevNPS.SelectedValue); prov.DiasVencimiento = Convert.ToInt32(txtDiasVencimiento.Text.Trim()); #region Tarjetas if (chkAmerican.Checked) { prov.SetAmericanExpress = prov.GetCodeCard(chkAmerican.Attributes["description"]); //chkAmerican.Value; } if (chkCabal.Checked) { prov.SetCabal = prov.GetCodeCard(chkCabal.Attributes["description"]); //chkCabal.Value; } if (chkDiners.Checked) { prov.SetDiners = prov.GetCodeCard(chkDiners.Attributes["description"]); //chkDiners.Value; } if (chkMastercard.Checked) { prov.SetMastercard = prov.GetCodeCard(chkMastercard.Attributes["description"]); //chkMastercard.Value; } if (chkNaranja.Checked) { prov.SetNaranja = prov.GetCodeCard(chkNaranja.Attributes["description"]); //chkNaranja.Value; } if (chkNevada.Checked) { prov.SetNevada = prov.GetCodeCard(chkNevada.Attributes["description"]); //chkNevada.Value; } if (chkVisa.Checked) { prov.SetVisa = prov.GetCodeCard(chkVisa.Attributes["description"]); //chkVisa.Value; } #endregion Tarjetas int result; if (prov.Id == 0) { result = FacadeDao.CrearProveedor(prov); } else { result = FacadeDao.ActualizarProveedor(prov); } if (result == 1) { Response.Redirect("MisProveedores.aspx"); } else { throw (new Exception("Ocurrió un error en el alta / actualización de la empresa")); } } else { throw (new Exception(CaptchaControl1.ErrorMessage)); } } catch (Exception ex) { //Logger.EscribirEventLog(ex); string script = "alert('" + ex.Message + "');"; ClientScript.RegisterStartupScript(this.GetType(), DateTime.Now.ToFileTime().ToString(), script); } } }