예제 #1
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                Class_Venda venda = new Class_Venda();
                venda.codvenda        = int.Parse(txtcod_venda.Text); //carrega os dados do gridview
                venda.matricula       = DropDownList1.SelectedValue;
                venda.datavenda       = DateTime.Parse(txtdatavenda.Text);
                venda.datapreventrega = DateTime.Parse(txtdatapreventrega.Text);
                venda.totalvenda      = decimal.Parse(txttotal.Text);
                venda.statusvenda     = txtstatus.Text;
                venda.enderecoEntrega = txtendereco.Text;
                venda.cartaoCredito   = int.Parse(txtcartao.Text);

                venda.alterar_dados();

                GridView1.EditIndex = -1;

                GridView1.DataSource = venda.visualizar();
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["usuario"] == null)
                {
                    Response.Redirect("login.aspx");
                }
                else
                {
                    lblusuario.Text = Session["usuario"].ToString();
                }
                if (!IsPostBack)
                {
                    Class_Vendedor vend = new Class_Vendedor();       // cria o objeto vendedor
                    DropDownList1.DataSource     = vend.visualizar(); // carrega os vendedores
                    DropDownList1.DataTextField  = "nome";            //associa o campo nome do banco de dados ao dropdown
                    DropDownList1.DataValueField = "matricula";       //associa o campo Matricula do banco de dados ao dropdown
                    DropDownList1.DataBind();                         //constroi os dados na tela

                    Class_Venda venda = new Class_Venda();            // cria o objeto venda
                    GridView1.DataSource = venda.visualizar();        //carrega todos as venda
                    GridView1.DataBind();                             //constroi os dados na tela
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
예제 #3
0
 protected void btn_Visualizar_Click(object sender, EventArgs e)
 {
     try
     {
         Class_Venda venda = new Class_Venda();
         GridView1.DataSource = venda.visualizar();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
예제 #4
0
 protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     try
     {
         GridView1.EditIndex = -1; //cancela a edição da linha
         Class_Venda venda = new Class_Venda();
         GridView1.DataSource = venda.visualizar();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
예제 #5
0
 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
 {
     try
     {
         GridView1.EditIndex = e.NewEditIndex; //ativa a edição da linha selecionada
         Class_Venda venda = new Class_Venda();
         GridView1.DataSource = venda.visualizar();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
예제 #6
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                Class_Venda venda = new Class_Venda();
                venda.codvenda = int.Parse(e.Values[0].ToString());
                venda.deletar();

                GridView1.EditIndex  = -1;
                GridView1.DataSource = venda.visualizar();
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }