public async Task <IHttpActionResult> Eliminar(int Id, int IdCliente, string UsrModificador) { try { ProductoLaboratorioBL oProductoLaboratorioBL = new ProductoLaboratorioBL(IdCliente); ProductoLaboratorioBE obe = new ProductoLaboratorioBE(); obe.Id = Id; obe.UsrModificador = UsrModificador; bool rpta = false; rpta = oProductoLaboratorioBL.Eliminar(obe); if (rpta) { return(Ok(Models.Util.GetBodyResponse(200, "OK"))); } else { return(Ok(Models.Util.GetBodyResponse(300, "Ocurrió un error al actualizar."))); } } catch (Exception ex) { //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex); return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }
public bool Actualizar(SqlConnection cnBD, SqlTransaction trx, ProductoLaboratorioBE obe) { bool rpta = false; string msjError = ""; using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Ajustes_ProductoLaboratorio_Actualizar]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Transaction = trx; cmd.Parameters.Add("@IdAlmacen", SqlDbType.Int).Value = obe.Id; cmd.Parameters.Add("@DesAlmacen", SqlDbType.VarChar, 150).Value = obe.Nombre; cmd.Parameters.Add("@Abreviatura", SqlDbType.VarChar, 150).Value = obe.Abreviatura; cmd.Parameters.Add("@Estado", SqlDbType.Bit).Value = obe.Estado; cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value = obe.IdCliente; cmd.Parameters.Add("@DesCliente", SqlDbType.VarChar, 150).Value = obe.DesCliente; cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = obe.UsrCreador; int counterMarker = 0; object objRes = cmd.ExecuteScalar(); int.TryParse(objRes.ToString(), out counterMarker); if (counterMarker > 0) { rpta = true; } else { msjError = objRes.ToString(); rpta = false; } } return(rpta); }
public bool Eliminar(SqlConnection cnBD, SqlTransaction trx, ProductoLaboratorioBE obe) { bool rpta = false; string msjError = ""; using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Ajustes_ProductoLaboratorio_Eliminar]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Transaction = trx; cmd.Parameters.Add("@Id", SqlDbType.Int).Value = obe.Id; cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = obe.UsrModificador; int counterMarker = 0; object objRes = cmd.ExecuteScalar(); int.TryParse(objRes.ToString(), out counterMarker); if (counterMarker > 0) { rpta = true; } else { msjError = objRes.ToString(); rpta = false; } } return(rpta); }
public List <ProductoLaboratorioBE> ListarDatosIniciales(SqlConnection cnBD, string usuario) { List <ProductoLaboratorioBE> lobe = new List <ProductoLaboratorioBE>(); ProductoLaboratorioBE obe = new ProductoLaboratorioBE(); using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Ajustes_ProductoLaboratorio_Lista]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value = usuario; using (SqlDataReader drd = cmd.ExecuteReader()) { if (drd.HasRows) { int pos_Id = drd.GetOrdinal("Id"); int pos_Nombre = drd.GetOrdinal("Nombre"); int pos_Abreviatura = drd.GetOrdinal("Abreviatura"); int pos_IdCliente = drd.GetOrdinal("IdCliente"); int pos_DesCliente = drd.GetOrdinal("DesCliente"); int pos_Estado = drd.GetOrdinal("Estado"); int pos_UsrCreador = drd.GetOrdinal("UsrCreador"); int pos_FchCreacion = drd.GetOrdinal("FchCreacion"); int pos_UsrModificador = drd.GetOrdinal("UsrModificador"); int pos_FchModificacion = drd.GetOrdinal("FchModificacion"); lobe = new List <ProductoLaboratorioBE>(); while (drd.Read()) { obe = new ProductoLaboratorioBE(); obe.Id = drd.GetInt32(pos_Id); obe.Nombre = drd.GetString(pos_Nombre); obe.Abreviatura = drd.GetString(pos_Abreviatura); obe.IdCliente = drd.GetInt32(pos_IdCliente); obe.DesCliente = drd.GetString(pos_DesCliente); obe.Estado = drd.GetBoolean(pos_Estado); obe.UsrCreador = drd.GetString(pos_UsrCreador); obe.FchCreacion = drd.GetString(pos_FchCreacion); obe.UsrModificador = drd.GetString(pos_UsrModificador); obe.FchModificacion = drd.GetString(pos_FchModificacion); lobe.Add(obe); } } } } return(lobe); }
public bool Eliminar(ProductoLaboratorioBE obe) { bool rpta = false; SqlTransaction sqltrans; using (SqlConnection con = new SqlConnection(strCnxRule)) { con.Open(); sqltrans = con.BeginTransaction(); rpta = oProductoLaboratorioDA.Eliminar(con, sqltrans, obe); if (rpta) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(rpta); }
public async Task <IHttpActionResult> Guardar(ProductoLaboratorioBE obe) { try { ProductoLaboratorioBL oProductoLaboratorioBL = new ProductoLaboratorioBL(obe.IdCliente); bool rpta = false; rpta = oProductoLaboratorioBL.Guardar(obe); if (rpta) { return(Ok(Models.Util.GetBodyResponse(200, "OK"))); } else { return(Ok(Models.Util.GetBodyResponse(300, "Ocurrió un error al guardar."))); } } catch (Exception ex) { //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex); return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }