public List <ClientBusiness_Entity> listClientBusiness() { List <ClientBusiness_Entity> list = new List <ClientBusiness_Entity>(); try { sqlConnection.Open(); sqlCommand = new SqlCommand("list_client_business", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { ClientBusiness_Entity client_business = new ClientBusiness_Entity(); client_business.id_client_business = Convert.ToInt32(sqlDataReader["Identificador"]); client_business.name_client_business = sqlDataReader["Nombre Empresa"].ToString(); list.Add(client_business); } } catch (Exception e) { throw; } return(list); }
public ActionResult InsertClientBusiness(string business_name, string nit_business, string quantEmployees, string cbxTypeBusiness, string cbxCreditCard) { String script = ""; int quantity = Convert.ToInt32(quantEmployees); ClientBusiness_Entity client_business = new ClientBusiness_Entity(); client_business.name_client_business = business_name; client_business.nit = nit_business; client_business.quantity_employees = quantity; client_business.typeBusiness_Entity.id_type_business = Convert.ToInt32(cbxTypeBusiness); client_business.creditCard_Entity.id_credit_card = Convert.ToInt32(cbxCreditCard); if (quantity >= 1 && quantity <= 10) { client_business.sizeBusiness_Entity.id_size_business = 1; } else if (quantity >= 11 && quantity <= 15) { client_business.sizeBusiness_Entity.id_size_business = 2; } else if (quantity >= 16 && quantity <= 25) { client_business.sizeBusiness_Entity.id_size_business = 3; } else if (quantity >= 25 && quantity <= 40) { client_business.sizeBusiness_Entity.id_size_business = 4; } else if (quantity >= 41 && quantity <= 50) { client_business.sizeBusiness_Entity.id_size_business = 5; } else if (quantity > 50) { client_business.sizeBusiness_Entity.id_size_business = 6; } if (clientBusiness_Logic.addClientBusiness(client_business)) { script = "<script languaje='javascript'>" + "alert('Cliente agregado correctamente'); " + "window.location.href = '/Index/Home'; " + "</script>"; } else { script = "<script languaje='javascript'>" + "alert('No se pudo agregar');" + "window.location.href = '/ClientBusiness/AddClientBusiness'; " + "</script>"; } return(Content(script)); }
public ClientBusiness_Entity searchClientBusiness(int id) { ClientBusiness_Entity client_business = new ClientBusiness_Entity(); try { sqlConnection.Open(); sqlCommand = new SqlCommand("search_client_business", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter id_parameter = new SqlParameter(); id_parameter.ParameterName = "@idClient"; id_parameter.SqlDbType = SqlDbType.Int; id_parameter.Value = id; sqlCommand.Parameters.Add(id_parameter); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); sqlDataReader.Read(); if (sqlDataReader.HasRows) { client_business.id_client_business = Convert.ToInt32(sqlDataReader["Identificador"]); client_business.name_client_business = sqlDataReader["Nombre Empresa"].ToString(); client_business.quantity_employees = Convert.ToInt32(sqlDataReader["Cantidad de Empleados"]); client_business.typeBusiness_Entity.type_business = sqlDataReader["Tipo de Empresa"].ToString(); client_business.sizeBusiness_Entity.size = sqlDataReader["Tamaño de Empresa"].ToString(); client_business.typeCard_Entity.type_card = sqlDataReader["Tarjeta de Crédito"].ToString(); client_business.sizeBusiness_Entity.name_size = sqlDataReader["Nombre Tamaño"].ToString(); } } catch (Exception e) { throw; } return(client_business); }
public bool addClientBusiness(ClientBusiness_Entity client_business) { bool response = false; try { sqlConnection.Open(); sqlCommand = new SqlCommand("add_client_business", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter p_idTypeBusiness = new SqlParameter(); p_idTypeBusiness.ParameterName = "@idTypeBusiness"; p_idTypeBusiness.SqlDbType = SqlDbType.Int; p_idTypeBusiness.Value = client_business.typeBusiness_Entity.id_type_business; SqlParameter p_idSizeBusiness = new SqlParameter(); p_idSizeBusiness.ParameterName = "@idSizebusiness"; p_idSizeBusiness.SqlDbType = SqlDbType.Int; p_idSizeBusiness.Value = client_business.sizeBusiness_Entity.id_size_business; SqlParameter p_idCreditCard = new SqlParameter(); p_idCreditCard.ParameterName = "@idCreditCard"; p_idCreditCard.SqlDbType = SqlDbType.Int; p_idCreditCard.Value = client_business.creditCard_Entity.id_credit_card; SqlParameter p_nit = new SqlParameter(); p_nit.ParameterName = "@nit"; p_nit.SqlDbType = SqlDbType.VarChar; p_nit.Size = 20; p_nit.Value = client_business.nit; SqlParameter p_nameClientBusiness = new SqlParameter(); p_nameClientBusiness.ParameterName = "@nameClientBusiness"; p_nameClientBusiness.SqlDbType = SqlDbType.VarChar; p_nameClientBusiness.Size = 20; p_nameClientBusiness.Value = client_business.name_client_business; SqlParameter p_quantityEmployees = new SqlParameter(); p_quantityEmployees.ParameterName = "@quantityEmployess"; p_quantityEmployees.SqlDbType = SqlDbType.Int; p_quantityEmployees.Value = client_business.quantity_employees; sqlCommand.Parameters.Add(p_idTypeBusiness); sqlCommand.Parameters.Add(p_idSizeBusiness); sqlCommand.Parameters.Add(p_idCreditCard); sqlCommand.Parameters.Add(p_nit); sqlCommand.Parameters.Add(p_nameClientBusiness); sqlCommand.Parameters.Add(p_quantityEmployees); sqlCommand.ExecuteNonQuery(); response = true; sqlConnection.Close(); } catch (Exception e) { throw; } return(response); }
public bool addClientBusiness(ClientBusiness_Entity client_business) { return(clientBusiness_Data.addClientBusiness(client_business)); }