public List<ENT_Laboratorio> ListarLaboratorio(int UsuarioID) { List<ENT_Laboratorio> oLista = new List<ENT_Laboratorio>(UsuarioID); SqlTransaction TransSql = default(SqlTransaction); connect.MyConn = new SqlConnection(connect.strCxn()); connect.MyCmd.CommandType = CommandType.StoredProcedure; connect.MyCmd.CommandText = "SLW_SP_ListarLaboratorio"; connect.MyCmd.Parameters.Clear(); connect.MyCmd.Parameters.Add("@UsuarioID", SqlDbType.Int).Value = UsuarioID; try { if (connect.MyConn.State == ConnectionState.Closed) connect.MyConn.Open(); TransSql = connect.MyConn.BeginTransaction(); connect.MyCmd.Transaction = TransSql; connect.MyCmd.Connection = connect.MyConn; SqlDataReader DrSql = default(SqlDataReader); DrSql = connect.MyCmd.ExecuteReader(); while (DrSql.Read()) { ENT_Laboratorio oEnt_Laboratorio = new ENT_Laboratorio(); oEnt_Laboratorio.NomLaboratorio = DrSql.GetString(DrSql.GetOrdinal("NomLaboratorio")); oEnt_Laboratorio.LaboratorioID = DrSql.GetInt32(DrSql.GetOrdinal("LaboratorioID")); oEnt_Laboratorio.LaboratorioCod = DrSql.GetString(DrSql.GetOrdinal("LaboratorioCod")); oEnt_Laboratorio.Ubicacion = DrSql.GetString(DrSql.GetOrdinal("Ubicacion")); oEnt_Laboratorio.FechaRegistro = DrSql.GetDateTime(DrSql.GetOrdinal("FechaRegistro")); oLista.Add(oEnt_Laboratorio); } DrSql.Close(); TransSql.Commit(); return oLista; } catch (Exception ex) { enterror = new ENT_Error(ex.Message, "ListarLaboratorio", "Web"); enterror.RegisterLog(); TransSql.Rollback(); return null; } finally { TransSql.Dispose(); connect.MyCmd.Dispose(); if (connect.MyConn.State == ConnectionState.Open) connect.MyConn.Close(); connect.MyConn.Dispose(); } }
public bool ActualizarLaboratorio(ENT_Laboratorio oEnt_Laboratorio) { SqlTransaction TransSql = default(SqlTransaction); connect.MyConn = new SqlConnection(connect.strCxn()); connect.MyCmd.CommandType = CommandType.StoredProcedure; connect.MyCmd.CommandText = "SLW_SP_ActualizarLaboratorio"; connect.MyCmd.Parameters.Clear(); connect.MyCmd.Parameters.Add("@LaboratorioID", SqlDbType.Int).Value = oEnt_Laboratorio.LaboratorioID; connect.MyCmd.Parameters.Add("@Ubicacion", SqlDbType.VarChar).Value = oEnt_Laboratorio.Ubicacion; connect.MyCmd.Parameters.Add("@NomLaboratorio", SqlDbType.VarChar).Value = oEnt_Laboratorio.NomLaboratorio; try { if (connect.MyConn.State == ConnectionState.Closed) connect.MyConn.Open(); connect.MyCmd.Connection = connect.MyConn; TransSql = connect.MyConn.BeginTransaction(); connect.MyCmd.Transaction = TransSql; connect.MyCmd.ExecuteNonQuery(); TransSql.Commit(); return true; } catch (Exception ex) { enterror = new ENT_Error(ex.Message, "ActualizarLab", "Web"); enterror.RegisterLog(); TransSql.Rollback(); return false; } finally { TransSql.Dispose(); connect.MyCmd.Dispose(); if (connect.MyConn.State == ConnectionState.Open) connect.MyConn.Close(); connect.MyConn.Dispose(); } }
protected void btnCrear_Click(object sender, EventArgs e) { ENT_Laboratorio oEnt_Laboratorio = new ENT_Laboratorio(); Dictionary<string,string> etiquetas = (Dictionary<string,string>) Session["Etiquetas"]; oEnt_Laboratorio.Ubicacion = txtDescProducto.Text.Trim(); oEnt_Laboratorio.NomLaboratorio = txtProducto.Text.Trim(); int userID = Int32.Parse(Session["UsuarioID"].ToString()); if (txtProductoID.Text.Length == 0) { int total = oLn_Empresa.VerificarRestriccion(Int32.Parse(Session["UsuarioID"].ToString()), "lab", 0); //OBTENER VALOR DE PAQUETE int paquete = Int32.Parse(Session["Paquete"].ToString()); if (paquete==0 && total >= 1) { //Response.Write("<script>alert('No puede crear más laboratorios con la licencia actual.');</script>"); Response.Write("<script>alert('" + etiquetas["ML01"] + "');</script>"); } else if (paquete==2) { oLn_Laboratorio.InsertarLab(oEnt_Laboratorio.NomLaboratorio, oEnt_Laboratorio.Ubicacion, Session["Ruc"].ToString(), userID); } } else { oEnt_Laboratorio.LaboratorioID = Int32.Parse(txtProductoID.Text.Trim()); oLn_Laboratorio.ActualizarLaboratorio(oEnt_Laboratorio); } oList_Lab = oLn_Laboratorio.ListarLaboratorio(userID); gvLaboratorio.DataSource = oList_Lab; gvLaboratorio.DataBind(); }
public bool ActualizarLaboratorio(ENT_Laboratorio oEnt_Laboratorio) { return dataTx.ActualizarLaboratorio(oEnt_Laboratorio); }
public ENT_Laboratorio ObtenerLab(string ProdLabCod) { SqlTransaction TransSql = default(SqlTransaction); connect.MyConn = new SqlConnection(connect.strCxn()); connect.MyCmd.CommandType = CommandType.StoredProcedure; connect.MyCmd.CommandText = "SLW_SP_ObtenerLab"; connect.MyCmd.Parameters.Clear(); connect.MyCmd.Parameters.Add("@ProdLabCod", SqlDbType.VarChar).Value = ProdLabCod; try { if (connect.MyConn.State == ConnectionState.Closed) connect.MyConn.Open(); TransSql = connect.MyConn.BeginTransaction(); connect.MyCmd.Transaction = TransSql; connect.MyCmd.Connection = connect.MyConn; SqlDataReader DrSql = default(SqlDataReader); DrSql = connect.MyCmd.ExecuteReader(); ENT_Laboratorio oEnt_Laboratorio = new ENT_Laboratorio(); while (DrSql.Read()) { oEnt_Laboratorio.NomLaboratorio = DrSql.GetString(DrSql.GetOrdinal("NomLaboratorio")); } DrSql.Close(); TransSql.Commit(); return oEnt_Laboratorio; } catch (Exception ex) { enterror = new ENT_Error(ex.Message, "ObtenerLab", "Web"); enterror.RegisterLog(); TransSql.Rollback(); return null; } finally { TransSql.Dispose(); connect.MyCmd.Dispose(); if (connect.MyConn.State == ConnectionState.Open) connect.MyConn.Close(); connect.MyConn.Dispose(); } }
public void Select_Change(Object sender, EventArgs e) { string Nivel = tvEstructura.SelectedNode.Value; try { Nivel = Nivel.Substring(0, 3); } catch { Nivel = "CLI"; } // lblNombreCompleto.Text = Nivel; switch (Nivel) { case "EMP": Session["EmpresaCod"] = tvEstructura.SelectedNode.Value; Response.Redirect("~/iSupervisor/Inicio.aspx"); break; case "LAB": Session["LaboratorioCod"] = tvEstructura.SelectedNode.Value; Session["NomLaboratorio"] = tvEstructura.SelectedNode.Text; Response.Redirect("~/iSupervisor/AsociarProducto.aspx"); break; case "PRO": Session["ProdLabCod"] = tvEstructura.SelectedNode.Value; Session["NomProducto"] = tvEstructura.SelectedNode.Text; ENT_Laboratorio oEnt = new ENT_Laboratorio(); oEnt = oLN_Laboratorio.ObtenerLab(tvEstructura.SelectedNode.Value); Session["NomLaboratorio"] = oEnt.NomLaboratorio.ToString(); Response.Redirect("~/iAdministradors/Historial.aspx"); break; case "PAR": Session["ProdParaCod"] = tvEstructura.SelectedNode.Value; Session["NomParametro"] = tvEstructura.SelectedNode.Text; ENT_Parametro oEntidad = new ENT_Parametro(); oEntidad = oLN_Parametro.ObtenerLab(tvEstructura.SelectedNode.Value); Session["NomLaboratorio"] = oEntidad.NomLaboratorio.ToString(); Session["NomProducto"] = oEntidad.NomProducto.ToString(); Response.Redirect("~/iAdministradors/EditarParametro.aspx"); break; case "CLI": Session["ClienteID"] = tvEstructura.SelectedNode.Value; Session["NomCliente"] = tvEstructura.SelectedNode.Text; //ENT_Cliente oEnt_Cli = new ENT_Cliente(); //oEntidad = oLN_Parametro.ObtenerLab(tvEstructura.SelectedNode.Value); //Session["NomLaboratorio"] = oEntidad.NomLaboratorio.ToString(); //Session["NomProducto"] = oEntidad.NomProducto.ToString(); //Response.Redirect("~/iAdministrador/Cliente.aspx"); break; } // Session["LaboratorioCod"] = tvEstructura.SelectedNode.Value; }