viernes, 12 de julio de 2019

master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Sourcing.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sourcing Web</title>
    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>

    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="Scripts/css/Main.css" rel="stylesheet" />
    <link rel="stylesheet" href="Content/bootstrap.css" type="text/css" />
    <link href="Content/font-awesome.css" rel="stylesheet" />
    <link href="Content/font-awesome.min.css" rel="stylesheet" />
</head>
<body style="padding-top:0px;">
    <form runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>               
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
            </Scripts>
        </asp:ScriptManager>

        <div class="container" >
            <header class="py-3" style="margin-top:0px; padding-top:0px;">
                <div class="row flex-nowrap justify-content-between align-items-center">
                    <div class="col-4 pt-1">
                       
                    </div>
                    <div class="col-4 text-center">
                        <p class="display-4 text-dark h2">Sourcing Web</p>
                    </div>
                    <div class="col-4 d-flex justify-content-end align-items-center">
                        <a class="text-muted" href="#">
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="mx-3" role="img" viewBox="0 0 24 24" focusable="false">
                                <title>Search</title>
                                <circle cx="10.5" cy="10.5" r="7.5"></circle><path d="M21 21l-5.2-5.2"></path></svg>
                        </a>
                        <a class="btn btn-sm btn-outline-secondary" href="#">Sign up</a>
                    </div>
                </div>
            </header>
            <hr style="margin-top:0px;margin-bottom:0px;" />
            <div class="nav-scroller py-1 mb-2">
                <nav class="nav d-flex justify-content-between">
                    <a class="p-2 text-muted" href="Default">Home</a>
                    <a class="p-2 text-muted" href="#">Procedures</a>
                    <a class="p-2 text-muted" href="#">WindChill</a>
                    <a class="p-2 text-muted" href="#">Reports</a>
                    <a class="p-2 text-muted" href="#">Marketing</a>
                    <a class="p-2 text-muted" href="VendorMaster/SuppliersList">Vendor Master</a>
                    <a class="p-2 text-muted" href="#">MNDA's / NDA's</a>
                    <a class="p-2 text-muted" href="#">Premium</a>
                    <a class="p-2 text-muted" href="About">About Us</a>
                    <a class="p-2 text-muted" href="Contact">Contacts</a>
                </nav>
            </div>
           
        </div>
        <div class="container body-content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
               
            </asp:ContentPlaceHolder>
            <hr />
            <footer class="footer">
                <p>&copy; <%: DateTime.Now.Year %> - Sourcing</p>
            </footer>
        </div>

    </form>
</body>
</html>


NO CODE BEHIND

-----------------------------------------------------------
DEFAULT

<%@ Page Title="Sourcing" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Sourcing._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
   

    <div class="container">
        <div class="col-sm-12">
            <div id="car" class="carousel slide" data-ride="carousel">
                <ol class="carousel-indicators" id="ind">
                    <li data-target="#car" data-slide-to="0" class="active"></li>
                    <li data-target="#car" data-slide-to="1"></li>
                </ol>
                <div class="carousel-inner">
                    <div class="carousel-item active" style="padding: 0 1rem;">
                        <img src="/Img/sour2.png" alt="..." style="margin-left: auto; margin-right: auto; display: block;">
                    </div>
                    <div class="carousel-item" style="padding: 0 1rem;">
                        <img src="/Img/sour3.png" alt="..." style="margin-left: auto; margin-right: auto; display: block;">
                    </div>
                </div>
                <div>
                </div>
                <a class="carousel-control-prev" href="#car" role="button" data-slide="prev" id="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true" style="color: gray;"></span>
                    <span class="sr-only">Previous</span>
                </a>
                <a class="carousel-control-next" href="#car" role="button" data-slide="next" id="next">
                    <span class="carousel-control-next-icon" aria-hidden="true" style="color: gray;"></span>
                    <span class="sr-only">Next</span>
                </a>
            </div>

            <div class="row">
                <div class="col-sm-4" style="text-align: center;">
                    <img src="Img/tren.png" width="140" height="140" />
                    <h2>Trending</h2>
                    <p>See what's new in Marketing.</p>
                    <p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
                </div>
                <div class="col-sm-4" style="text-align: center;">
                    <img src="Img/reports.png" width="140" height="140" />
                    <h2>Reports</h2>
                    <p>See all the reports that are ready.</p>
                    <p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
                </div>
                <div class="col-sm-4" style="text-align: center;">
                    <img src="Img/process.png" width="140" height="140" />
                    <h2>Procedures</h2>
                    <p>Take a look to all the sourcing procedures.</p>
                    <p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
                </div>
            </div>
        </div>
        <hr style="margin-top:50px; margin-bottom: 50px;" />
    </div>

  
   <script src="Scripts/js/Main.js"></script>
   
