public int AgregarYEditarMedicamento(MedicamentoCLS oMedicamentoCLS) { int rpta = 0; try { MedicamentosClient oMedicamentoClient = new MedicamentosClient(); oMedicamentoClient.ClientCredentials.UserName.UserName = "******"; oMedicamentoClient.ClientCredentials.UserName.Password = "******"; rpta = oMedicamentoClient.RegistraryActualizarMedicamento(oMedicamentoCLS); } catch (Exception) { rpta = 0; } return(rpta); }
private void cmdAceptar_Click(object sender, EventArgs e) { var exito = true; if (txtnombre.Text == "") { errorDatos.SetError(txtnombre, "Ingrese nombre"); exito = false; } else { errorDatos.SetError(txtnombre, ""); } if (txtStock.Text == "") { errorDatos.SetError(txtStock, "Ingrese Stock"); exito = false; } else { errorDatos.SetError(txtnombre, ""); } if (txtPrecio.Text == "") { errorDatos.SetError(txtPrecio, "Ingrese precio"); exito = false; } else { errorDatos.SetError(txtPrecio, ""); } if (txtPresentacion.Text == "") { errorDatos.SetError(txtPresentacion, "Ingrese Presentacion"); exito = false; } else { errorDatos.SetError(txtPresentacion, ""); } if ((int)cboformaFarmaceutica.SelectedValue == 0) { errorDatos.SetError(cboformaFarmaceutica, "Ingrese Forma Farmaceutica"); exito = false; } else { errorDatos.SetError(cboformaFarmaceutica, ""); } if (exito == false) { this.DialogResult = DialogResult.None; return; } else { MedicamentoCLS oMedicamentoCLS = new MedicamentoCLS(); oMedicamentoCLS.IidMedicamento = int.Parse(txtIdMedicamento.Text); oMedicamentoCLS.Nombre = txtnombre.Text; oMedicamentoCLS.Precio = decimal.Parse(txtPrecio.Text); oMedicamentoCLS.Presentacion = txtPresentacion.Text; oMedicamentoCLS.IidFormaFarmaceutica = (int)cboformaFarmaceutica.SelectedValue; oMedicamentoCLS.Stock = int.Parse(txtStock.Text); oMedicamentoCLS.BHabilitado = 1; MedicamentosClient oMedicamentosClient = new MedicamentosClient(); oMedicamentosClient.ClientCredentials.UserName.UserName = "******"; oMedicamentosClient.ClientCredentials.UserName.Password = "******"; int rpta = oMedicamentosClient.RegistraryActualizarMedicamento(oMedicamentoCLS); if (rpta == 1) { MessageBox.Show("Guardado"); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Error"); this.DialogResult = DialogResult.None; } } //ingresando o editando //Nuevo //if (txtIdMedicamento.Text=="") //{ //} //else ////Editar //{ //} }