public ActionResult WCO01Menu(string valor2, WCO01_ListaContratos Contratos )
        {
        
            if (ModelState.IsValid)
            {

            }
            return View();
        }
 public ActionResult WCO01Menu(string IDContrato, string NContrato, string NombreAsesor, 
     string CodAsesor, string NombreCliente, string ODP)
 {
     WCO01_ListaContratos man = new WCO01_ListaContratos();
     man.IDLinea = Convert.ToInt32(IDContrato);
     man.NContrato = NContrato;
     man.NombreVendedor = NombreAsesor;
     man.CodAsesor = CodAsesor;
     man.NombreCliente = NombreCliente;
     man.ODP = ODP;
     return View(man);
 }
        public ActionResult WCO01MenuAdd(FormCollection formCollection, WCO01_ListaContratos contrats)
        {
            //foreach (string key in formCollection.AllKeys)
            //{
            //    Response.Write("Key= " + key + "      ");
            //    Response.Write(formCollection[key]);
            //    Response.Write("<br/>");
            //}
            //Response.Write("nada");
            try
            {
                if (ModelState.IsValid)
                {
                    WCO01_ListaContratos man = new WCO01_ListaContratos();
                    man.IDLinea = 0;
                    man.NContrato = formCollection["NContrato"];
                    man.CodCliente = formCollection["CodCliente"];
                    man.NombreCliente = formCollection["NombreCliente"];
                    man.ODP = formCollection["ODP"];
                    man.Empresa = formCollection["Empresa"];
                    man.FechaContrato = Convert.ToDateTime(formCollection["FechaContrato"]);
                    man.CodAsesor = formCollection["CodAsesor"];
                    man.Estado = 0;
                    man.QuienIngreso = "dvargas";
                    int resultado = GestorWCO01.WCO01_INSERT(man);
                    //Luego ver si pasa un error que dato dar.

                    return RedirectToAction("WCO01MenuBuscar");
                    //return View();
                }
            }
            catch (ExecutionEngineException ex /* edx */)
            {
                return View();
            }
            return View();

        }
        public ActionResult WCO01MenuAdd(string cod, string nombre, string Telefono, string CodAsesor, string vendedor)
        {
            WCO01_ListaContratos man = new WCO01_ListaContratos();
            if (Telefono != null)
            {
                ViewBag.cod = cod;
                ViewBag.nombre = nombre;
                ViewBag.telefono = Telefono;

                man.CodCliente = ViewBag.cod;
                man.NombreCliente = ViewBag.nombre;
                man.Telefono = ViewBag.Telefono;
            }
            else
            {
                //ViewBag.CodAsesor = CodAsesor;
                //ViewBag.vendedor = vendedor;
                ViewBag.CodAsesor = cod;
                ViewBag.vendedor = nombre;
                man.CodAsesor = ViewBag.CodAsesor;
                man.NombreVendedor = ViewBag.vendedor;

            }
            
            return View(man);
        }
        public WCO01_ListaContratos CargarListaContratos2()
        {
            WCO01_ListaContratos man = new WCO01_ListaContratos();
            var con = new SqlConnection (db.Database.Connection.ConnectionString);
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = new SqlCommand();
                adapter.SelectCommand.CommandText = "WCO01_ListaContratos";
                adapter.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                adapter.SelectCommand.Connection = con;

                DataTable dt = new DataTable();
                adapter.Fill(dt);
                adapter.SelectCommand.Connection.Close();
              
        

            return man;

        }
 public static int WCO01_INSERT(WCO01_ListaContratos Contrato)
 {
       db = new siawinContext();
     List<CC01> man = new List<CC01>();
     SqlConnection conexion = new SqlConnection(db.Database.Connection.ConnectionString);
     conexion.Close();
     try
     {
         SqlCommand cmd = new SqlCommand("WCO01_INSERT", conexion);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("IDLinea", Contrato.IDLinea);
         cmd.Parameters.AddWithValue("NContrato", Contrato.NContrato);
         cmd.Parameters.AddWithValue("CodCliente", Contrato.CodCliente);
         cmd.Parameters.AddWithValue("NombreCliente", Contrato.NombreCliente);
         cmd.Parameters.AddWithValue("ODP", Contrato.ODP);
         cmd.Parameters.AddWithValue("FechaContrato", Contrato.FechaContrato);
         cmd.Parameters.AddWithValue("CodAsesor", Contrato.CodAsesor);
         cmd.Parameters.AddWithValue("Estado", Contrato.Estado);
         cmd.Parameters.AddWithValue("QuienIngreso", Contrato.QuienIngreso);
         conexion.Open();
         cmd.ExecuteNonQuery();
         conexion.Close();
         return 1;
     }
     catch (Exception)
     {
         return -1;
     }
 }