</asp:Content>

NO CODE ATRAS
-----------------------------------------------------------------

SUPLIEERS LIST


<%@ Page Title="Vendor Master" Language="C#" AutoEventWireup="true" CodeBehind="SuppliersList.aspx.cs" Inherits="Sourcing.VendorMaster.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="Content/bootstrap.css" type="text/css" />
    <link href="../Content/bootstrap.min.css" rel="stylesheet" />
    <link href="../Content/bootstrap.css" rel="stylesheet" />
    <script src="../Scripts/jquery-3.4.1.min.js"></script>
    <script src="../Scripts/bootstrap.min.js"></script>
    <link href="../Content/font-awesome.css" rel="stylesheet" />
    <link href="../Content/font-awesome.min.css" rel="stylesheet" />
    <link href="../Scripts/css/VendorMaster.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
        <nav class="nav navbar-expand-sm bg-dark navbar-dark">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a href="../Default.aspx" class="nav-link">
                        <img src="../Img/volver.png" style="width: 50px;" />
                        Return
                    </a>
                </li>
            </ul>
        </nav>
        <div class="col-12">
            <div class="row" id="firstRow">
                <div class="col-2">
                    <input type="text" runat="server" id="searchNumber" class="form-control" placeholder="Vendor No." />
                </div>
                <div class="col-2">
                    <input type="text" runat="server" id="searchName" class="form-control" placeholder="Vendor Name" />
                </div>
                <div class="col-2">
                    <asp:Button runat="server" id="searchButton" class="btn btn-success w-50" text="Search" OnClick="searchFunction" />
                </div>
                <div class="col-2"></div>
                <div class="col-2">
                    <button runat="server" id="exportCustom" class="btn btn-info w-100">Export Custom Grid</button>
                </div>
                <div class="col-2">
                    <asp:Button runat="server" ID="exportAll" CssClass="btn btn-info w-100" Text="Export Entire Grid" />
                </div>
            </div>
            <hr />
            <div class="row" id="secondRow">
                <div class="col-3" >
                    <div id="divSelectCol">
                        <h4>Select Columns (Optional)</h4>
                        <hr />
                        <div>
                            <asp:Button runat="server" OnClick="ColumnListButton" Text="Select Columns"/>
                        </div>
                        <asp:CheckBoxList runat="server" ID="columnList" BorderColor="#666699" BorderWidth="1" CellPadding="5"
                            DataTextField="COLUMN_NAME" DataValueField="COLUMN_NAME" CssClass="w-100">
                        </asp:CheckBoxList>
                    </div>
                </div>
                <div class="col-9" id="divGridView">
                    <asp:GridView ID="gridSuppliers" runat="server"
                        AutoGenerateColumns="true" Font-Size="Small" CellPadding="5" AutoGenerateEditButton="true"
                        OnRowEditing="gridSuppliers_RowEditing" OnRowCancelingEdit="gridSuppliers_RowCancelingEdit" OnRowUpdating="gridSuppliers_RowUpdating">
                       <Columns>
                           <asp:TemplateField>
                               <ItemTemplate>
                               </ItemTemplate>
                           </asp:TemplateField>
                       </Columns>
                    </asp:GridView>
                </div>
            </div>
        </div>
        <asp:Label ID="catchLabel" runat="server"></asp:Label>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Sql;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;

