Esempio n. 1
0
 protected void btnguardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (cmbcli.SelectedValue != "0" || cmbpro.SelectedValue != "0")
         {
             entVentas obj = new entVentas();
             obj.Operacion   = 1;
             obj.id          = Convert.ToInt32(Session["Idventacli"]);
             obj.id_compania = Convert.ToInt32(cmbcli.SelectedValue);
             obj.id_producto = Convert.ToInt32(cmbpro.SelectedValue);
             if (negVentas.AgregarVentasClientes(obj) == 1)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "Guardado()", true);
                 LimpiarCampos();
                 pnlagregarventacli.Visible = false;
                 btnnuevavta.Visible        = true;
                 CargarGrillaVentasClientes();
                 Session["Idventacli"] = "0";
                 btnvtsxcli.Visible    = true;
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "sindatos()", true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        public static int AgregarVentasClientes(entVentas obj)
        {
            int        indicador = 0;
            SqlCommand cmd       = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("SP_TRANSAC_VENTAS_CLIENTES", cnx);
                cmd.Parameters.AddWithValue("@Operacion", obj.Operacion);
                cmd.Parameters.AddWithValue("@id", obj.id);
                cmd.Parameters.AddWithValue("@id_compania", obj.id_compania);
                cmd.Parameters.AddWithValue("@id_producto", obj.id_producto);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                cmd.ExecuteNonQuery();
                indicador = 1;
            }
            catch (Exception ex)
            {
                throw ex;
                //indicador = 0;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(indicador);
        }
Esempio n. 3
0
        public static List <entVentas> ListarVentasxClientes(int idcli)
        {
            SqlCommand       cmd         = null;
            SqlDataReader    dr          = null;
            List <entVentas> listavtacli = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("SP_CARGAR_VENTAS_X_CLI", cnx);
                cmd.Parameters.AddWithValue("@id", idcli);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr          = cmd.ExecuteReader();
                listavtacli = new List <entVentas>();
                while (dr.Read())
                {
                    entVentas c = new entVentas();
                    c.id           = Convert.ToInt32(dr["id"].ToString());
                    c.idpro        = Convert.ToInt32(dr["idpro"].ToString());
                    c.descproducto = dr["descproducto"].ToString();
                    c.descripcion  = dr["descripcion"].ToString();
                    c.valor        = dr["valor"].ToString();

                    listavtacli.Add(c);
                }
            }
            catch (Exception e)
            {
                throw e;
                //listacom = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(listavtacli);
        }
Esempio n. 4
0
        public static List <entVentas> ListarVentasCompanias()
        {
            SqlCommand       cmd      = null;
            SqlDataReader    dr       = null;
            List <entVentas> listavta = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd             = new SqlCommand("SP_CARGAR_VENTAS_TOTAL_COM", cnx);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr       = cmd.ExecuteReader();
                listavta = new List <entVentas>();
                while (dr.Read())
                {
                    entVentas c = new entVentas();
                    c.id           = Convert.ToInt32(dr["id"].ToString());
                    c.idcom        = Convert.ToInt32(dr["idcom"].ToString());
                    c.descCompania = dr["descCompania"].ToString();
                    c.idpro        = Convert.ToInt32(dr["idpro"].ToString());
                    c.descproducto = dr["descproducto"].ToString();

                    listavta.Add(c);
                }
            }
            catch (Exception e)
            {
                throw e;
                //listacom = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(listavta);
        }
Esempio n. 5
0
        public static entVentas ListarVentasEditarClientes(int operacion, int idvta)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            entVentas     obj = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("SP_TRANSAC_VENTAS_CLIENTES", cnx);
                cmd.Parameters.AddWithValue("@Operacion", operacion);
                cmd.Parameters.AddWithValue("@id", idvta);
                cmd.Parameters.AddWithValue("@id_compania", "");
                cmd.Parameters.AddWithValue("@id_producto", "");
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr  = cmd.ExecuteReader();
                obj = new entVentas();
                dr.Read();
                entVentas c = new entVentas();
                obj.id           = Convert.ToInt32(dr["id"].ToString());
                obj.idcli        = Convert.ToInt32(dr["idcli"].ToString());
                obj.nombre       = dr["nombre"].ToString();
                obj.idpro        = Convert.ToInt32(dr["idpro"].ToString());
                obj.descproducto = dr["descproducto"].ToString();
            }
            catch (Exception e)
            {
                throw e;
                //listacom = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(obj);
        }
Esempio n. 6
0
 protected void btneditar_Click(object sender, EventArgs e)
 {
     try
     {
         btnvtsxcli.Visible = false;
         Button      btneditar     = (Button)sender;
         TableCell   grvventasclie = (TableCell)btneditar.Parent;
         GridViewRow row           = (GridViewRow)grvventasclie.Parent;
         grvventascli.SelectedIndex = row.RowIndex;
         int fila  = row.RowIndex;
         int idvta = int.Parse(grvventascli.Rows[fila].Cells[0].Text);
         Session["Idventacli"] = idvta;
         int       operacion = 2;
         entVentas obj       = negVentas.ListarVentasEditarClientes(operacion, idvta);
         cmbcli.SelectedValue       = Convert.ToInt32(obj.idcli).ToString();
         cmbpro.SelectedValue       = Convert.ToInt32(obj.idpro).ToString();
         pnlagregarventacli.Visible = true;
         btnnuevavta.Visible        = false;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 7
0
 public static int AgregarVentasClientes(entVentas obj)
 {
     return(daoVentas.AgregarVentasClientes(obj));
 }
Esempio n. 8
0
 public static int AgregarVentasCompanias(entVentas obj)
 {
     return(daoVentas.AgregarVentasCompanias(obj));
 }