Exemple #1
0
        protected void btnguardar_Click(object sender, EventArgs e)
        {
            NotaRecojoDAO nota = new NotaRecojoDAO();

            Model.Enity.NotaRecojo nt = new Model.Enity.NotaRecojo();
            nt.Fecha       = txtfecha.Text;
            nt.Id_Cliente  = Convert.ToInt32(ddlcliente.SelectedValue);
            nt.Id_Vendedor = Convert.ToInt32(Session["IDUsuario"].ToString());
            nt.Nota        = txtnota.Text;
            nt.sw          = false;
            nt.swdecrip    = " ";
            Int64 id = nota.InsertarNotaRecojo(nt);

            foreach (GridViewRow fila in grvDetalles.Rows)
            {
                NotaRecojoDetalle det    = new NotaRecojoDetalle();
                TextBox           precio = (TextBox)fila.FindControl("txtprecio");
                det.Precio      = Math.Round(Convert.ToDecimal(precio.Text), 2);
                det.Id_Producto = Convert.ToInt32(fila.Cells[0].Text);
                nota.InsertarNotaRecojoDetalle(det, id);
            }



            Response.Redirect("ManteNotaRecojoVendedor.aspx", true);
        }
Exemple #2
0
 public Int64 InsertarNotaRecojo(NotaRecojo en)
 {
     try
     {
         Int64  id     = 0;
         string numero = obtener();
         en.Numero_Recojo = numero.ToString().PadLeft(8, '0');
         string cnx = db.Database.Connection.ConnectionString;
         con     = new SqlConnection(cnx);
         comando = new SqlCommand("usp_NotaRecojoInsert", con);
         comando.Parameters.AddWithValue("@Id_cliente", en.Id_Cliente);
         comando.Parameters.AddWithValue("@Numero", en.Numero_Recojo);
         comando.Parameters.AddWithValue("@idvendedor", en.Id_Vendedor);
         comando.Parameters.AddWithValue("@fecha", en.Fecha);
         comando.Parameters.AddWithValue("@nota", en.Nota);
         comando.Parameters.AddWithValue("@sw", en.sw);
         comando.Parameters.AddWithValue("@descrip", en.swdecrip);
         comando.CommandType = System.Data.CommandType.StoredProcedure;
         con.Open();
         id = Convert.ToInt64(comando.ExecuteScalar().ToString());
         return(id);
         //comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         con.Close();
     }
 }
Exemple #3
0
 public void ActualizarNotaRecojo(NotaRecojo en)
 {
     try
     {
         string cnx = db.Database.Connection.ConnectionString;
         con     = new SqlConnection(cnx);
         comando = new SqlCommand("usp_NotaRecojoUpdate", con);
         comando.Parameters.AddWithValue("@id", en.Id);
         comando.Parameters.AddWithValue("@Id_cliente", en.Id_Cliente);
         comando.Parameters.AddWithValue("@Numero", en.Numero_Recojo);
         comando.Parameters.AddWithValue("@idvendedor", en.Id_Vendedor);
         comando.Parameters.AddWithValue("@fecha", en.Fecha);
         comando.Parameters.AddWithValue("@nota", en.Nota);
         comando.Parameters.AddWithValue("@sw", en.sw);
         comando.Parameters.AddWithValue("@swdes", en.swdecrip);
         comando.CommandType = System.Data.CommandType.StoredProcedure;
         con.Open();
         comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         con.Close();
     }
 }
 protected void btnguardar_Click(object sender, EventArgs e)
 {
     try
     {
         Model.Enity.NotaRecojo nt = new Model.Enity.NotaRecojo();
         nt.Id            = Convert.ToInt32(Request.QueryString["IDMP"]);
         nt.Numero_Recojo = txtnumerorecojo.Text;
         nt.Id_Vendedor   = Convert.ToInt32(txtxvendedor.Text);
         nt.Id_Cliente    = Convert.ToInt32(ddlcliente.SelectedValue);
         nt.Nota          = txtnota.Text;
         nt.Fecha         = txtfecha.Text;
         nt.sw            = chkrecojo.Checked;
         Int32 id = nt.Id;
         if (chkrecojo.Checked == true)
         {
             nt.swdecrip = "Si Recogio";
         }
         else
         {
             nt.swdecrip = "No Recogio";
         }
         NotaRecojoDAO nota = new NotaRecojoDAO();
         nota.ActualizarNotaRecojo(nt);
         nota.EliminarDetalle(id);
         foreach (GridViewRow fila in grvDetalles.Rows)
         {
             NotaRecojoDetalle det    = new NotaRecojoDetalle();
             TextBox           precio = (TextBox)fila.FindControl("txtprecio");
             det.Id_Producto = Convert.ToInt32(fila.Cells[0].Text);
             det.Precio      = Convert.ToDecimal(precio.Text);
             nota.InsertarNotaRecojoDetalle(det, id);
         }
         Response.Redirect("ManteNotaRecojo.aspx", true);
     }
     catch (Exception ex)
     {
         txtmensaje.Text = ex.Message;
         string script = "openModal();";
         ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
     }
 }