namespace Sourcing.VendorMaster
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        static string conexion;
        SqlConnection SqlCon;

        protected void Page_Load(object sender, EventArgs e)

        {
            conexion = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=Sourcing;Integrated Security=True;";
            SqlCon = new SqlConnection(conexion);
           
        }

        protected void FillGridSuppliers()
        {
            string sqlQuery;
           
            try
            {
                SqlCon.Open();
                sqlQuery = "Select * from [Sourcing].[dbo].[User]";
                SqlCommand cmd = new SqlCommand(sqlQuery, SqlCon);
                SqlDataAdapter Datos = new SqlDataAdapter(cmd);
                DataTable TablaDatos = new DataTable();
                Datos.Fill(TablaDatos);
                gridSuppliers.DataSource = TablaDatos;
                gridSuppliers.DataBind();
                SqlDataReader Dr = cmd.ExecuteReader();

                SqlCon.Close();
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                catchLabel.Text = e.Message.ToString();
            }
        }

        protected void FillSelectedColumns()
        {

            string sqlQuery = "";
            string selectedColumns = "";

            if (columnList.Items.Count > 0)
            {
                for (int i = 0; i < columnList.Items.Count; i++)
                {
                    if (columnList.Items[i].Selected == true)
                    {
                        if (selectedColumns == "")
                        {
                            selectedColumns = columnList.Items[i].ToString();
                        }
                        else
                        {
                            selectedColumns = selectedColumns + "," + columnList.Items[i].ToString();
                        }
                    }
                }
                sqlQuery = "select " + selectedColumns + " from [Sourcing].[dbo].[User]";
            }
            else
            {
                sqlQuery = "Select * from [Sourcing].[dbo].[User]";
            }
            try
            {
                SqlCon.Open();
                SqlCommand cmd = new SqlCommand(sqlQuery, SqlCon);
                SqlDataAdapter Datos = new SqlDataAdapter(cmd);
                DataTable TablaDatos = new DataTable();
                Datos.Fill(TablaDatos);
                gridSuppliers.DataSource = TablaDatos;
                gridSuppliers.DataBind();
                SqlDataReader Dr = cmd.ExecuteReader();

                SqlCon.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                catchLabel.Text = ex.Message.ToString();
            }
        }

        protected void ColumnListButton(object sender, EventArgs e)
        {
            List<string> colNameList = new List<string>();
            string sqlQuery;
            try
            {
                SqlCon.Open();
                sqlQuery = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'User'";
                SqlCommand cmd = new SqlCommand(sqlQuery, SqlCon);
                SqlDataAdapter Datos = new SqlDataAdapter(cmd);
                DataTable TablaDatos = new DataTable();
                Datos.Fill(TablaDatos);
                columnList.DataSource = TablaDatos;
                columnList.DataBind();
                SqlDataReader Dr = cmd.ExecuteReader();

                SqlCon.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                catchLabel.Text = ex.Message.ToString();
            }
           
        }

        protected void searchFunction(object sender, EventArgs e)
        {
            FillSelectedColumns();
        }

        protected void gridSuppliers_RowEditing(object sender, System.Web.UI.WebControls.GridViewEditEventArgs e)
        {
            gridSuppliers.EditIndex = e.NewEditIndex;
            FillSelectedColumns();
        }

        protected void gridSuppliers_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gridSuppliers.EditIndex = -1;
            FillSelectedColumns();
        }

        protected void gridSuppliers_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {

        }
    }
}

------------------------------------------------------


CSS

body {
    background-color: #ededed;
}

#divGridView {
    padding: 15px;
    border-radius: 15px;
    background-color: white;
}
#firstRow {
    margin: 10px 0px 10px 0px;
   

}
#secondRow {
    padding:10px;
}
#divSelectCol {
    border-radius: 15px;
    background-color: white;
    padding:15px;
}








-----------------------

body {
}
.footer {
 
}
#next {
    border-radius: 15px;
    background: linear-gradient(to left, #666699 -2%, #ffffff 80%);
}
#prev {
    background: linear-gradient(to right, #666699 -2%, #ffffff 80%);
    border-radius: 15px;
}
#car{
    border-radius:15px;
}