public ActionResult newSucursal(Sucursal newSucursal)
 {
     Respuesta resp = new Respuesta();
     SqlConnection myConnection = new SqlConnection();
     try
     {
         myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
         myConnection.Open();
         SqlCommand command = new SqlCommand("INSERT INTO SUCURSAL (SUCC_ID, SUCC_DES) VALUES (@ID, @DES) ", myConnection);
         command.Parameters.AddWithValue("@ID", newSucursal.succ_id);
         command.Parameters.AddWithValue("@DES", newSucursal.succ_des);
         command.ExecuteNonQuery();
         command.Parameters.Clear();
     }
     catch (SqlException ex)
     {
         resp.success = false;
         resp.message = "ERROR " + ex.Message;
         return Json(resp);
     }
     finally
     {
         myConnection.Close();
     }
     resp.success = true;
     resp.message = "OK";
     return Json(resp);
 }
        public ActionResult updateSucursal(Sucursal sucursal)
        {
            Respuesta resp = new Respuesta();
            SqlConnection myConnection = new SqlConnection();
            try
            {
                myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
                myConnection.Open();
                SqlCommand command = new SqlCommand("UPDATE SUCURSAL SET SUCC_DES = @DES WHERE SUCC_ID = @ID ", myConnection);
                command.Parameters.AddWithValue("@ID", sucursal.succ_id);
                command.Parameters.AddWithValue("@DES", sucursal.succ_des);
                if (0 < command.ExecuteNonQuery())
                {
                    resp.success = true;
                    resp.message = "OK";
                }
                else
                {
                    resp.success = false;
                    resp.message = "NO HUBO ACTUALIZACION";
                }
                command.Parameters.Clear();
            }
            catch (SqlException ex)
            {
                resp.success = false;
                resp.message = "ERROR " + ex.Message;
                return Json(resp);
            }
            finally
            {
                myConnection.Close();
            }

            return Json(resp);
        }
 public ActionResult getSucursales()
 {
     RespSucursal respSucursales = new RespSucursal();
     SqlDataReader reader = null;
     SqlConnection myConnection = new SqlConnection();
     try
     {
         myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
         myConnection.Open();
         SqlCommand command = new SqlCommand("select * from SUCURSAL;", myConnection);
         reader = command.ExecuteReader();
         List<Sucursal> listaSucursales = new List<Sucursal>();
         while (reader.Read())
         {
             Sucursal suc = new Sucursal();
             suc.succ_des = reader["succ_des"].ToString();
             suc.succ_id = Convert.ToInt32(reader["succ_id"].ToString());
             listaSucursales.Add(suc);
         }
         respSucursales.sucursales = listaSucursales;
     }
     catch (Exception ex)
     {
         respSucursales.success = false;
         respSucursales.message = "ERROR " + ex.Message;
         return Json(respSucursales);
     }
     finally
     {
         myConnection.Close();
     }
     respSucursales.success = true;
     respSucursales.message = "OK";
     return Json(respSucursales);
 }